Thread: Manipulating Sources..
-
April 27th, 2020, 15:59 #1
Manipulating Sources..
So I'm working on this problem where a primary number value can be reduced by a source value, but only if the primary value remains greater than a given number.
I tried setting up an onValueChanged() function in the primary value to check if it goes under the number and it works but when I do a setValue() on the source to remove it, it fails to updated the primary value, leaving the primary value adjusted. I'm guessing that I'm doing the wrong call to make that happen and thus avoiding the source adjusting code.
Code:function onValueChanged() local nodeWeapon = getDatabaseNode().getChild("...."); if getValue() < 50 then DB.setValue(nodeWeapon, source[3]["name"][1], "number", 0); end 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.
-
April 27th, 2020, 18:03 #2
Why don't you just add <min>50</min> to the number control?
-
April 27th, 2020, 18:06 #3
Also, if the control is a numberfield (i.e. linked to a node in the database) then you probably want to be setting the value on the control, not directly on the node? Maybe? Or does that set up an infinite recursion through onValueChanged?
I still think you're better off just setting the min and max values you allow in the control, unless I misunderstand what the logic needs to be.Last edited by darrenan; April 27th, 2020 at 18:10.
-
April 27th, 2020, 19:12 #4
Is that min value going to work if the control is being changed by a source?
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.
-
April 27th, 2020, 19:47 #5---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
April 27th, 2020, 19:52 #6
Sure.. it is the info for the sources for that control... it inherits number_linked from CoreRPG... source is a variable in that template.
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.
-
April 27th, 2020, 19:59 #7
If you're certain that is correct... What is the "primary" value you are talking about and what is the Source you are changing.
If they are the same, have you tried and use the "minimum" setting mentioned above?
Sorry, the smallish clip of code is making it difficult for me to get a handle on what you're trying to do.---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
April 27th, 2020, 20:27 #8
If you don't work with the number_linked template then you probably won't have the answer I'm looking for here.
'number_linked' is the 'common' template that allows CoreRPG controls to talk to each other and share data behind the scenes.
You can set a <source> in a control and tell it how that source relates to your control, then that second value will be added or subtracted from your initial control. I was kinda hoping to talk with someone who worked with this template a good bit and was familiar with it's nuances.
In my situation.. the primary value is your 'skill', it could be a number between 0% and 200% or more, and the secondary value is based on how you want to split your skill up... assuming you can keep at least 50% in the primary skill... so I'm subtracting the 'source'.. which is the number you want to reduce your skill by in order to increase a 3rd number, your 'split' value. The check I'm working on is the one that prevents you from taking 151 from your skill of 200... 150 would be ok.. but 151 is right out. My plan is to bounce those entries entirely... which my code snip does.. kinda. What it doesn't do is undo what the number_linked code does... that is.. if you tell the primary value to reset itself... which honestly.. I assumed would happen when the source changed.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