Reset Option



  • There are a few places in the XML browser where it talks about resetting options:
    "This option may be cleared/reset by triggers if you want by prefixing with '-reset-'."

    Does anyone have an example of this? I'm taking it as if I had the following condition:
    <attachment name="conditionAttachment_WaxOn" attachTo="Player1" javaClass="RulesAttachment" type="player">
    <option name="switch" value="true"/>
    </attachment>

    Then I could reset this back to false by listing another condition like this:
    <attachment name="conditionAttachment_WaxOff" attachTo="Player1" javaClass="RulesAttachment" type="player">
    <option name="-reset-conditionattachment_WaxOn"/>
    </attachment>

    Sorry if I am confusing anyone but I am scratching my head on this one...


  • Admin

    Can't answer your question, but I can point you to these examples that use a 'reset' option:

    • empire/map/games/Empire.xml
    • total_ancient_war/map/games/Total_Ancient_War.xml
    • a_song_of_ice_and_fire/map/games/A_Song_of_Ice_and_Fire.xml


  • Thanks for the examples @LaFayette. That doesn't quite work the way I thought but at least I can quit barking up the wrong tree!


  • Admin

    Just to be sure, it looks like there are a couple of variants, the second two example XMLs perhaps were slightly different. Afraid I can't say the usage of reset is super clear.


  • Moderators

    @Michael-Hoover There's actually no reason to use reset with boolean options (like the switch is), or any options accepting a single value, for this matter. Reset is for those items that would otherwise add the value or the values to any value or values already defined, if not cleared (by using reset).



  • Ok. What about booleans by the way - is there a way to toggle them in game between true and false? Seems like the trigger conditions only fire if true, so I was thinking I would have to have a couple of booleans. One to toggle the other if that makes sense? Or if I am way off please let me know!


  • Moderators

    @Michael-Hoover Not sure what you mean. You can have a user action changing a condition switch between a true and false state, or having a boolean (not hardcoded) property called by a condition called by a trigger (respectively, for toggling during the game or before loading it).


  • Banned

    *facepalm



  • @Cernel Huh...I was under the impression that you couldn't toggle game properties once the game starts, but if you can I'm pretty sure that would solve my issue. I'm half asleep so I'll revisit this in the morning. Thanks for all the help 👍


  • Moderators

    @Michael-Hoover You can (with some rare exceptions related to properties that set options). The most usual example is starting a game with Low Luck, then saving it, reloading it, disabling Low Luck and restarting it (thus playing it with regular dice, from that point on).



  • @Michael-Hoover as @Cernel stated "-reset-" is used to clear multiple values. You can use a "playerProperty" to change a "switch" value.

    You stated:

    <attachment name="conditionAttachment_WaxOn" attachTo="Player1" javaClass="RulesAttachment" type="player">
       <option name="switch" value="true"/>
    </attachment>
    

    Then you would need to create a condition for when to turn the switch to false:

    <attachment name="conditionAttachment_TurnWaxOff" attachTo="Player1" javaClass="RulesAttachment" type="player">
       <!-- Create the condition here -->
    </attachment>
    
    

    Then by checking the state of "conditionAttachment_TurnWaxOff" you could use this to then set "conditionAttachment_WaxOn" to "false":

    <attachment name="conditionAttachment_WaxOff" attachTo="Player1" javaClass="TriggerAttachment" type="player">
       <option name="conditions" value="conditionAttachment_TurnWaxOff"/>
       <option name="players" value="Player1"/>
       <option name="playerAttachmentName" value="RulesAttachment" count="conditionAttachment_WaxOn"/>
       <option name="playerProperty" value="switch" count="false"/>
    </attachment>
    

    To change "conditionAttachment_WaxOn" to false.

    Hope this helps.

    Cheers...


Log in to reply