Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Mr Games on Wed 19/12/2018 19:34:41

Title: Creating a local int/bool etc. SOLVED
Post by: Mr Games on Wed 19/12/2018 19:34:41
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) Select
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.
Title: Re: Creating a local int/bool etc.
Post by: Khris on Wed 19/12/2018 20:07:47
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.
Title: Re: Creating a local int/bool etc.
Post by: Mr Games on Wed 19/12/2018 21:05:20
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.