PDA

View Full Version : Trouble calling getDice()



Chandley
July 17th, 2008, 22:58
So, FourUglyMonsters registration is borked, or I would ask JPG over there. Im poking at the 4ed ruleset he put together, trying to add a check box that lets you set which weapon your powers default to.

Theres a list of weapons under a Combat tab, with a field like this: (Ive unrolled templates to make this easier to follow)


<diefield name="damagedice">
<noreset />
<script>
function onDoubleClick(x,y)
ChatManager.DoubleClickDieControl(getDice(), window.damagestatlabel.getTotalModifier() + window.damagebonus.getValue(), window.name.getValue() .. " (Damage)", {pc = window.getDatabaseNode().getParent().getParent()}) ;
return true;
end

function onDrag(button, x, y, draginfo)
draginfo.setType("dice");
draginfo.setDieList(getDice());
draginfo.setNumberData(window.damagestatlabel.getT otalModifier() + window.damagebonus.getValue());
draginfo.setDescription(window.name.getValue() .. " (Damage)");
draginfo.setShortcutData("charsheet", window.getDatabaseNode().getParent().getParent().g etNodeName());

return true;
end
</script>
<anchored>
<to>damageframe</to>
<position>insideleft</position>
<size>
<width>70</width>
</size>
</anchored>
</diefield>


Ive added a little check box field in the same sheetdata and windowclass, and Im looking to use the "onValueChanged" function of checkbox to push the damage dice stored in the above field over to another sheet.

However, when I do this:


local me = window.getDatabaseNode().getChild("damagedice").getDice();
print (me[1]);

I get an error:

Script Error: [string "charsheet_weaponlistitem:weaponinhand"]:1: attempt to call field 'getDice' (a nil value)

If I call "getType()" off of that damagedice node, it returns "dice". FG _thinks_ thats a dice object, but I cant seem to actually get the dice out of it. Calling getDice() from inside the <script> for damagedice works fine. Is there some kind of bizzare scoping that Im just to new at FG modding to know about going on here?

Any help is appreciated.

Chandley

Foen
July 18th, 2008, 06:16
There isn't a getDice() method for a database node, you have to use getValue.

If you want to access the dicefield control instead of the underlying bound database node, use window.damagedice instead of window.getDatabaseNode().getChild("damagedice").

Hope that helps

Stuart

Chandley
July 18th, 2008, 13:38
Thanks Foen, thats done it. Now I have to pound into my head the difference between the database nodes and the controls.

:)

Chandley