GlobalScript.asc(-10): Runtime error: Function still open, missing }

Started by Mixand, Wed 13/05/2009 23:27:32

Previous topic - Next topic

Mixand

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

Sephiroth

Identing might help seeing your syntax errors, you just forgot some braces (said brackets) :

Code: ags

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 ;)

Trent R

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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Gilbert


SMF spam blocked by CleanTalk