HYDRAK23 Posted March 27, 2021 Share Posted March 27, 2021 Hi I recently watch a tutorial and create a magic effect that allow you to teleport to a location, now I would like to use the spell for go back to where I was... but is my first time trying to write script, I m a bit lost. ------------------------------------------------------------Original Working Script------------------ ObjectReference Property Loc01 Auto Event OnEffectStart(Actor akTarget, Actor akCaster)Utility.Wait(1.5)Game.FadeOutGame(False, True, 2.0, 1.0)Game.GetPlayer().MoveTo(Loc01)Game.EnableFastTravel()Game.FastTravel(Loc01)EndEvent ------------------------------------------------------------My New Script-----------------------------ObjectReference Property Loc01 AutoObjectReference Loc02 = Game.GetPlayer().GetParentCell() aaTPcast=0 if aaTPcast=0Event OnEffectStart(Actor akTarget, Actor akCaster)Utility.Wait(1.5)Game.FadeOutGame(False, True, 2.0, 1.0)Game.GetPlayer().MoveTo(Loc01)Game.EnableFastTravel()Game.FastTravel(Loc01)EndEventaaTPcast=1endif if aaTPcast=1Event OnEffectStart(Actor akTarget, Actor akCaster)Utility.Wait(1.5)Game.FadeOutGame(False, True, 2.0, 1.0)Game.GetPlayer().MoveTo(Loc02)Game.EnableFastTravel()Game.FastTravel(Loc02)EndEventaaTPcast=0endif ---------------------------------------------------------------------------------------------------------------- Thank you for your time Link to comment Share on other sites More sharing options...
dylbill Posted March 27, 2021 Share Posted March 27, 2021 A few things, you only need 1 event, and you need to put the if conditions inside the event. Also I would place a marker to get your previous location. You also need to define what aaTPcast is. Like so: ObjectReference Property Loc01 Auto Static Property XMarker Auto ObjectReference Loc02 Int aaTPcast = 0 Event OnEffectStart(Actor akTarget, Actor akCaster) if aaTPcast == 0 Utility.Wait(1.5) If Loc02 == None ;if the marker doesn't exist yet Loc02 = Game.GetPlayer().PlaceAtMe(XMarker, 1) ;place new marker at player Else Loc02.MoveTo(Game.GetPlayer()) ;move marker to player Endif Game.FadeOutGame(False, True, 2.0, 1.0) Game.GetPlayer().MoveTo(Loc01) Game.EnableFastTravel() Game.FastTravel(Loc01) aaTPcast = 1 Elseif aaTPcast == 1 Game.FadeOutGame(False, True, 2.0, 1.0) Game.GetPlayer().MoveTo(Loc02) Game.EnableFastTravel() Game.FastTravel(Loc02) aaTPcast = 0 Endif EndEvent Link to comment Share on other sites More sharing options...
dylbill Posted March 27, 2021 Share Posted March 27, 2021 Sorry I realized that won't work, because it's a magic affect each time you cast aaTPcast will always be 0 because it creates a new active magic effect when you cast, so you need to save that value somewhere else. The easiest I think would be to make it a GlobalVariable. In the creation kit, you can make those under Miscellaneous / Global. ObjectReference Property Loc01 Auto Static Property XMarker Auto ObjectReference Loc02 GlobalVariable Property aaTPcast Auto Event OnEffectStart(Actor akTarget, Actor akCaster) if aaTPcast.GetValue() == 0 Utility.Wait(1.5) If Loc02 == None Loc02 = Game.GetPlayer().PlaceAtMe(XMarker, 1) ;place new marker at player Else Loc02.MoveTo(Game.GetPlayer()) ;move marker to player Endif Game.FadeOutGame(False, True, 2.0, 1.0) Game.GetPlayer().MoveTo(Loc01) Game.EnableFastTravel() Game.FastTravel(Loc01) aaTPcast.SetValue(1) Elseif aaTPcast.GetValue() == 1 Game.FadeOutGame(False, True, 2.0, 1.0) Game.GetPlayer().MoveTo(Loc02) Game.EnableFastTravel() Game.FastTravel(Loc02) aaTPcast.SetValue(0) Endif EndEvent Link to comment Share on other sites More sharing options...
dylbill Posted March 27, 2021 Share Posted March 27, 2021 Sorry one more thing. I just realized you can't store the loc2 marker in the script that way for the same reason, it re-initializes every time you cast the spell. Instead just place an xmarker in your cell in the creation kit and use that in the script: ObjectReference Property Loc01 Auto ObjectReference Property Loc02 Auto GlobalVariable Property aaTPcast Auto Event OnEffectStart(Actor akTarget, Actor akCaster) if aaTPcast.GetValue() == 0 Utility.Wait(1.5) Loc02.MoveTo(Game.GetPlayer()) ;move marker to player Game.FadeOutGame(False, True, 2.0, 1.0) Game.GetPlayer().MoveTo(Loc01) Game.EnableFastTravel() Game.FastTravel(Loc01) aaTPcast.SetValue(1) Elseif aaTPcast.GetValue() == 1 Game.FadeOutGame(False, True, 2.0, 1.0) Game.GetPlayer().MoveTo(Loc02) Game.EnableFastTravel() Game.FastTravel(Loc02) aaTPcast.SetValue(0) Endif EndEvent Link to comment Share on other sites More sharing options...
HYDRAK23 Posted March 28, 2021 Author Share Posted March 28, 2021 Hi Thank You for both answeras , they help me to understund this language and teach me a lot!! Also save me propably weeks of searching, and for the script !Make sense now !I add the GlobalVarible ;) I was ignore you can do this as well.. I m sure the script is correct now but I still Teleport to the Loc01.The problem now is the Loc2 "marker" , I don t know if I have to create it, placed in the world or in a cell... Really Thank you dylBill Link to comment Share on other sites More sharing options...
dylbill Posted March 28, 2021 Share Posted March 28, 2021 You should place an xmarker static in an interior cell. Then when filling the property in the ck. Choose the cell and the xmarker reference. Link to comment Share on other sites More sharing options...
HYDRAK23 Posted March 28, 2021 Author Share Posted March 28, 2021 Ok it finally work!! Thank you so much for everything! For the Knowledge you pass me and basiclly your working script :) I was using a 2' Mapmarker estead of a Xmarker ( that also I was ignore what it was) and I forgette in the script property to set the value as the variable aaTPcast.... so nooob Now the Spell worw how intend, 1' cast go in the specific cell, 2' cast go back where you was.. work for interior and exterior cell too... Magically Link to comment Share on other sites More sharing options...
HYDRAK23 Posted March 28, 2021 Author Share Posted March 28, 2021 You should place an xmarker static in an interior cell. Then when filling the property in the ck. Choose the cell and the xmarker reference. lol I just read it know :) Link to comment Share on other sites More sharing options...
dylbill Posted March 28, 2021 Share Posted March 28, 2021 No problem. Glad you got it working :) Link to comment Share on other sites More sharing options...
NellSpeed Posted April 13, 2021 Share Posted April 13, 2021 Just checking in-- is this mod going to be released? It's exactly what I've been looking for! Link to comment Share on other sites More sharing options...
Recommended Posts