Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

(Sugarcube 2.0) Checking/setting a variable's current amount

This is probably a question with an obscenely simple answer, but I've been struggling with it all day, so here goes:

I have a variable, $goodness, that changes when certain setter links are clicked (it either increases or decreases). The problem is, I want to be able to check my variable's amount at any given time, without having to start over my game each time (at the start of the game, I've set the variable to 0). I've looked all over and can't find the answer: how do you simply set a variable without changing its state, and how do you view it?

Thanks in advance! And please go easy on me, I'm new to programming in general.

Comments

  • You use the <<set>> macro to assign a value to a variable:
    <<set $variable to 0>> /% Assigns the value of zero to the variable. %/
    <<set $variable to $variable>> /% Assigns the variables current value to the variable. %/
    
    You use the <<print>> macro or a naked variable to display the current value of a variable:
    The current value of variable is: <<print $variable>>
    The current value of variable is: $variable
    
    You use the <<if>> macro if you want to test the current value of a variable:
    <<if $variable is 0>>The variable equals zero<</if>>
    
Sign In or Register to comment.