Your browser does not support JavaScript or its disabled!
Please turn it on, or be aware that some features on this website will not work correctly.
1.4K
Suggestions
Switch Next Char | 01/05/21 | 3.1K
Auto Mount | 01/01/20 | 2.2K
Warning replace | 18/08/24 | 134
Orb Counter | 17/11/21 | 1.2K
Use Lever on Item Drop #77

This will use a lever to the left of player if an item is dropped at the set location.

1.41kb | 43 lines.
--[[
  Script made by Lee (Discord: l33_) - www.trainorcreations.com
  If you want to support my work, feel free to donate at https://trainorcreations.com/donate
  PS. Stop ripping off my work and selling it as your own.
]]--
local itemFloor = 1781
local itemPos = { x = 1003, y = 991, z = 7 }
local levers = { 2772, 2773 } -- lever to use  (if you can use the lever if its left or right, put both id's)

--------
-- use this or below
--------
macro(100, "Use Lever", function()
    local leverPos = pos()
    leverPos.x = leverPos.x - 1   -- x-1 is left of player x+1 == right of player
    local lever = g_map.getTile(leverPos)
    local item = g_map.getTile(itemPos)
    if not item or not lever then return false end

    local itemTop = item:getTopUseThing()
    local leverTop = lever:getTopUseThing()
    if not itemTop or not leverTop then return false end
    if itemTop:getId() == itemFloor then
        if table.contains(levers, leverTop:getId()) then
            delay(1000)
            g_game.use(leverTop)
        end
    end
end)
--------
-- or --
--------
macro(100, "Use Lever", function()
    local tile = g_map.getTile(itemPos)
    if not tile then return false end
    if isOnTile(itemFloor, tile) then
        local leverPos = pos()
        leverPos.x = leverPos.x - 1   -- x-1 is left of player x+1 == right of player
        local lever = g_map.getTile(leverPos)
        if not lever then return false end

        local leverTop = lever:getTopUseThing()
        if leverTop and table.contains(levers, leverTop:getId()) then
            delay(1000)
            g_game.use(leverTop)
        end
    end
end)

27 Dec 2021
Ads