So I have question about updating variables with click and making new text appear without having to do replace. So I have a decently sized game right now and many passages have multiple choices that lead to different outcomes and different text on the same passage. So far I have been doing this by using replace to make new text appear, but i was kinda hoping i could skip that and just have a click that updates a variable making an if statement true and showing the text under that if statement without having to leave the passage and come back. Or replacing.
Sorry if this is unreable i'm on an ipad right now. Also i'm writing in the newest version of sugarcube 2.
Comments
At my computer now and adding an example to try and clarify my problem.
And I'm not using the newest sugarcube 2, but 2.5.
This is part of my store system. It only shows items as buyable if you enter the store with enough money. Now when you buy something the money amount changes, but there is no immediate visual change if you can't afford the other items. I did a workaround with displaying a "You can't afford this text" When clicking on buy, but this requires extra clicks from the user.
I would like it to cut out this extra click and just update what items the player can afford when they buy something. I know I could put the entire passage into every replace, but this scales very badly with multiple items.
Several of your conditionals are redundant. For example: There's no need to check if $PlayerMoney is greater than or equal to 70 in the <<elseif>> conditional. You only get to that point if the <<if>> conditional has failed—meaning that you already know that $PlayerMoney is greater than or equal to 70, by virtue of it not being less than 70.
You seem to be using integers (0 and 1) as booleans. Use real booleans (false and true) instead. For example, instead of: Do something like the following: Or for the inverted case:
Oh. You also misspelled proceed as procede in the ankle knife purchase message.
Now, as to your question. You could set it up so that purchasing an item replays the passage via Engine.play(passage()). And for that to work correctly, you'll need another variable, only temporarily, so that you know to display the purchase message. For example: