PDA

View Full Version : Template Skill Line Help



Brianide
August 17th, 2014, 23:40
I want to create an object that holds a line for a skill. It just needs to hold a stringcontrol label and a modified numberfield rank. When the rank is double-clicked, I need the label text to go to the chat box. I'm looking at something like this:

--<template name="skill_line">
----<stringcontrol name="label" />
----<numberfield name="rank">
------<script>
--------function onDoubleClick(x,y)
----------local rRoll = { sType = "dice", sDesc = getLabelText(), aDice = StringManager.convertStringToDice("4DF"), nMod = getValue() };
----------ActionsManager.performAction(nil, nil, rRoll);
--------end
------</script>
----</numberfield>
--</template>

Is a template appropriate to handle an object like this, or do I have to make something like a windowclass? In the case of a windowclass, can I make instances of it via xml like I would a template? And what's the proper way to reference the label's text for sDesc? In a window class, it looks like it'd be window.label.getValue(), but I would guess that doesn't work in a template. Any info is greatly appreciated.

Brianide
August 18th, 2014, 02:02
Alternately, can I just set a variable held by a numberfield when I create it, then pass that variable on double click? Like so:

In sheet layout:
--<my_number_field label_string="Skill Name">

Then defining the template:
--<template name="my_number_field">
----<numberfield name="rank">
------<script>
--------function onDoubleClick(x,y)
----------local rRoll = { sType = "dice", sDesc = label_string, aDice = StringManager.convertStringToDice("4DF"), nMod = getValue() };
----------ActionsManager.performAction(nil, nil, rRoll);
--------end
------</script>
----</numberfield>
--</template>

So here I'd be setting label_string when I create an instance of my_number_field, and then I'd be using that value as sDesc for the roll. Is this possible?

Brianide
August 18th, 2014, 03:32
I found a workaround - I'm just going to set the name of my rank fields to the text I want it to display, and then I can use getName(). I'd still be happy to read a proper solution if anyone has one.

Trenloe
August 18th, 2014, 07:00
You can access XML parameters from scripts, see the "Access XML values from scripts" section here: https://www.fantasygrounds.com/modguide/scripting.xcp

Have a look at <template name="string_labeled"> in the CoreRPG \campaign\template_char.xml file - this makes use of a custom XML tag (labelres) and uses that to get the string resource - using Interface.getString. More info on Interface.getString here: https://www.fantasygrounds.com/refdoc/Interface.xcp#getString This looks for text resources which are usually defined in XML files found in the \strings directory in the ruleset.

Brianide
August 19th, 2014, 02:56
Thanks, that should be exactly what I need. I'll give it a look sometime soon.

damned
August 19th, 2014, 03:50
Brianide - please post your finished solution when done. I am attempting a new character sheet and am struggling with the learning curve, Any good well documented examples are much appreciated!

Brianide
August 25th, 2014, 04:42
I cheated to get this working how I want, but I'd be happy to help however I'm able. PM me what you need, and we'll see what we can do. But for now, it's time to sleep.