Once again, I'm having problems with scripting. In my GlobalScript, I have the code...
int game_var;
export game_var;
In my Global Script Header, I have the following code...
import int game_var;
In my Room2 RoomScript, I typed in the following code....
int game_var = 7;
and I get the following error message.....
Failed to save room room2.crm; details below
room2.asc(1): Error (line 1): Variable 'game_var' is already imported
If I remove "int" from the last entry and just type in....
game_var = 7;
then I get the following error message.....
Failed to save room room2.crm; details below
room2.asc(1): Error (line 1): Parse error: unexpected 'game_var'
I haven't been able to find any help in the docs, online or in the FAQ's. Can anyone tell me how to change a variable in room? Does this have to be in a function? And if so, does all coding have to occur in a function? Thanks!
This is exactly same problem as the previous case (https://www.adventuregamestudio.co.uk/forums/index.php?topic=58028.msg636620040#msg636620040): changing variable value is a command, and you can only do commands inside a function. Determine at which event do you want this happen and make corresponding function for that event. Inside the function you can then write "game_var = 7;"
Quote from: cliffwhite on Sun 17/05/2020 03:24:31And if so, does all coding have to occur in a function? Thanks!
Like CW says, all
commands have to be inside functions. Declarations don't need to be. (These are the things like creating a variable and giving it a starting value, describing new data types like structs and enums, and all the import/export lines.) Nor do macros, which are lines that start with #.
Hey guys! Thanks so much!!!