Jump to content

[LE] Please help me create a script


gbcsi88

Recommended Posts

Also make sure you run it inside an event or function. The compiler should also give you the line number for the fail. I think it says line 3, 5 or something like that. If the statement isn't inside an event or function and the rest of the script is correct, the script will fail instantly and give back EOF error.

 

Everything that does something inside a script, with only the exception of declaring variables, has to be inside either an event or a function. Events are code blocks that listen for particular things that the game does and are the entry point for manipulating it with scripts. The OnMagicEffectStart in the code snippet of this post is an example of an event. It will fire whenever the magic effect starts being applied to the target.

 

Functions are code blocks that can be reused without needing to re-write all the pieces of it. For example, RemoveItem() is an event.

 

If your objective is to use a player's gold to cast something instead of, or in addition to, their magicka, there may be a better approach. I need to do some testing.

Link to comment
Share on other sites

Try this. (I only added lines to your first script, check for typos)


Event OnEffectStart(actor Target, actor Caster)


RegisterForSingleUpdate(1.0)


EndEvent


Event OnUpdate()



IF Game.Getplayer().GetitemCount(gold001) <= 1


Game.Getplayer().Unequipspell(Myspell, 0)


Game.Getplayer().Unequipspell(Myspell, 1)


Debug.Notification("no Gold")



ElseIf Game.Getplayer()GetItemCount(Gold001) > 1


Game.Getplayer()RemoveItem(Gold001, 1)


RegisterForSingleUpdate(1.0)


ENDIF

ENDIF


endEvent


Event OnEffectFinish(Actor Target, Actor Caster)


UnregisterForUpdate()


EndEvent

Link to comment
Share on other sites

^ Yes. Should work after those corrections.

A few problems;
The HasMagicEffect event is not needed anymore.
Line 25 doesn't need the Elseif i don't think. Using "Else" instead and removing the contents of that line would do the same, but be more efficient. (my bad)
The way it is now, if we ignore the first event, the script will run for 1 second when you cast without checking for gold, which I guess doesn't work very well with what you are trying to do.


Link to comment
Share on other sites

  • Recently Browsing   0 members

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