Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Artilleryman37 on Fri 11/02/2011 02:42:29

Title: parse error help
Post by: Artilleryman37 on Fri 11/02/2011 02:42:29
hi, i'm currently working on a halo side scroller and i'm having trouble with a parse error. If you could explain why i'm getting this error or a different method to achieve my goal i would be greatfull.

Code:

function repeatedly_execute()
{
  if (cShield => 101) fixshield();
  if (cHealth => 101) fixhealth();
}

Error:

GlobalScript.asc(11): Error (line 11): Parse error in expr near 'cShield'


cShield is a global variable and if it goes over 100 i want the function fixshield to run.

same problem applies to cHealth but any answer should fix both.
Thanks
Title: Re: parse error help
Post by: Gilbert on Fri 11/02/2011 02:44:11
Use 'if (blah >= 101)' or 'if (blah > 100)', not 'if (blah => 101)'.
Title: Re: parse error help
Post by: Artilleryman37 on Fri 11/02/2011 02:59:27
lol thankyou very much
Title: Re: parse error help
Post by: Artilleryman37 on Fri 11/02/2011 04:40:49
hi all,
im having another error could someone pls help.

Code:

// new module script
function pistolshot() {
 
  object[1].SetPosition(cCharacter.x + 35, cCharacter.y + 58;
  object[1].Move(object[1].X + Room[1].Width, object[1].Y, 10, eNoBlock, eAnywhere);
 
}

error:

pistol.asc(-10): Runtime error: unexpected eof

code to use function(in global script:

function on_key_press(eKeyCode keycode)
{
  if (IsGamePaused()) keycode = 0; // game paused, so don't react to keypresses

  if (keycode == eKeyF) pistolshot();
 
}
Title: Re: parse error help
Post by: Artilleryman37 on Fri 11/02/2011 04:43:23
fixed
Title: Re: parse error help
Post by: Gilbert on Fri 11/02/2011 05:13:04
Don't double post in a short time. You can just edit the last post for it. Also, when you manage to fix a problem, it would be a good idea to write how you fix your problems. This would be helpful to other people in case they encounter similar problems. I suppose it's the missing close ) in the 'object[1].SetPosition(cCharacter.x + 35, cCharacter.y + 58;' line, right?

Just a helpful hint, you can use the 'match-brace' feature of the script editor (press Ctrl-B when the cursor is next to an open/close bracket) to help you fix these kinds of problems.