If you want the platform to move when players step in use http://otland.net/f81/flying-platform-191207
Click on image to play animation
You step on a flying tile that makes you travel thru a path you draw on map editor.
Any item thrown on path or platform is erased
Config
Draw the travel path with invis tiles(id:460) in map, it can't be diagonal, it can be opened or closed.
A part of the path can't be less than 1 tile farther from another parallel part of the path
You ought to add nologout zone on entire path aswell to avoid stack overflow and player debug
In order to make a platform move:
Edit function doPlatform in globalevent at final part
>First position is original position of platform in map
>Second position is where the platform came from, so the platform will travel in a opposite way.
Graphic explanation:
Yellow: First position, position of platform
Blue: Second position, position of where the platform came from
White: Platform will travel in that direction
/data/movements/movements.xml
/data/movements/scripts/platform.lua
/data/globalevent/scripts/globalevents.xml
/data/globalevent/scripts/platform.lua
NOTE: THIS SCRIPT DISABLES THE USAGE OF FLY SYSTEMS AND WALKING ON INVISIBLE TILES!
Click on image to play animation
You step on a flying tile that makes you travel thru a path you draw on map editor.
Any item thrown on path or platform is erased
Config
local SPEED = 300 --fastest = 100, slowest = 1000
local PLATFORM = 412 --itemid of platform
Draw the travel path with invis tiles(id:460) in map, it can't be diagonal, it can be opened or closed.
A part of the path can't be less than 1 tile farther from another parallel part of the path
You ought to add nologout zone on entire path aswell to avoid stack overflow and player debug
In order to make a platform move:
Edit function doPlatform in globalevent at final part
>First position is original position of platform in map
>Second position is where the platform came from, so the platform will travel in a opposite way.
doPlatform(Pos(90, 86, 6), Pos(90, 87, 6))
Graphic explanation:
Yellow: First position, position of platform
Blue: Second position, position of where the platform came from
White: Platform will travel in that direction
/data/movements/movements.xml
Code:
<movevent type="StepIn" itemid="460" event="script" value="platform.lua"/>
<movevent type="AddItem" tileitem="1" itemid="460" event="script" value="platform.lua"/>
/data/movements/scripts/platform.lua
Code:
function onAddItem(moveItem, tileItem, position, cid)
if isPlayer(cid) then
doRemoveItem(moveItem.uid)
doSendMagicEffect(position, CONST_ME_POFF)
end
end
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if isCreature(cid) then
doTeleportThing(cid, fromPosition, false)
end
end
/data/globalevent/scripts/globalevents.xml
Code:
<globalevent name="platform" type="start" event="script" value="platform.lua"/>
/data/globalevent/scripts/platform.lua
Code:
-- Flying Platform script
-- By cbrm / CyberM / cybermaster
-- otland.net
local Pos = Position
if not Position then
Pos = function (x, y, z)
local position = {x = 0, y = 0, z = 0}
if(tonumber(x .. y .. z) ~= nil) then
position = {x = x, y = y, z = z}
end
return position
end
end
function modify_pos(old, new)
return Pos(new.x and old.x+new.x or old.x, new.y and old.y+new.y or old.y, new.z and old.z+new.z or old.z)
end
local SPEED = 300 --fastest = 1, slowest = 1000
local PLATFORM = 426 --itemid of platform
local FLOOR = 460 --invisible tile
local path =
{
[NORTH] = {y = -1},
[EAST] = {x = 1},
[SOUTH] = {y = 1},
[WEST] = {x = -1}
}
function getPosition(position, lastPosition)
for direction, mod in pairs(path) do
local pos = modify_pos(position, mod)
if (getTileItemById(pos, FLOOR).uid > 0) and not doComparePositions(pos, lastPosition) then
return pos
end
end
return lastPosition
end
function doPlatform(position, lastPosition)
local posEx = getPosition(position, lastPosition)
doTransformItem(getTileItemById(posEx, FLOOR).uid, PLATFORM)
doCleanTile(position)
for i = 1, getTileInfo(position).things do
position.stackpos = getTileInfo(position).things-i
local cid = getThingFromPos(position).uid
if isCreature(cid) then
doTeleportThing(cid, posEx, false)
end
end
doTransformItem(getTileItemById(position, PLATFORM).uid, FLOOR)
return addEvent(doPlatform, SPEED, posEx, position)
end
function onStartup()
doPlatform(Pos(90, 86, 6), Pos(90, 87, 6))
return true
end
NOTE: THIS SCRIPT DISABLES THE USAGE OF FLY SYSTEMS AND WALKING ON INVISIBLE TILES!
Last edited: