ThinkTank
January 12th, 2014, 22:53
Having a bit of a mental block here.
How would I go about referencing a function within a control (in charsheet_main) that is only defined inside another control (in charsheet_toplevel)?
The two in question being:
<string_labeled name="race">
<anchored>
<to>classframe</to>
<position>insidetopleft</position>
<offset>15,17</offset>
<size>
<width>70</width>
<height>20</height>
</size>
</anchored>
<label>Race</label>
<static></static>
<script>
function onValueChanged()
if DataCommon.racedata[getValue()]~=nil then
window.phy_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].phy);
window.spd_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].spd);
window.str_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].str);
window.agi_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].agi);
window.prw_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].prw);
window.poi_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].poi);
window.int_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].int);
window.arc_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].arc);
window.per_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].per);
end
recalcStatMax();
end
function recalcStatMax()
if DataCommon.racedata[getValue()]~=nil then
local level=window.getDatabaseNode().getChild("level").getValue();
window.phy_max.setValue( DataCommon.racedata[getValue()][level].phy);
window.spd_max.setValue( DataCommon.racedata[getValue()][level].spd);
window.str_max.setValue( DataCommon.racedata[getValue()][level].str);
window.agi_max.setValue( DataCommon.racedata[getValue()][level].agi);
window.prw_max.setValue( DataCommon.racedata[getValue()][level].prw);
window.poi_max.setValue( DataCommon.racedata[getValue()][level].poi);
window.int_max.setValue( DataCommon.racedata[getValue()][level].int);
window.arc_max.setValue( DataCommon.racedata[getValue()][level].arc);
window.per_max.setValue( DataCommon.racedata[getValue()][level].per);
end
end
</script>
and:
<!-- XP -->
<basicnumber name="XP">
<anchored>
<to>overviewframe</to>
<position>insidetopleft</position>
<offset>180,12</offset>
<size>
<width>32</width>
<height>20</height>
</size>
</anchored>
<script>
function onInit()
onValueChanged();
end
oldLevel="Heroic";
function setOldLevel(level)
oldLevel=level;
end
function onValueChanged()
local xptotal=getValue();
local levelstring="Heroic";
if xptotal >= 50 then levelstring="Veteran"; end
if xptotal >= 100 then levelstring="Epic"; end
window.level.setValue(levelstring);
end
</script>
</basicnumber>
<stringfield name="level">
<anchored>
<to>XP</to>
<position>right</position>
<offset>0,-3</offset>
<size><width>60</width></size>
</anchored>
<script>
function onValueChanged()
???
end
</script>
<font>sheetlabel</font>
<static>Heroic</static>
<center/>
</stringfield>
respectivly.
How would I go about referencing a function within a control (in charsheet_main) that is only defined inside another control (in charsheet_toplevel)?
The two in question being:
<string_labeled name="race">
<anchored>
<to>classframe</to>
<position>insidetopleft</position>
<offset>15,17</offset>
<size>
<width>70</width>
<height>20</height>
</size>
</anchored>
<label>Race</label>
<static></static>
<script>
function onValueChanged()
if DataCommon.racedata[getValue()]~=nil then
window.phy_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].phy);
window.spd_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].spd);
window.str_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].str);
window.agi_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].agi);
window.prw_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].prw);
window.poi_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].poi);
window.int_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].int);
window.arc_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].arc);
window.per_score.setValue(DataCommon.racedata[getValue()]["Starting Stats"].per);
end
recalcStatMax();
end
function recalcStatMax()
if DataCommon.racedata[getValue()]~=nil then
local level=window.getDatabaseNode().getChild("level").getValue();
window.phy_max.setValue( DataCommon.racedata[getValue()][level].phy);
window.spd_max.setValue( DataCommon.racedata[getValue()][level].spd);
window.str_max.setValue( DataCommon.racedata[getValue()][level].str);
window.agi_max.setValue( DataCommon.racedata[getValue()][level].agi);
window.prw_max.setValue( DataCommon.racedata[getValue()][level].prw);
window.poi_max.setValue( DataCommon.racedata[getValue()][level].poi);
window.int_max.setValue( DataCommon.racedata[getValue()][level].int);
window.arc_max.setValue( DataCommon.racedata[getValue()][level].arc);
window.per_max.setValue( DataCommon.racedata[getValue()][level].per);
end
end
</script>
and:
<!-- XP -->
<basicnumber name="XP">
<anchored>
<to>overviewframe</to>
<position>insidetopleft</position>
<offset>180,12</offset>
<size>
<width>32</width>
<height>20</height>
</size>
</anchored>
<script>
function onInit()
onValueChanged();
end
oldLevel="Heroic";
function setOldLevel(level)
oldLevel=level;
end
function onValueChanged()
local xptotal=getValue();
local levelstring="Heroic";
if xptotal >= 50 then levelstring="Veteran"; end
if xptotal >= 100 then levelstring="Epic"; end
window.level.setValue(levelstring);
end
</script>
</basicnumber>
<stringfield name="level">
<anchored>
<to>XP</to>
<position>right</position>
<offset>0,-3</offset>
<size><width>60</width></size>
</anchored>
<script>
function onValueChanged()
???
end
</script>
<font>sheetlabel</font>
<static>Heroic</static>
<center/>
</stringfield>
respectivly.