DICE PACKS BUNDLE
  1. #1

    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.

  2. #2
    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.

  3. #3
    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.

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,470
    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!

  5. #5
    Thanks, that should be exactly what I need. I'll give it a look sometime soon.

  6. #6
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,709
    Blog Entries
    1
    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!

  7. #7
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Starfinder Playlist

Log in

Log in