Jump to content

Missing EOF at "if"


Snowraptor

Recommended Posts

I'm trying to create what should be a simple script to check if someone has a spell and if they do not then add it. Instead I get this error when I compile, (5,0): missing EOF at 'if'

 

Scriptname InsertSpellName extends ObjectReference  
{The}
Spell Property InsertSpellName Auto  

if (Game.GetPlayer.HasSpell(InsertSpellName) == 0)
 Game.AddSpell(InsertSpellName)
endIf

 

Not sure how I'm getting an end of file error on "if". I know there's more errors to this than just that, but no matter what is put after the property declaration I get the same EOF error.

Edited by Snowraptor
Link to comment
Share on other sites

You're missing parentheses after Game.GetPlayer:

Scriptname InsertSpellName extends ObjectReference  
{The}
Spell Property InsertSpellName Auto  

if (Game.GetPlayer().HasSpell(InsertSpellName) == false)
 Game.AddSpell(InsertSpellName)
endIf

Also, note that I've changed "== 0" to "== false". We have proper "bool" types now, so even though yours would work due to automatic casting, using "false" is more semantically correct.

 

Cipscis

Link to comment
Share on other sites

I still get the EOF error. I tried removing the if/else to see if it would work without them (I realize I need it to perform the check) and got this error instead; (5,4): no viable alternative at input '.'

 

Scriptname InsertSpellName extends ObjectReference  
{The}
Spell Property InsertSpellName Auto  

Game.GetPlayer().HasSpell(InsertSpellName) == false
Game.AddSpell(InsertSpellName)

 

Is there some other property I need to set up that I'm missing?

 

Removing Game.GetPlayer().HasSpell(Fireball) == false will give me the same error but with Game.AddSpell instead.

Edited by Snowraptor
Link to comment
Share on other sites

I had the same thought and I have three different scripts made each with the same error. I've just been using the default editor because this is 6 lines and I haven't set up Notepad++ with the papyrus compiler. Only experience I have with EOF (assuming that represents end of file) is when dealing with text documents so it is completely baffling how the compiler finds an EOF error at "if". I'll set up Notepad++ tomorrow, maybe the default editor just doesn't like me.
Link to comment
Share on other sites

  • 1 year later...

Old thread man, but the problem with this script is obvious.

 

You can't run statements outside of an event or function. Compiler was expecting and Event or Function. That's not to say this is was "EOF" means, because I don't know, but looking at the script the OP posted, this is the case.

 

Though, the OP could be hiding the rest of the code, I guess. Doesn't matter.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...