Rock5's version of teleport
Posted: Tue Jul 19, 2011 11:44 am
Seeing as Jduartedj hasn't been online for awhile, I thought I'd start my own thread for my fixed version of his "teleport" userfunction. This version has even more improvements and features than previous versions I've uploaded in other threads.
teleport
-- NEW FUNCTION ADDED--
teleportToWP
teleport
- Description:
- This function allows you to teleport your character over short distances. The maximum distance you can teleport is 120 but this function will try to make shorter hops if the coordinates you give it are too far. If there are obstacles in the way it may fail to teleport.
- teleport(x, z, y, absolute)
or
teleport(x, z, absolute)
for backward compatibility.
- If absolute is "false" then the x, z, y values are how much it will move by. eg. if x = 20 then it will move 20 to the east.
If absolute is "true" or nil then the x, z, y values are the absolute coordinates it will move to. eg. if x = 4400 then it will move to 4400 on the x axis.
x, z and y are optional but at least one must be specified. If one is omitted then it will not move on that axis.
User settings:Code: Select all
teleport(4400) -- move to 4400 on the 'x' axis. teleport(nil,3300) -- move to 3300 on the 'z' axis. teleport(4400,3300) -- move to 4400, 3300 on the x, z axis. teleport(50, -50, false) -- move 50 east and 50 south. teleport(nil, nil, 100, false) -- move 100 straight up.
- The maximum distance, I've found, that the character can teleport in one go is 120, but this function will try to make shorter hops if the coordinates given are too far. The function uses a maximum step size of 115, to add a little bit of a buffer. Between multiple hops, it will pause for 500 milliseconds for the new location to register. Both these values can be changed by the user with the following functions.
- teleport_SetStepSize(val)
teleport_SetStepPause(val)
-- NEW FUNCTION ADDED--
teleportToWP
- Description:
- This function will teleport directly to a waypoint. It accepts either the waypoint index number or the waypoints 'tag' if it has one. If the argument is ommitted it teleports to the next waypoint. Also, you don't need to run "__WPL:setWaypointIndex" as the function does it for you.
- teleportToWP(index)
- If index is a number, it will teleport to that waypoint index number.
If index is a string it will teleport to the waypoint with that "tag" name.
If index is ommitted then it will teleport to the next waypoint.
Code: Select all
teleportToWP() -- Will teleport to next waypoint teleportToWP(3) -- Will teleport to waypoint 3 teleportToWP("repair") -- Will teleport to the waypoint with tag="repair"