Thread: Template Skill Line Help
-
August 17th, 2014, 23:40 #1
- Join Date
- Jul 2011
- Posts
- 43
Template Skill Line Help
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.Last edited by Brianide; August 18th, 2014 at 02:05.
-
August 18th, 2014, 02:02 #2
- Join Date
- Jul 2011
- Posts
- 43
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?Last edited by Brianide; August 18th, 2014 at 02:26.
-
August 18th, 2014, 03:32 #3
- Join Date
- Jul 2011
- Posts
- 43
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.
-
August 18th, 2014, 07:00 #4
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/refdo....xcp#getString This looks for text resources which are usually defined in XML files found in the \strings directory in the ruleset.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
August 19th, 2014, 02:56 #5
- Join Date
- Jul 2011
- Posts
- 43
Thanks, that should be exactly what I need. I'll give it a look sometime soon.
-
August 19th, 2014, 03:50 #6
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!
-
August 25th, 2014, 04:42 #7
- Join Date
- Jul 2011
- Posts
- 43
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.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks