juffatoot Posted December 4, 2017 Share Posted December 4, 2017 (edited) Hi,I'm trying to create a spell that is dependent on the player's location: Scriptname ChangeRealmEffectScript extends activemagiceffect ObjectReference property WintTeleDest auto ObjectReference property ArtTeleDest auto Event OnEffectFinish(Actor Target, Actor Caster) Target.GetCurrentLocation() if (Target.IsInLocation(TamrielLocation)) Target.MoveTo(WintTeleDest) else Target.MoveTo(ArtTeleDest) endif endEvent After compiling, the only problem is that it says TamrielLocation (or any other location, for that matter) is not a defined variable. Does anyone know why this is and what I should do to fix it?Thank you :smile: Edited December 4, 2017 by juffatoot Link to comment Share on other sites More sharing options...
Evangela Posted December 4, 2017 Share Posted December 4, 2017 (edited) Scriptname ChangeRealmEffectScript extends activemagiceffect Location property TamrielLocation auto ObjectReference property WintTeleDest auto ObjectReference property ArtTeleDest auto Event OnEffectFinnish(Actor Target, Actor Caster) Location CurrentLoc = Target.GetCurrentLocation() If CurrentLoc != none If CurrentLoc.isChild(TamrielLocation) || CurrentLoc == TamrielLocation Target.MoveTo(WintTeleDest) Else Target.MoveTo(ArtTeleDest) Endif Else return Endif EndEventI think I eliminated two function calls(IsInLocation and the extra GetCurrentLocation it'll call for the assignment) and because GetCurrentLocation() expects a location to have a location, if you don't explicitly check for this, it'll return none and post a error to the log if the Cell does not have a location. I added a check to prevent such an error. Many wilderness cells do not have a location. *Not tested. Edited December 4, 2017 by Rasikko Link to comment Share on other sites More sharing options...
foamyesque Posted December 4, 2017 Share Posted December 4, 2017 Hi,I'm trying to create a spell that is dependent on the player's location: Scriptname ChangeRealmEffectScript extends activemagiceffect ObjectReference property WintTeleDest auto ObjectReference property ArtTeleDest auto Event OnEffectFinish(Actor Target, Actor Caster) Target.GetCurrentLocation() if (Target.IsInLocation(TamrielLocation)) Target.MoveTo(WintTeleDest) else Target.MoveTo(ArtTeleDest) endif endEvent After compiling, the only problem is that it says TamrielLocation (or any other location, for that matter) is not a defined variable. Does anyone know why this is and what I should do to fix it?Thank you :smile: It's because you didn't define it. You can't simply type a form's name into the papyrus compiler and have it understand what you mean to do. Information like that is passed in through the properties system, which hooks Papyrus variables with the game forms. You can see how to use them in Rasikko's script, but after you compile it you'll need to go to the 'properties' button beside the script window and fill them. Link to comment Share on other sites More sharing options...
Recommended Posts