Creating a local int/bool etc. SOLVED

Started by Mr Games, Wed 19/12/2018 19:34:41

Previous topic - Next topic

Mr Games

Sorry this is a super-beginner question,

Every time I've created a new variable I've made it a Global Variable, because I was thinking that if I created an int or bool at the top a room script, it would return to that value every time that room is entered.

For example, if I stated at the top of a room:
Code: ags
PineapplePizzaIsTasty = true;
and an event in that same room caused that value to become false, but I left the room and came back, would it not read the original statement and make it true again?

I'm just trying to get my head around how this works.

Khris

The rooms 1-300 save their state, including script variables. So as long as you put bool at the start of that line, it'll work fine.

Only variables local to functions lose their value, as soon as the function ends.

Mr Games

OK, thanks :) I'm familiar with the room saving the state but I wasn't sure if it would "re-read" code outside of the functions and thus return the variable to its original value.

SMF spam blocked by CleanTalk