Jump to content

Recommended Posts

Posted (edited)

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
Posted

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

Posted (edited)

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
Posted

I still think it's really strange that you get an EOF error at all... Maybe there's some funny extra character in there that's not being displayed by your text editor? If you write it out again from scratch, does the same thing happen?

 

Cipscis

Posted
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.
Posted
I'm not sure if that has something to do with the problem but you miss the .GetPlayer () when you give him the spell, which should be : Game.GetPlayer().AddSpell(InsertSpellName)
  • 1 year later...
Posted

Rename your script. For me on this same error the engine didn't like my script name. Sometimes when pasting out of notepad it may add an ; or there is a ; missing... that happened once or twice too, but different error.

Posted

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.

  • Recently Browsing   0 members

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