Blacky
December 14th, 2014, 22:31
By way of an extension, I would like to change one script that's inside a XML file of the ruleset. I tried targeting directly the script, appending it, target the script as nested inside the proper XML tags, all by way of an additional <includefile /> in my extension, nothing works. Google tells me I've looked everywhere on the wiki and the modguide of the site, to no avail.
Here's the full relevant code from the ruleset:
<windowclass name="char_consequence">
<margins control="0,0,0,2"/>
<sheetdata>
<genericcontrol name="leftanchor">
<anchored height="15" width="0">
<top/>
<left/>
</anchored>
</genericcontrol>
<stringfield name="label">
<anchored to="leftanchor" position="right" offset="0,2" height="15" width="65"/>
<font>sheetlabelmini</font>
<stateframe>
<hover>
<name>sheetfocus</name>
<offset>6,7,7,5</offset>
</hover>
</stateframe>
<static />
<script>
function setState(value)
if value and value ~= "" then
setValue(value);
else
setValue("MILD");
end
end
function cycleState()
local cyclemap = { ["MILD"] = "MODERATE", ["MODERATE"] = "SEVERE", ["SEVERE"] = "EXTREME", ["EXTREME"] = "MILD" };
local statenow = getValue() or "MILD";
setState(cyclemap[statenow]);
end
function onClickDown(button, x, y)
cycleState();
end
function onValueChanged()
local curValue = getValue();
if curValue == "MILD" then window.stress.setValue(-2) end
if curValue == "MODERATE" then window.stress.setValue(-4) end
if curValue == "SEVERE" then window.stress.setValue(-6) end
if curValue == "EXTREME" then window.stress.setValue(-8) end
if curValue == "EXTREME" then window.aspect.setValue("REPLACE PERMANENT") end
end
</script>
</stringfield>
<numberfield name="stress">
<anchored to="label" position="right" offset="0,0" width="20" height="12"/>
<frame>
<name>modifier</name>
<offset>5,5,5,5</offset>
</frame>
<font>sheetlabelmini</font>
<hideonvalue>0</hideonvalue>
<readonly/>
<script>
function onDrag(button, x, y, draginfo)
local label = window.aspect.getValue() .. " [" .. window.label.getValue() .. "]";
draginfo.setType("number");
draginfo.setDescription(label);
draginfo.setNumberData(getValue());
return true;
end
</script>
</numberfield>
<stresstrackitem name="used">
<anchored to="stress" position= "right" offset="10,0" />
</stresstrackitem>
<string_textlistitem name="aspect">
<anchored to="used" position="right" offset="8,0" height="15" width="150"/>
<script>
function onDoubleClick(x,y)
FateChat.aspectMessage(getValue());
return true;
end
</script>
</string_textlistitem>
<genericcontrol name="rightanchor">
<anchored height="0" width="0">
<top/>
<right/>
</anchored>
</genericcontrol>
<button_idelete name="idelete">
<anchored>
<top/>
<right parent="rightanchor" anchor="left" relation="relative" offset="-5"/>
</anchored>
</button_idelete>
</sheetdata>
</windowclass>
I wanted to change the first script, the one targeted by:
<windowclass name="char_consequence">
<sheetdata>
<stringfield name="label">
<script>
Without touching anything else, for maintenance purposes. Any way to do that?
Here's the full relevant code from the ruleset:
<windowclass name="char_consequence">
<margins control="0,0,0,2"/>
<sheetdata>
<genericcontrol name="leftanchor">
<anchored height="15" width="0">
<top/>
<left/>
</anchored>
</genericcontrol>
<stringfield name="label">
<anchored to="leftanchor" position="right" offset="0,2" height="15" width="65"/>
<font>sheetlabelmini</font>
<stateframe>
<hover>
<name>sheetfocus</name>
<offset>6,7,7,5</offset>
</hover>
</stateframe>
<static />
<script>
function setState(value)
if value and value ~= "" then
setValue(value);
else
setValue("MILD");
end
end
function cycleState()
local cyclemap = { ["MILD"] = "MODERATE", ["MODERATE"] = "SEVERE", ["SEVERE"] = "EXTREME", ["EXTREME"] = "MILD" };
local statenow = getValue() or "MILD";
setState(cyclemap[statenow]);
end
function onClickDown(button, x, y)
cycleState();
end
function onValueChanged()
local curValue = getValue();
if curValue == "MILD" then window.stress.setValue(-2) end
if curValue == "MODERATE" then window.stress.setValue(-4) end
if curValue == "SEVERE" then window.stress.setValue(-6) end
if curValue == "EXTREME" then window.stress.setValue(-8) end
if curValue == "EXTREME" then window.aspect.setValue("REPLACE PERMANENT") end
end
</script>
</stringfield>
<numberfield name="stress">
<anchored to="label" position="right" offset="0,0" width="20" height="12"/>
<frame>
<name>modifier</name>
<offset>5,5,5,5</offset>
</frame>
<font>sheetlabelmini</font>
<hideonvalue>0</hideonvalue>
<readonly/>
<script>
function onDrag(button, x, y, draginfo)
local label = window.aspect.getValue() .. " [" .. window.label.getValue() .. "]";
draginfo.setType("number");
draginfo.setDescription(label);
draginfo.setNumberData(getValue());
return true;
end
</script>
</numberfield>
<stresstrackitem name="used">
<anchored to="stress" position= "right" offset="10,0" />
</stresstrackitem>
<string_textlistitem name="aspect">
<anchored to="used" position="right" offset="8,0" height="15" width="150"/>
<script>
function onDoubleClick(x,y)
FateChat.aspectMessage(getValue());
return true;
end
</script>
</string_textlistitem>
<genericcontrol name="rightanchor">
<anchored height="0" width="0">
<top/>
<right/>
</anchored>
</genericcontrol>
<button_idelete name="idelete">
<anchored>
<top/>
<right parent="rightanchor" anchor="left" relation="relative" offset="-5"/>
</anchored>
</button_idelete>
</sheetdata>
</windowclass>
I wanted to change the first script, the one targeted by:
<windowclass name="char_consequence">
<sheetdata>
<stringfield name="label">
<script>
Without touching anything else, for maintenance purposes. Any way to do that?