Jump to content

TeleportationTrouble


alonsomartinez

Recommended Posts

So im trying to make an amulet that teleports you directely into a cell

 

i have the whole move to marker and everything down but

 

when i get in the cell it glitches and i cant move im running but not moving.

 

i took off the amulet but im still stuck

 

did i do something wrong ? help

Link to comment
Share on other sites

Indeed...posting the script would allow us to help you better.

My best guess is that you didn't us a variable in a block for a 'doonce' kind of action and it is constantly teleporting the player to the marker, making you unable to move.

Link to comment
Share on other sites

The OP PMed me the script he attached to the object. For reference here it is:

 

scn teleport

begin onequip player 
player.moveto mymarker
end 

 

It may or may not work but adding a doonce variable is worth a try (I thought onequip blocks only ran on the frame the object was actually equipped - please correct me if I'm wrong). To add a doonce it would look like this:

 

scn teleport

Short DoOnce

begin onequip player

If (DoOnce == 0)
    player.moveto mymarker
EndIf

end 

Link to comment
Share on other sites

It is a run-once begin block so it shouldn't matter indeed...

MoveTo's cancel the block immediately (return) so it could not work at all.

MoveTo is a difficult function to work with and has a lot of unpredicted results:

Moving the player with MoveTo within an OnEquip or OnAdd block causes an infinite loop: the Player is MoveTo'd every frame thereafter.

 

It seems that instead of "acting as a return" the MoveTo function crashes the script AFTER moving the player or, somehow, prevents the script from complete successfully. The game engine seems to notice that the block did not complete successfully and tries to run it again the next frame. The Player will be moved again. The script will crash again, etc, etc. Final result: the player is moved to the same spot every frame - cannot move from there. This crash effect may be related to the fact that the scripted object is moved with the player as it does not occur in an OnDrop block or if the object is added to an NPC/container (in both cases, the object stays behind and is not moved with the player)

 

Workarounds: (1) add controls to prevent the MoveTo function from running two frames in a row or (2) Move the Moveto function to another block or another script.

...try to tackle it with this:

scn teleport

Short DoOnce

begin onequip player
If (DoOnce == 0)
set DoOnce to 1
message "Teleporting", 5
if DoOnce == 0
	player.moveto mymarker
endif
EndIf

Trying to get rid of the 0 at all could help too, as the return/cancel do a LOT of unexpected things:

scn teleport

Short DoOnce
Short DoEnd

begin onequip player
If (DoOnce == 0)
set DoOnce to 1
set DoEnd to 1
EndIf

Begin Gamemode
if DoEnd == 1
	set DoEnd to 2
	set DoOnce to 2
	if DoOnce == 1
		player.moveto mymarker
	endif
endif
endif

Link to comment
Share on other sites

That script would make a one-time use teleportation amulet wouldn't it?

 

Would this work for a reusable amulet?

 

scn teleport

Short DoOnce
Short DoEnd

begin onequip player
If (DoOnce == 0)
set DoOnce to 1
set DoEnd to 1
EndIf

Begin Gamemode
if DoEnd == 1
	set DoEnd to 2
	set DoOnce to 2
	if DoOnce == 1
		player.moveto mymarker
	endif
endif
endif

Begin OnUnequip
Set DoOnce to 0
Set DoEnd to 0
End

Link to comment
Share on other sites

That script would make a one-time use teleportation amulet wouldn't it?

 

Would this work for a reusable amulet?

 

scn teleport

Short DoOnce
Short DoEnd

begin onequip player
If (DoOnce == 0)
set DoOnce to 1
EndIf

Begin Gamemode

if (DoOnce == 1)
    set DoOnce to 0
    player.moveto mymarker
endif

 

That would work. It's also not hard to make an amulet that would teleport you back to where you were when you put it on once you took it off. I'm not gunna write the code but I think the command you'd need is getplayercell, save that function to a raf variable and in the unequip block set doonce to 2 which will run a script just like the one above except it will use the stored reference cell to teleport to.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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