Teleportation Script

Post » Thu Nov 27, 2014 3:40 pm

Hi there,

I am trying to create a script that resets the player to the entrance of each new room, when he is detected by an enemy (i.e. when he enters combat).

Therefore I created three things in the first room:

- an XMarker (RoomMarker1) that serves as a teleport destination

- a trigger area that determines the XMarker that will serve as a target for the reset in a current room

- a script inside the player that listens to the combat-event

The Script in the player looks like this:

Scriptname ResetAfterDetection extends ObjectReferenceimport gameObjectReference Property PreviousPosition AutoEvent OnCombatStateChanged(Actor actorRef, int combatState)	If (actorRef == game.getplayer())		If (combatState == 1)			game.getplayer().MoveTo(PreviousPosition)		EndIf	EndIfEndEvent

The PreviousPosition is set up as a property so that it can be accessed by another script and if I understood correctly, MoveTo requires an ObjectReference as a target. The Idea ist to use a variable in the MoveTo expression to change the ObjectReference for each new room the player enters. Is this possible? The trigger area has the following script:

ScriptName SetPrevPosRoom1 extends objectReference{Default script that simply activates itself when player enters trigger}import gameimport debugResetAfterDetection property player auto{access other script}bool property doOnce = TRUE auto{Fire only once?  Default: TRUE};************************************auto State waiting	Event onTriggerEnter(objectReference triggerRef)		if(triggerRef == game.getPlayer())			if doOnce == TRUE				ResetAfterDetection.PreviousPosition = MarkerRoom1				gotoState("allDone")			endif		endif	endEventendState;************************************State allDone	;do nothingendState;************************************

However, I get the following errors concerning the highlighted change of the ObjectReference:

C:\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\SetPrevPosRoom1.psc(20,24): a property cannot be used directly on a type, it must be used on a variable
C:\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\SetPrevPosRoom1.psc(20,43): variable MarkerRoom1 is undefined
Is it even possible to create a variable for an ObjectReference or did I walk a completely wrong path?
Any helpf would be much appreciated!
User avatar
Jordyn Youngman
 
Posts: 3396
Joined: Thu Mar 01, 2007 7:54 am

Return to V - Skyrim