Thread: Changing string cycler
-
July 30th, 2020, 23:28 #1
Changing string cycler
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).bmos' extensions
he/them
-
July 31st, 2020, 05:08 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,412
You can just use DB.setValue to set the data node pointed to by the cycler; and it will update to match.
JPG
-
July 31st, 2020, 11:14 #3bmos' extensions
he/them
-
July 31st, 2020, 12:19 #4
Tried it again.
Still doesn't seem to like the setValue command.
Code:Script Error: [string "campaign/scripts/abilitymod2_effects.lua"]:64: attempt to call field 'setValue' (a nil value)
Code:window.fortitudestat2.setValue('Cha')
Code:<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.updateEffectBonuses() end </script> </cycler_ability>
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 fortitudestat2Last edited by bmos; July 31st, 2020 at 12:57.
bmos' extensions
he/them
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks