Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: manny.p on Wed 15/06/2005 12:42:25

Title: AGS 2.7_gui is a global var; cannot use name for local_MI2 Template!!!
Post by: manny.p on Wed 15/06/2005 12:42:25
I am using the MI2 template in ags v 2.7 and i already get and error when i haven't changed anything.

The error: (line 221) "gui" is a global var; cannot use name for local

function GetLucasSavegameListBox(int gui,int object){  // line 221


My guess here as a n00b, is that in ags 2.7 they've made gui a built in variable or something, so you can't have the same name as it.

But i'm not sure how to correct this, plus that means the MI2 Template is incompatible with the new ags until you edit the script.

Any help would be great. :)
Title: Re: AGS 2.7_gui is a global var; cannot use name for local_MI2 Template!!!
Post by: strazer on Wed 15/06/2005 14:07:41
I've just noticed you posted the same in the main tech forum. No crossposting please!

I have deleted your message and my reply. Here it is again:

Correct. As stated in the AGS v2.7 upgrading guide (http://www.adventuregamestudio.co.uk/manual/UpgradingTo27.htm):

Quote
Is there anything else I should watch out for?

Because of the new additions, the script language has more reserved words than before. For example, words like "gui", "object" and "hotspot" are now reserved (since they are used to access the global arrays). If your script uses any variables with these names, it will no longer work. You'll need to change the variable name in order to compile.

So you'll have to rename the affected variables everywhere in the script, for example:


function SomeFunction(int gui, int hotspot) {
  Display("GUI is ", gui);
  GuiOff(gui);
  int a = hotspot + 3;
}


becomes for example


function SomeFunction(int gui_id, int hotspot_id) {
  Display("GUI is ", gui_id);
  GuiOff(gui_id);
  int a = hotspot_id + 3;
}
Title: Re: AGS 2.7_gui is a global var; cannot use name for local_MI2 Template!!!
Post by: manny.p on Wed 15/06/2005 15:03:05
I'm not quite sure how i do this.

function GetLucasSavegameListBox(int gui,int object){  // line 221

i'm guessing i change "gui" to "gui_7", because thats what the savegamelistbox is under the gui editor.

but what do i change "object" to?
Title: Re: AGS 2.7_gui is a global var; cannot use name for local_MI2 Template!!!
Post by: strazer on Wed 15/06/2005 15:10:33
It doesn't matter what you call the variable. You can rename "object" to "flubby" if you like, you just have to replace every occurance of "object" in the GetLucasSavegameListBox function with the same word. I would use "object_id", for example.
Title: Re: AGS 2.7_gui is a global var; cannot use name for local_MI2 Template!!!
Post by: manny.p on Wed 15/06/2005 15:39:28
Ahhh i understand now.

In the new ags you can have "object_1" "object_2" and so on in that certain function.

or just call them the names like "banana" or "pillow" but they are only used in that function, well thnx for the help!