5E Product Walkthrough Playlist
Page 1 of 2 12 Last
  1. #1
    Blackfoot's Avatar
    Join Date
    Oct 2010
    Location
    New Jersey, USA
    Posts
    4,202
    Blog Entries
    4

    Changing Default Values in a script.

    Is it possible to change the default value for a numbercontrol using a script? I don't see a function for it on the wiki.
    Full License Operator - You must have a 'Lite' License to play in my games.
    Member and GM in the Fantasy Grounds Pathfinder Society Group.
    PFS Fantasy Grounds Forum
    FG Community Teamspeak Server: ts.fg-con.com
    Interested in Custom Character Portraits and Tokens? Contact me.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    In the onInit function for the control use setValue()?
    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!

  3. #3
    The problem is that the default value is used before the onInit function is called, which only happens after all controls are instantiated.

    To set default values dynamically, you would have to use a numbercontrol, check for existence of node, set to default if node does not exist, link to the node's value change event to update number control.

    Regards,
    JPG

  4. #4
    Blackfoot's Avatar
    Join Date
    Oct 2010
    Location
    New Jersey, USA
    Posts
    4,202
    Blog Entries
    4
    The situation I am trying to handle actually happens after the control exists.
    Clearing the damage field on the combat tracker (rather than setting it) returns that field to it's default value... I want to set that default to equal a specific number but that specific number can be different for every character.. and is based on one of the character's stats.
    I'm looking at trying something like this:
    Code:
    					function update()
    						local node = window.getDatabaseNode();
    						DB.setValue(node, "default", window.stun.getValue());
    						window.onHealthChanged();
    					end
    Where I want to set the default temporary of nonlethal to the permanent value of stun.
    Full License Operator - You must have a 'Lite' License to play in my games.
    Member and GM in the Fantasy Grounds Pathfinder Society Group.
    PFS Fantasy Grounds Forum
    FG Community Teamspeak Server: ts.fg-con.com
    Interested in Custom Character Portraits and Tokens? Contact me.

  5. #5
    Blackfoot's Avatar
    Join Date
    Oct 2010
    Location
    New Jersey, USA
    Posts
    4,202
    Blog Entries
    4
    So.. that doesn't work.
    <default>20</default>
    sets the default value to 20 for that control in the xml... but you I'm having trouble altering the default value once it is set using a script.
    I'm trying to follow Moon Wizard's comment but it sorta sounds like he's talking about something not quite the same as what I'm trying to do.
    Ultimately, I want to do something like:
    <default>nStunVal</default>
    Where nStunVal = window.stun.getValue();
    Obviously I'm going about this wrong... but I can't seem to find the way to get at it.
    Full License Operator - You must have a 'Lite' License to play in my games.
    Member and GM in the Fantasy Grounds Pathfinder Society Group.
    PFS Fantasy Grounds Forum
    FG Community Teamspeak Server: ts.fg-con.com
    Interested in Custom Character Portraits and Tokens? Contact me.

  6. #6
    Blackfoot's Avatar
    Join Date
    Oct 2010
    Location
    New Jersey, USA
    Posts
    4,202
    Blog Entries
    4
    Hrm. This 'kinda' worked... except now it the value can't be changed at all:
    Code:
    					function update()
    						local nStunVal = window.stun.getValue();
    						Debug.chat(nStunVal);
    						setValue("default", nStunVal);
    						Debug.chat(getValue("default") .. "!");
    						window.onHealthChanged();
    					end
    It seems to be setting the value of nonlethal to the value of stun... instead of just setting the default for nonlethal. Hrm.
    Full License Operator - You must have a 'Lite' License to play in my games.
    Member and GM in the Fantasy Grounds Pathfinder Society Group.
    PFS Fantasy Grounds Forum
    FG Community Teamspeak Server: ts.fg-con.com
    Interested in Custom Character Portraits and Tokens? Contact me.

  7. #7
    Yeah, I was responding to a different default scenario.

    How are you "clearing" the field?

    Can you trigger off whatever event is triggering the clearing of the field to set the value specifically?

    JPG

  8. #8
    Blackfoot's Avatar
    Join Date
    Oct 2010
    Location
    New Jersey, USA
    Posts
    4,202
    Blog Entries
    4
    Backspace or delete clears it. It is actually pretty cool.. if I can get it to work with the correct default value.
    Full License Operator - You must have a 'Lite' License to play in my games.
    Member and GM in the Fantasy Grounds Pathfinder Society Group.
    PFS Fantasy Grounds Forum
    FG Community Teamspeak Server: ts.fg-con.com
    Interested in Custom Character Portraits and Tokens? Contact me.

  9. #9
    Blackfoot's Avatar
    Join Date
    Oct 2010
    Location
    New Jersey, USA
    Posts
    4,202
    Blog Entries
    4
    Quote Originally Posted by Moon Wizard View Post
    How are you "clearing" the field?

    Can you trigger off whatever event is triggering the clearing of the field to set the value specifically?

    JPG
    I can't seem to locate what triggers the number edit function .. onValueChanged() seems to be called AFTER the default has already been found.
    I am working with the template <number_ct_crosslink> from CoreRPG.. which seems to tie back through a few things.. but doesn't seem to have any specific code for editing. So I'm guessing that it's more deeply rooted than that.
    Full License Operator - You must have a 'Lite' License to play in my games.
    Member and GM in the Fantasy Grounds Pathfinder Society Group.
    PFS Fantasy Grounds Forum
    FG Community Teamspeak Server: ts.fg-con.com
    Interested in Custom Character Portraits and Tokens? Contact me.

  10. #10
    Blackfoot's Avatar
    Join Date
    Oct 2010
    Location
    New Jersey, USA
    Posts
    4,202
    Blog Entries
    4
    What if I come at this from another tack... is there a way to set the default to a variable rather than an actual number? Seems like the xml code is a lot more limited than the lua so I'm thinking no... which may be the issue with this whole concept. Currently I'm setting the defaults to 10 body and 20 stun (standard for a 'normal' person) but I should know the actual values of these 95% of the time before they are actually added to the combat tracker.. the problem is that I don't know how to set them on the fly rather than in the code.
    Currently I do:
    <default>10</default>
    and I can't really see any other way to do that.
    I'd like to do:
    <default>nBodyVal</default>
    Full License Operator - You must have a 'Lite' License to play in my games.
    Member and GM in the Fantasy Grounds Pathfinder Society Group.
    PFS Fantasy Grounds Forum
    FG Community Teamspeak Server: ts.fg-con.com
    Interested in Custom Character Portraits and Tokens? Contact me.

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