• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

MoveEvent 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 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
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.
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

/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:
video pls

I cannot find a video at this time, but I can give you a general idea:

Example 1:- Player (targeting other player, we will call him Target) casts Hirenkyaku (just for the sake of demonstration), platform is created, player is "flying" or "hovering" over platform, untill he reaches Target.
Example 2:- Player casts Hirenkyaku, platform is created, player can "hover" while riding his Hirenkyaku Platform, as if he was moving normally, for a set amount of time.

*EDIT-1*: Basically I'm asking if its possible to re-write this without having to make a path in the map editor.
 
Last edited:
I cannot find a video at this time, but I can give you a general idea:

Example 1:- Player (targeting other player, we will call him Target) casts Hirenkyaku (just for the sake of demonstration), platform is created, player is "flying" or "hovering" over platform, untill he reaches Target.
Example 2:- Player casts Hirenkyaku, platform is created, player can "hover" while riding his Hirenkyaku Platform, as if he was moving normally, for a set amount of time.

*EDIT-1*: Basically I'm asking if its possible to re-write this without having to make a path in the map editor.
Maybe with a fly system, but it's too messy, would need to rewrite all script
 
Back
Top