Problem with moveto

Post » Wed Apr 13, 2011 5:08 am

Heyas

I have a spell setup to teleport me to a cell and then back, however once I teleport to the cell using the spell I can not leave!! If I cast the spell again to return, it ports me to the marker that I ported to in the cell when I first cast it. This doesn't make any sense to me at all, I'm sure I have it setup right. Perhaps someone could could a look?

scn XtMoveBegin ScriptEffectStartShort TeleportedIf Player.IsInCombat == 1	Message "You cannot teleport while in combat."	ReturnElseIf Player.IsSwimming	Message "You cannot teleport while swimming."	ReturnElseIf Player.GetInCell ICArena || Player.GetInWorldSpace CamoranParadise || Player.GetInWorldSpace DreamWorld || Player.GetInWorldSpace MS14World		Message "You cannot teleport in this location."	ReturnEndIfIf emcPlaylistExists "XtyfeMusic"  == 0	emcCreatePlaylist "XtyfeMusic" "Data\Music\Xtyfe\*.*"EndifEndBegin ScriptEffectFinishif Teleported == 0	set Teleported to 1 	emcChangePlaylist "0" "XtyfeMusic"	startquest XtMusicSaveQuest	XtSpotMarker.moveto Player 0,0,20	Player.moveto XtHomeMarkerElseIf Teleported == 1	set Teleported to 0	emcRestoreDefaultPlaylist "0"	stopquest XtMusicSaveQuest	Player.moveto XtSpotMarkerEndifEnd

User avatar
lillian luna
 
Posts: 3432
Joined: Thu Aug 31, 2006 9:43 pm

Post » Wed Apr 13, 2011 6:53 am

This is your problem:

if Teleported == 0	set Teleported to 1 	emcChangePlaylist "0" "XtyfeMusic"	startquest XtMusicSaveQuest	XtSpotMarker.moveto Player 0,0,20	Player.moveto XtHomeMarkerElseIf Teleported == 1	set Teleported to 0	emcRestoreDefaultPlaylist "0"	stopquest XtMusicSaveQuest	Player.moveto XtSpotMarkerEndif


The script effect script runs once per spell cast, it doesn't remember variables from a previous spell of the same type. That is why 'Teleported' will always be 0, no matter how often you cast the spell. You either need a global or quest variable to check for or a different condition that works. Like getincell maybe (don't know what you're trying to do exactly).
User avatar
Robert Jackson
 
Posts: 3385
Joined: Tue Nov 20, 2007 12:39 am

Post » Wed Apr 13, 2011 3:46 am

Ya I figured it was something simple like that, I know it works without a global on objects and stuff so I assumed it was this way for spell effect. But you learn something new everyday

Thanks :)
User avatar
KRistina Karlsson
 
Posts: 3383
Joined: Tue Jun 20, 2006 9:22 pm

Post » Wed Apr 13, 2011 9:53 am

Probably the easiest solution would be to check to see if you're in the cell you're teleporting to; if not, run the "teleport there" part of the script, otherwise run the "teleport back" part. No need for messy variables that way. :D
User avatar
Mylizards Dot com
 
Posts: 3379
Joined: Fri May 04, 2007 1:59 pm

Post » Wed Apr 13, 2011 2:15 pm

Indeed that would be more efficient. Not being able to solve such a simple problem is exactly why I would never be good at programming, I'm just not creative enough.
User avatar
Makenna Nomad
 
Posts: 3391
Joined: Tue Aug 29, 2006 10:05 pm


Return to IV - Oblivion