• 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!

RevScripts Movements stepin/out tile pos

_M4G0_

Well-Known Member
Joined
Feb 6, 2016
Messages
504
Solutions
16
Reaction score
98
Hello,
I would like help, how to add the coordinates for the script to work on the chosen tile?
Does it only work with aid?


the tiles would be 284, 176, 7 and 284, 177, 7

Lua:
local coal_basin = MoveEvent()
coal_basin:type("stepin")

function coal_basin.onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
    if not player then
        return true
    end
    local  coal_basin = Tile(Position(283, 175,  7)):getItemById(1484)
    if not coal_basin then
            Game.createItem(1484,1, Position(coal_basin))
            player:getPosition():sendMagicEffect(14)
            return true
    end
       
    return true
end
coal_basin:register()


local coal_basin = MoveEvent()
coal_basin:type("stepout")


local coal_basin = MoveEvent()
function coal_basin.onStepOut(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        return false
    end
   
                pos = Position(283, 175,  7)
                coal_basin = Tile(pos):getItemById(1484)
                if coal_basin then
                    coal_basin:remove()
                end  
                   
end
coal_basin:register()
 
Solution
Hello,
I would like help, how to add the coordinates for the script to work on the chosen tile?
Does it only work with aid?


the tiles would be 284, 176, 7 and 284, 177, 7

Lua:
local coal_basin = MoveEvent()
coal_basin:type("stepin")

function coal_basin.onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
    if not player then
        return true
    end
    local  coal_basin = Tile(Position(283, 175,  7)):getItemById(1484)
    if not coal_basin then
            Game.createItem(1484,1, Position(coal_basin))
            player:getPosition():sendMagicEffect(14)
            return true
    end
      
    return true
end
coal_basin:register()


local coal_basin = MoveEvent()
coal_basin:type("stepout")...
you can use:
Lua:
coal_basin:position(Position(284, 176, 7), Position(284, 177, 7))
I had already tried this

Lua Script Error: [Scripts Interface]
D:\Ot\data\scripts\movements\upgrade_item.lua
D:\Ot\data\scripts\movements\upgrade_item.lua:3: attempt to call method 'position' (a nil value)
stack traceback:
[C]: in function 'position'
D:\Ot\data\scripts\movements\upgradeitem.lua:3: in main chunk
 
TRY.

Lua:
local coal_basin = MoveEvent()
coal_basin:type("stepin")

function coal_basin.onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end


    if (position.x == 284 and (position.y == 176 or position.y == 177) and position.z == 7) then
        local coal_basin = Tile(Position(283, 175, 7)):getItemById(1484)
        if not coal_basin then
            Game.createItem(1484, 1, Position(283, 175, 7))
            player:getPosition():sendMagicEffect(14)
        end
    end

    return true
end

coal_basin:register()

local coal_basin_out = MoveEvent()
coal_basin_out:type("stepout")

function coal_basin_out.onStepOut(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        return false
    end


    if (fromPosition.x == 284 and (fromPosition.y == 176 or fromPosition.y == 177) and fromPosition.z == 7) then
        local coal_basin = Tile(Position(283, 175, 7)):getItemById(1484)
        if coal_basin then
            coal_basin:remove()
        end
    end

    return true
end

coal_basin_out:register()
 
Hello,
I would like help, how to add the coordinates for the script to work on the chosen tile?
Does it only work with aid?


the tiles would be 284, 176, 7 and 284, 177, 7

Lua:
local coal_basin = MoveEvent()
coal_basin:type("stepin")

function coal_basin.onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
    if not player then
        return true
    end
    local  coal_basin = Tile(Position(283, 175,  7)):getItemById(1484)
    if not coal_basin then
            Game.createItem(1484,1, Position(coal_basin))
            player:getPosition():sendMagicEffect(14)
            return true
    end
      
    return true
end
coal_basin:register()


local coal_basin = MoveEvent()
coal_basin:type("stepout")


local coal_basin = MoveEvent()
function coal_basin.onStepOut(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        return false
    end
  
                pos = Position(283, 175,  7)
                coal_basin = Tile(pos):getItemById(1484)
                if coal_basin then
                    coal_basin:remove()
                end 
                  
end
coal_basin:register()
Lua:
-- same config for both events
local CONFIG_ITEM_ID = 1484
local CONFIG_ITEM_POS = Position(283, 175,  7)

local EVENT_POSITIONS = {Position(284, 176, 7), Position(284, 177, 7)}


-- step IN event
local coalBasin_IN = MoveEvent()
coalBasin_IN:type("stepin")

function coalBasin_IN.onStepIn(creature, item, position, fromPosition)
  if not creature:isPlayer() then
    return false
  end

  local someTile = Tile(CONFIG_ITEM_POS)
  local someItem = someTile:getItemById(CONFIG_ITEM_ID)

  if not someItem then
    Game.createItem(CONFIG_ITEM_ID, 1, CONFIG_ITEM_POS)
    creature:getPosition():sendMagicEffect(14)
  end

  return true
end
coalBasin_IN:position(unpack(EVENT_POSITIONS))
coalBasin_IN:register()


-- step out event
local coalBasin_OUT = MoveEvent()
coalBasin_OUT:type("stepout")

function coalBasin_OUT.onStepOut(creature, item, position, fromPosition)
  if not creature:isPlayer() then
    return false
  end
  
  local someTile = Tile(CONFIG_ITEM_POS)
  local someItem = someTile:getItemById(CONFIG_ITEM_ID)

  if someItem then
    someItem:remove()
  end

  return true
end
coalBasin_OUT:position(unpack(EVENT_POSITIONS))
coalBasin_OUT:register()
 
Solution
Lua:
-- same config for both events
local CONFIG_ITEM_ID = 1484
local CONFIG_ITEM_POS = Position(283, 175,  7)

local EVENT_POSITIONS = {Position(284, 176, 7), Position(284, 177, 7)}


-- step IN event
local coalBasin_IN = MoveEvent()
coalBasin_IN:type("stepin")

function coalBasin_IN.onStepIn(creature, item, position, fromPosition)
  if not creature:isPlayer() then
    return false
  end

  local someTile = Tile(CONFIG_ITEM_POS)
  local someItem = someTile:getItemById(CONFIG_ITEM_ID)

  if not someItem then
    Game.createItem(CONFIG_ITEM_ID, 1, CONFIG_ITEM_POS)
    creature:getPosition():sendMagicEffect(14)
  end

  return true
end
coalBasin_IN:position(unpack(EVENT_POSITIONS))
coalBasin_IN:register()


-- step out event
local coalBasin_OUT = MoveEvent()
coalBasin_OUT:type("stepout")

function coalBasin_OUT.onStepOut(creature, item, position, fromPosition)
  if not creature:isPlayer() then
    return false
  end
 
  local someTile = Tile(CONFIG_ITEM_POS)
  local someItem = someTile:getItemById(CONFIG_ITEM_ID)

  if someItem then
    someItem:remove()
  end

  return true
end
coalBasin_OUT:position(unpack(EVENT_POSITIONS))
coalBasin_OUT:register()
work perfectly, thank you

after adding missing functions
Lua:
registerMethod("MoveEvent", "position", LuaScriptInterface::luaMoveEventPosition);
 
Back
Top