If you want the platform always moving use http://otland.net/f82/flying-platform-190928/
You step on a flying tile that makes you travel thru a path you draw on map editor, platform stops on destination arrival
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 only be open.
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
/data/movements/movements.xml
/data/movements/scripts/platform.lua
NOTE: THIS SCRIPT DISABLES THE USAGE OF FLY SYSTEMS AND WALKING ON INVISIBLE TILES!
You step on a flying tile that makes you travel thru a path you draw on map editor, platform stops on destination arrival
Any item thrown on path or platform is erased
Config
local SPEED = 300 --fastest = 100, slowest = 1000
local PLATFORM = 406 --itemid of platform
local TILES = {Pos(111, 90, 6), Pos(103, 71, 6)} --all start/stop positions of platforms
Draw the travel path with invis tiles(id:460) in map, it can't be diagonal, it can only be open.
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
/data/movements/movements.xml
XML:
<movevent type="StepIn" itemid="406" event="script" value="platform.lua"/>
<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:
-- 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 = 406 --itemid of platform
local FLOOR = 460 --invisible tile
local TILES = {Pos(111, 90, 6), Pos(103, 71, 6)} --all start/stop positions of platforms
local path =
{
[NORTH] = {y = -1},
[EAST] = {x = 1},
[SOUTH] = {y = 1},
[WEST] = {x = -1}
}
function isPlatform(pos)
for i, position in ipairs(TILES) do
if doComparePositions(pos, position) then
return true
end
end
return false
end
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 not isPlatform(posEx) and addEvent(doPlatform, SPEED, posEx, position)
end
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if item.itemid == FLOOR and isCreature(cid) then
doTeleportThing(cid, fromPosition, false)
elseif isPlayer(cid) and isPlatform(position) and (getTileItemById(fromPosition, PLATFORM).uid == 0) then
doPlatform(getThingPos(cid), position)
end
end
function onAddItem(moveItem, tileItem, position, cid)
if isPlayer(cid) then
doRemoveItem(moveItem.uid)
doSendMagicEffect(position, CONST_ME_POFF)
end
end
NOTE: THIS SCRIPT DISABLES THE USAGE OF FLY SYSTEMS AND WALKING ON INVISIBLE TILES!
Last edited: