• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

GlobalEvent Flying Platform

hodleo

Formerly cbrm -Crypto enthusiast, Retired scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,598
Solutions
3
Reaction score
955
Location
Caribbean Sea
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
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.
8k4EEr.png
7aCxcB.png

hm9AwI.png

EhIli-.png


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
xxfXbYj.png


/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:
jufp7a.jpg


POS ==73,27,6
POS == 73,28,6

in globalevents script :
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 = 100, slowest = 1000
local PLATFORM = 426 --itemid of platform
local FLOOR = 460 --invisible floor
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
end

function doPlatform(position, lastPosition)
    local posEx = getPosition(position, lastPosition)
    doCreateItem(PLATFORM, posEx)
    
    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)
    
    for j = 1, getTileInfo(position).things do
        position.stackpos = getTileInfo(position).things-j
        local id = getThingFromPos(position)
        if (id.itemid > 0) and not isInArray({PLATFORM, FLOOR}, id.itemid) then
            doRemoveItem(id.uid)
            doSendMagicEffect(position, CONST_ME_POFF)
        end
    end
    return addEvent(doPlatform, SPEED, posEx, position)
end

function onStartup()
    doPlatform(Pos(73, 27, 6), Pos(73, 28, 6))
    return true
end
 
Script updated, now it supports open paths like
hm9AwI.png
EhIli-.png
 
Last edited:
Is it possible to add a monster on TOP of the plataform that looks like a plataform?
The idea I mean is to make the animation smooth.
 
Is it possible to add a monster on TOP of the plataform that looks like a plataform?
The idea I mean is to make the animation smooth.
I don't totally get it
 
He means to make a monster look like a platform and place it over the platform, I think o_O
 
Back
Top