Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Mixand on Wed 13/05/2009 23:27:32

Title: GlobalScript.asc(-10): Runtime error: Function still open, missing }
Post by: Mixand on Wed 13/05/2009 23:27:32
When I try saving or running my game it comes up with that error.
Can anybody help me please?

It seems like when I delete

function Dwarf_UseInv()
{
if(player.ActiveInventory==iLeaves){
Jason.Walk(236, 84, eBlock);
Dwarf.Say("&48 Uh.. I don't smoke.");
}

{
if(player.ActiveInventory==Fishstick){
Jason.Walk(236, 84, eBlock);
Dwarf.Say("&49 No thanks. I don't like sushi, It's bad for my stomach.");
}

It works again
Title: Re: GlobalScript.asc(-10): Runtime error: Function still open, missing }
Post by: Sephiroth on Wed 13/05/2009 23:35:34
Identing might help seeing your syntax errors, you just forgot some braces (said brackets) :


function Dwarf_UseInv()
{
  if(player.ActiveInventory==iLeaves)
  {
    Jason.Walk(236, 84, eBlock);
    Dwarf.Say("&48 Uh.. I don't smoke.");
  }
  else if(player.ActiveInventory==Fishstick)
  {
    Jason.Walk(236, 84, eBlock);
    Dwarf.Say("&49 No thanks. I don't like sushi, It's bad for my stomach.");
  }
}


I bet NsMn will have something to say to you ;)
Title: Re: GlobalScript.asc(-10): Runtime error: Function still open, missing }
Post by: Trent R on Wed 13/05/2009 23:38:31
Actually, he had an extra { above the second if statement, and was missing the one at the end (although it's probably in his script and forgot to c&p it over to the forum).

But Sephiroth is right, indenting and formatting your code 'correctly' (cause their's not one way to do it, but there are messy ways) will help make it easier to debug, and to share your code with others.


~Trent
Title: Re: GlobalScript.asc(-10): Runtime error: Function still open, missing }
Post by: Gilbert on Thu 14/05/2009 01:48:15
Also, use the match braces feature of the script editor.