PDA

View Full Version : Changing string cycler



bmos
July 30th, 2020, 23:28
Is there a way to change a string cycler from a script? Or just a way to change the default so that it changes if it hasn't been manually set yet?
I see that there are functions exposed on it, but I get errors when I try to use them (unless I call the onInit as well which duplicates the contents).

Moon Wizard
July 31st, 2020, 05:08
You can just use DB.setValue to set the data node pointed to by the cycler; and it will update to match.

JPG

bmos
July 31st, 2020, 11:14
You can just use DB.setValue to set the data node pointed to by the cycler; and it will update to match.

JPGI tried that, but must have had something wrong. Thanks!

bmos
July 31st, 2020, 12:19
Tried it again.
Still doesn't seem to like the setValue command.

Script Error: [string "campaign/scripts/abilitymod2_effects.lua"]:64: attempt to call field 'setValue' (a nil value)

The line it's complaining about is:

window.fortitudestat2.setValue('Cha')
and the stringcycler is:

<cycler_ability name="fortitudestat2">
<anchored to="fortitudebase" position="aboveright" offset="-112,-20" height="20" width="32" />
<baseability>-</baseability>
<fieldabilitymod>fortitudestatmod2</fieldabilitymod>
<source><name>saves.fortitude.ability2</name></source>
<parameters><defaultlabelres>-</defaultlabelres></parameters>
<script>
function onValueChanged()
if window.isInitialized() then
local sValue = getStringValue();
if sValue == "" and baseability then
sValue = baseability[1];
end

local sCharRelative = "";
if abilityrelative then
sCharRelative = abilityrelative[1];
end

if fieldabilitymod and window[fieldabilitymod[1]] then
window[fieldabilitymod[1]].updateAbility(sCharRelative, sValue);
end
end

window.fortitudestatmod2effects.updateEffectBonuse s()
end
</script>
</cycler_ability>


Oh, I think I see what you're saying.
I just have to set it via the database instead of changing the value of the UI element directly.

EDIT: doing that worked :) I suppose that is because I was able to use the setValue of DB instead of trying to use a special setValue of fortitudestat2