-
May 22nd, 2016, 05:07 #1
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.
-
May 22nd, 2016, 05:18 #2
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!
-
May 22nd, 2016, 05:31 #3
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
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
-
May 22nd, 2016, 19:25 #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
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.
-
May 22nd, 2016, 19:42 #5
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.
-
May 22nd, 2016, 20:01 #6
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
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.
-
May 22nd, 2016, 21:01 #7
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
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
-
May 22nd, 2016, 22:21 #8
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.
-
May 24th, 2016, 01:10 #9
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.
-
May 24th, 2016, 02:27 #10
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