Problem with compiling script in v2.7 [SOLVED]

Started by leone, Tue 03/05/2005 14:57:23

Previous topic - Next topic

leone

Hi,

I loaded my game in AGS v2.7, but when I tried to test it I got a message:
Ã,  'There was an error compiling your script.
Ã,  Ã, Variable 'Direction' is already defined'

The variable in question is in 'repeatedly_execute' section of the Global script:

int CharId, Direction, dx, dy;

It is the part of the script that deals with keyboard control, which I copied from Hollister Man's script I found in the 'Controlling movement with keyboard' thread.

Since I just copied it, I don't know how it really works. I checked the rest of my script and didn't find any other place where variable 'Direction' is defined.
Mister No is coming

Rui 'Trovatore' Pires

Try defining it in the beginning of the Golbal Script instead of in repeatedly_execute.

Failing that, rename it. I'm not too sure, but AGS now reserves some keywords, or something. Maybe this is such one...? Then again, I'm not totally sure, not even 10% sure...
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Wretched

I had same problem with a variable I had called Region, 2.7 has some new reserved variable names. You can just rename Direction to Direction2 and all occurances in your script. Ã, 

strazer

That's right, "Direction" is the name of a built-in enum:

  enum Direction {
    eForwards = 1062,
    eBackwards = 1063
  }

"Direction2" would also work, but it is recommended that you write local variables (declared within a function) in lowercase letters.
So just change all occurrences of "Direction" to "direction".

Kinoko

I had that exact problem but luckily I'd read up on it a bit beforehand so I knew what it was. I also had to change things like 'gui' in my script. I typically just put an 'a' on the end of them (don't know why, it just sticks in my head). Oh, and 'static', which was the variable name for a magic spell in my game. I was a bit surprised at that one, but it's understandable I guess.

strazer

I renamed any such variables from object to objectid, for example, since they do contain the ID of the entity, not a pointer to it.

Here are all names reserved by built-in enum definitions:

bool
TransitionStyle
MouseButton
RoundDirection
RepeatStyle
Alignment
LocationType
CutsceneSkipType
DialogOptionState
eSpeechStyle
eVoiceMode
eCDAudioFunction
FileMode
EventType
BlockingStyle
Direction
WalkWhere

In retrospect, maybe they should have been named AGS_Direction and so on to reduce the probability of them being used as variable names by the user.

leone

Thanks guys, my problem is of course solved.
By the way, v2.7 looks great :)
Mister No is coming

SMF spam blocked by CleanTalk