Hello! This is a key concept in programming, I think you are describing the
if statement.
The basic format is that:
Code:
if (expression is true)
{
//Code executes here
}
For example, if you wanted to test a variable called global.money and you wanted to remove $5 if the person has more than $5 you could write something like this.
Code:
if (global.money >= 5)
{
global.money -= 5;
}
else
{
show_message("You are broke. Sorry.");
}
That symbol >= is a comparison, and it means "more than or equal to". If you simply wanted to see if it was equal to, you would use the symbols ==.
See here for a list of expressions. You can also see I added "else" at the end, which is the code that runs when the expression in the if statement is untrue. In this case, the code is saying "if your money is more than 5, remove 5 from money, otherwise show a message saying they are broke".
If you want to test two variables at once, like money and food, you could do this:
Code:
if (global.money == 5 && global.food = 0)
{
//Code
}
This uses && to check that both are true. If money is not 5, or is food is not 0, then it will not run. This is covered under
"Combining" in the manual.
Understanding statements and expressions is basically a crucial minimum when you learn programming. Now is a great time to start reading up on it!