The above code results in this, which is pretty amazing, because stat2 is not declared normally, which means, theoretically, that a *temp can be declared in the middle of code:
This isn’t new, it’s only *create that has restricted declarations. As Szaal points out if that condition failed you’d get an error (so it’s highly inadvisable).
As mentioned before, if that pass doesn’t check, you’d get an error, and this would be the case if stat1 /= 5.
In practical use, you’d probably want to declare the *temp before the *if check, and use the *if check to alter the variable.
(In Startup)
*create luck 0
(In any text)
You have 3 coins. You decide to look for more.
*temp coins 3
*rand luck 1 5
*if luck = 1
You found a coin in your pocket, lucky you.
*set coins + 1
*goto x
*elseif luck = 2
You are lucky today! You found 5 coins!
*set coins + 5
*goto x
*else
You dig around but find no coins.
*goto x
*label x
You have ${coins} coins.
In any use, if the ‘${variable}’ doesn’t have a variable to check, such as when it’s created only under specific conditions, you’ll get an error.
also don’t forget temp only creates it for that scene so you’d have keep having a *temp in each scene you wanted it in. So if you wanted it to be more than scene *create would be better.