View Full Version : What am I doing wrong?
Visvalor
July 29th, 2013, 02:17
How do I access the unspent skill points in skillpoints.unspent so that it reduces the number by 1 each time this widget is clicked? I can get this to raise the skill ranks in the skill page, I just haven't been quite able to get it to reduce the unspent points in the window above it.
I'm pretty sure I'll need to change the window.getchild thing to something else.
Also do any of you have a recommendation on how to get the widget to check for in-class skill vs out of class skills? That way it'll charge 2 instead of 1.
<script>
function onInit()
labelwidget = addTextWidget("sheetlabelsmall", "Raise Skill");
labelwidget.setPosition("center", 0, 1);
end
function onClickDown(button, x, y)
placeranks = window.getDatabaseNode().getChild("ranks");
unspentskillpoints = window.getDatabaseNode().getChild("skillpoints.unspent");
if unspentskillpoints.getValue() > 0 then
placeranks.setValue(placeranks.getValue()+1);
unspentskillpoints.setValue(unspentskillpoints.get Value()-1);
end
end
</script>
Visvalor
July 29th, 2013, 04:13
How do I call the variable unspentskillpoints or "skillpoints.unspent" from the skill point window under the skills? getChild doesn't work because it's on a different window technically.
unspentskillpoints = window.getDatabaseNode().getChild("skillpoints.unspent");
Dakadin
July 29th, 2013, 08:53
You will need to use .getValue() on the end of the getChild function if you want the value contained in the database node. If that doesn't work here are a few other things to consider.
When I encounter those situations I use the Debug functions to help me find where in the database I am. Try adding this right before that line:
Debug.chat(window.getDatabaseNode());
It should show you which database node you are dealing with. Then open the FG Application Data folder and go to the campaigns folder. Find the campaign folder you are running and open it up. Then open the db.xml file. Look for the node it is referring to. The look where the skillpoints unspent section is. Verify you have the right spell and that it exists. If you have the spelling right then, check if it is up or down a level or 2. You can use getParent() on a database node to move up a level. Use getchild("NodeName") where NodeName is the name of the node to move down a level.
Visvalor
July 29th, 2013, 20:12
I don't really know how it all works but I'm trying to access a windowclass on the same sheet as the skill list in the 3.5 ruleset. Further down in the XML there is this, and this is what I'm trying to access.
<frame_char name="skillpointframe">
<bounds>15,430,800,80</bounds>
</frame_char>
<gennum name="gennumtest" source="gennumtest">
<anchored>
<to>skillpointframe</to>
<position>insidetopleft</position>
<offset>100,20</offset>
</anchored>
</gennum>
<basicnumber_sm name="unspentskillpoints" source="skillpoints.unspent">
<anchored>
<to>skillpointframe</to>
<position>insidetopleft</position>
<offset>60,15</offset>
<size>
<height>20</height>
<width>35</width>
</size>
</anchored>
<nodrag />
<min>0</min>
</basicnumber_sm>
<label_sm>
<anchored>
<to>skillpointframe</to>
<position>insidetopleft</position>
<offset>13,15</offset>
<size>
<height>21</height>
<width>45</width>
</size>
</anchored>
<static>Available points</static>
<multilinespacing>10</multilinespacing>
</label_sm>
<number name="spentskillpoints" source="skillpoints.spent">
<anchored>
<to>skillpointframe</to>
<position>insidetopright</position>
<offset>10,15</offset>
<size>
<height>20</height>
<width>35</width>
</size>
</anchored>
<frame>
<name>modifier</name>
<offset>3,3,3,3</offset>
</frame>
<font>sheetnumbersmall</font>
<readonly />
<nodrag />
</number>
<label_sm>
<anchored>
<to>skillpointframe</to>
<position>insidetopright</position>
<offset>50,15</offset>
<size>
<height>21</height>
<width>45</width>
</size>
</anchored>
<static>Points Spent</static>
<multilinespacing>10</multilinespacing>
</label_sm>
</sheetdata>
</windowclass>
</root>
Dakadin
July 30th, 2013, 03:48
Try using this:
function onClickDown(button, x, y)
placeranks = window.getDatabaseNode().getChild("ranks");
window.unspentskillpoints.setValue(window.getDatab aseNode().getChild("skillpoints.unspent").getValue());
if unspentskillpoints.getValue() > 0 then
placeranks.setValue(placeranks.getValue()+1);
window.unspentskillpoints.setValue(window.unspents killpoints.getValue()-1);
end
end
Visvalor
July 30th, 2013, 03:58
Here is my entire entry into charskills.xml that is being engaged. Above is what is trying to be called. When I made the changes you suggested here is the error message I got.
Script Error: [string "charsheet_skilllistitem:rankraiser"]:1: attempt to index field 'unspentskillpoints' (a nil value)
<genericcontrol name="rankraiser">
<bounds>-161,5,120,20</bounds>
<frame>
<name>bonus</name>
<offset>2,2,2,2</offset>
</frame>
<script>
function onInit()
labelwidget = addTextWidget("sheetlabelsmall", "Raise Skill");
labelwidget.setPosition("center", 0, 1);
end
function onClickDown(button, x, y)
placeranks = window.getDatabaseNode().getChild("ranks");
skillpts = window.unspentskillpoints.setValue(window.getDatab aseNode().getChild("skillpoints.unspent").getValue());
if skillpts.getValue() > 0 then
placeranks.setValue(placeranks.getValue()+1);
skillpts.setValue(skillpts.getValue()-1);
end
end
</script>
</genericcontrol>
Visvalor
July 30th, 2013, 03:59
Also tried copy pasting your script, it had the same error message.
Dakadin
July 30th, 2013, 04:30
Let's try it with a bit of debugging, error checking and using the database nodes instead. Try replacing your onClickDown function with this one:
function onClickDown(button, x, y)
placeranks = window.getDatabaseNode().getChild("ranks");
local unspentNode = window.getDatabaseNode().getChild("skillpoints.unspent");
Debug.chat(unspentNode);
if unspentNode then
unspentskillpoints = unspentNode.getValue();
Debug.chat(unspentskillpoints);
if unspentskillpoints > 0 then
placeranks.setValue(placeranks.getValue() + 1);
unspentNode.setValue(unspentskillpoints - 1);
Debug.chat(unspentNode.getValue());
end
end
end
Visvalor
July 30th, 2013, 11:54
nil
Visvalor
July 30th, 2013, 17:06
Went and double checked to make sure I had a number in the number field, still reads nil either way. Do you want me to send the xml?
Trenloe
July 30th, 2013, 17:42
I think you need to look at exactly what database node is being returned by local unspentNode = window.getDatabaseNode()
Split this out into a new variable and use debug commands to see what this database node actually is - use the databasenode getName function: https://www.fantasygrounds.com/refdoc/databasenode.xcp#getName
Dakadin
July 30th, 2013, 18:22
Visvalor, I sent you a private message so we can see about getting this resolved for you.
Trenloe, I agree that is likely the case.
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.