Miserere
August 6th, 2008, 06:04
I am making a new character sheet for a custom ruleset. In front of each skill I want a little checkbox icon that will be checked if the skill is related to the character's profession, or unchecked if it is not (the default). I have figured out how to make a toggling checkbox that switches back and forth between checked and unchecked, but at the moment this is not recorded in the database and so all skills are unchecked when you reopen the character sheet. I thought I had the right code to make this persistent, but apparently I am missing something. Can someone help? Thanks in advance.
Here is the relevant code for the checkbox object in the XML:
<genericcontrol>
<icon>indicator_checkoff</icon>
<script file="scripts/charsheet_skillstate.lua" />
</genericcontrol>
Here is the Lua script referenced in the object:
function toggle()
if (onOff == 1) then
onOff = 0;
setIcon("indicator_checkoff");
else
onOff = 1;
setIcon("indicator_checkon");
end
end
function onClickDown(button, x, y)
toggle();
end
function onInit()
-- Set selection
onOff = window.getDatabaseNode().createChild("switch", "number");
if (onOff == 1) then
setIcon("indicator_checkon");
end
end
Here is the relevant code for the checkbox object in the XML:
<genericcontrol>
<icon>indicator_checkoff</icon>
<script file="scripts/charsheet_skillstate.lua" />
</genericcontrol>
Here is the Lua script referenced in the object:
function toggle()
if (onOff == 1) then
onOff = 0;
setIcon("indicator_checkoff");
else
onOff = 1;
setIcon("indicator_checkon");
end
end
function onClickDown(button, x, y)
toggle();
end
function onInit()
-- Set selection
onOff = window.getDatabaseNode().createChild("switch", "number");
if (onOff == 1) then
setIcon("indicator_checkon");
end
end