Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Joseph DiPerla on Wed 14/09/2005 00:57:33

Title: error line(6): Variable '[' is already defined.
Post by: Joseph DiPerla on Wed 14/09/2005 00:57:33
This is the code: function room_a() {
  // script for Room: First time player enters screen
Character[cHomer].Think("What am I going to do?");
 
}

And the topic is the error I get. Sounds newbieish. What am I doing wrong?
Title: Re: error line(6): Variable '[' is already defined.
Post by: Joseph DiPerla on Wed 14/09/2005 01:00:37
You know what... I just figured out. I feel like an idiot. The script language changed and I have to the new scripting, which makes the script into : cHomer.Think. Sorry. You could delete.
Title: Re: error line(6): Variable '[' is already defined.
Post by: monkey0506 on Wed 14/09/2005 02:17:34
You don't have to use cHomer.Think... you could do Character[cHomer.ID].Think if you really wanted to. :=
Title: Re: error line(6): Variable '[' is already defined.
Post by: strazer on Wed 14/09/2005 17:03:15
Actually, I think it would be character[cHomer.ID] or character[HOMER]. But of course the cHomer shortcut is much nicer.
Title: Re: error line(6): Variable '[' is already defined.
Post by: Joseph DiPerla on Thu 15/09/2005 03:35:09
Actually Monkey, I tried those, and thats what also gave me this error for some reason.
Title: Re: error line(6): Variable '[' is already defined.
Post by: Gilbert on Thu 15/09/2005 03:57:00
Use cHomer as recommended by many then, it should work.
Title: Re: error line(6): Variable '[' is already defined.
Post by: Ishmael on Thu 15/09/2005 11:14:43
Which AGS version are you using?
Title: Re: error line(6): Variable '[' is already defined.
Post by: monkey0506 on Thu 15/09/2005 22:06:02
Quote from: Joseph DiPerla on Thu 15/09/2005 03:35:09
Actually Monkey, I tried those, and thats what also gave me this error for some reason.

Well that's because I accidentally used a 'C' instead of a 'c', as strazer pointed out.  "Character" should be used when defining a pointer, i.e., Character *chara = Character.GetAtScreenXY(mouse.x, mouse.y).  "character" is the globally defined array of all the characters in the game.
Title: Re: error line(6): Variable '[' is already defined.
Post by: Joseph DiPerla on Sat 17/09/2005 01:28:07
I was using AGS 2.71 beta 4. I got it working now. Like I said, I dropped the Character[cHomer].Think to cHomer. Think and it worked.