Is there any way to get a certain command, for example
<<if $gold gt 200>><<set $gold = 200>><</if>>
to run on all pages. So that the player cannot have more than 200 gold on them at any one time.
The alternative is to copy and paste this at the bottom of every single page and I really don't want to that.
If this isn't possible is there a way to set a maximum value so that $gold cannot exceed 200?
Comments
PassageReady
PassageDone
PassageFooter
Create a new passage with one of these names and put the <<if>> macro to run each turn in it.
Please read the SugarCube manual if unsure what these passages are.
http://www.motoslave.net/sugarcube/2/docs/special-names.html
You can also use StoryCaption though it's probably not the right place for this.
Again thanks.
Alternatively, you could simply clamp $gold whenever you modify it by using something like Math.clamp() (SugarCube v1 or v2 doc). For example:
As to the special passages, they are all executed at different times. If you've only looked at the Twinery wiki, then I'd suggest looking at SugarCube's own documentation on the special passages as well (v1 or v2).
In my game I use both PassageDone and PassageReady for different functions.
PassageDone I use for things that I want happening after the passages so as to avoid an animation traffic jam (so the game sorts out the passage transitions first, then PassageDone triggers the full screen background changes, which helps avoid stutter from trying to do too many things at once).
PassageReady I use for the <<stopsound>> macro, so that if there are any ongoing sounds from previous passage, it stops them before starting new sounds in the incoming passage.
That sounds really useful if I ever put audio into any of my games.
I spent quite a few hours reading the documentation and have tried math.clamp and I assume I was just doing it wrong but it didn't really work for what I was using it for. I've since looked up the other passages and how they work. I Still appreciate you trying to help.