DICE PACKS BUNDLE
  1. #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).

  2. #2
    You can just use DB.setValue to set the data node pointed to by the cycler; and it will update to match.

    JPG

  3. #3
    Quote Originally Posted by Moon Wizard View Post
    You can just use DB.setValue to set the data node pointed to by the cycler; and it will update to match.

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

  4. #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)
    The line it's complaining about is:
    Code:
    window.fortitudestat2.setValue('Cha')
    and the stringcycler is:
    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>
    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
    Last edited by bmos; July 31st, 2020 at 12:57.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in