Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Wonkyth on Thu 22/05/2008 00:48:48

Title: Room scripts and variables
Post by: Wonkyth on Thu 22/05/2008 00:48:48
Just so that I have this all sorted out.
I don't seem to be able to use variables in room scripts, is that because you just cant do that, or am I just doing something wrong?
if you cant, then is the only way I can get variables in a function that is in a roomscript by making another variable in the global script, and then make a function of the same name?

thanks for any help in advance.
Title: Re: Room scripts and variables
Post by: Kaktus on Thu 22/05/2008 01:18:47
The variables have to be declared at the very top of the room script. The functions have to follow after that.


//room script file
int myInt;

function myFunction()
{
    // do something
}


Then they can be used anywhere in that room.
Title: Re: Room scripts and variables
Post by: TwinMoon on Thu 22/05/2008 01:43:36
Could you give some example of how you want to use variables? What doesn't work?

You can declare variables at any time btw, not just at the top of the script.
Title: Re: Room scripts and variables
Post by: Wonkyth on Fri 23/05/2008 14:09:12
What a dunce I am! :P
I had it all figured out, it's just that i forgot to put the semicolon after the "int exampleCounter" bit.
thanks all  the same. 8)