Cool! Thanks!
Printable View
Cool! Thanks!
Thank you for the tip.
I dug a little bit more so I can explain the challenge a bit better.
I'm used to using onValueChanged() in my scripts. But I can't find a proper way to find the path to each "strength_bonus" to use with onValueChanged().
The trouble here is that the value of strength bonus is in each line of the list.
I think that the path (for my setup) would be
nodeWin.getChild("weaponlist").getChild("id-0000X").getChild("strength_bonus")();
Now, each line of the list has an id, which I need to go through.
I.E. I have three weapons in the list, that means I have to go through id-00001, id-00002 and id-00003 and find the "strength_bonus" in each and update that.
You will need to use a
for loop
You will do something like
for k, v in pairs
You will need to post more code so we can try and suggest the right syntax to use
Okey, I will try to post what I've found
Does this make any sense? It certainly doesn't work.Code:function sbonus()
local nodeWin = window.getDatabaseNode();
local nS = nodeWin.getChild("totS").getValue();
local nSB = math.floor(nS/10)
local test = nodeWin.getChild("weaponlist");
for _,v in pairs(test.getChildren()) do
v.strength_bonus.setValue(nSB);
end
end
I think the path is nodeWin.weaponlist.id-0000X.strength_bonus.
where x = the listnumber in the weaponlist.
I km not near my computer but first start with debug statements
Debug.chat(nodeWin)
Debug.chat(nS)
Debug.chat(test)
Debug.chat(v)
Assuming test is valid then this should work:
Code:for k,v in pairs (test.getChildren())
v.getChild("strength_bonus").setValue(nSB));
end
Haha! That worked perfectly! Thank you very much damned!
One step closer :D
Continued here:
https://www.fantasygrounds.com/forum...munity-Ruleset
I ended up just buying Foundry.... They have an official ruleset that works well. I'd much rather play in FG but I don't think there is any interest in making an official ruleset.