Content Scripting Python Local Teleport
From RexWiki
Preface
This page shows how to create a script which can be used for local teleports.
To use this script:
- Make sure server is down
- Add the python class from below to "\rexserver\ScriptEngines\PythonScript\Samples" folder to a file named sampleteleportlocal.py
- Open "\rexserver\ScriptEngines\PythonScript\Samples\__init__.py" file and add sampleteleportlocal.py to the end of the list
- Start servers
- Create a prim and define "sampleteleportlocal.Teleport" for it's Class Name.
- Add to Rex tab-> Data the correct parameters (see below). Remember to press the Set button below the Data to set it.
- Stop editing the prim.
- Touch the primitive to teleport.
Note about the script implementation: The reason why avatar is forced to flying mode for a short time during the local teleport is so that the avatar won't start moving fast towards the previous position. This is a bug in the rex 0.4 which is avoided using the described workaround.
Rex data
The following text is a sample for Rex tab->Data.
112
135
27
Parameter descriptions line by line are as follows:
- Line 1: X coordinate
- Line 2: Y coordinate
- Line 3: Z coordinate
Python script
The following python script should be added to a file named sampleteleportlocal.py.
import rxactor
import rxavatar
import sys
import clr
asm = clr.LoadAssemblyByName('OpenSim.Region.ScriptEngine.Common')
Vector3 = asm.OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3
class Teleport(rxactor.Actor):
def GetScriptClassName():
return "sampleteleportlocal.Teleport"
def EventCreated(self):
super(self.__class__,self).EventCreated()
print "sampleteleportlocal.Teleport"
self.MyAvatars = []
self.SetValues()
def EventTouch(self,vAvatar):
self.SetValues()
self.MyAvatars.insert(0,vAvatar)
vAvatar.SetWalkDisabled(True)
vAvatar.DoLocalTeleport(self.TeleportDest)
self.SetTimer(0.2,False)
def EventTimer(self):
while len(self.MyAvatars) > 0:
TempAvatar = self.MyAvatars.pop(0)
TempAvatar.SetWalkDisabled(False)
def SetValues(self):
# Parse rex prim data separated by any white space character
myfreedata = self.rexGetPrimFreeData()
paramlistlines = myfreedata.splitlines()
self.TeleportDest = Vector3(float(paramlistlines[0]),float(paramlistlines[1]),float(paramlistlines[2]))
|