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

Lua Want 4 walls to be removed instead of only 1

Aliii96

New Member
Joined
Jul 14, 2014
Messages
39
Reaction score
0
Hello Otlanders, I got this script and its working perfectly. But I have 1 problem now cuz I want this lever to remove 4 walls next to eachother on position 33398,32467,8 and 33398,32469,8 and 33398,32470,8 and the 1 already in the script.
I have tried to just place the positions at the local wallposition: but it didnt work..
So here is the script and I hope you guys can help me with this lil thing.

lever.lua - Pastebin.com
 
Solution
Lua:
local config = {
    leverRevertTime = 1*60, --time in seconds instead of miliseconds
    itemPositions = {
        {id = 1546, pos = Position(33398, 32468, 8), revertTime = 1*60},
        {id = 1546, pos = Position(33398, 32468, 8), revertTime = 1*60},
    }
}
local function revertWall(position, id)
    Game.createItem(id, 1, position)
    position:sendMagicEffect(CONST_ME_POFF)
end
local function revertLever(position)
    local leverItem = Tile(position):getItemById(1946)
    if leverItem then
        leverItem:transform(1945)
    end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        for i = 1, #config.itemPositions do
            local removeWall =...
Lua:
local config = {
    leverRevertTime = 1*60, --time in seconds instead of miliseconds
    itemPositions = {
        {id = 1546, pos = Position(33398, 32468, 8), revertTime = 1*60},
        {id = 1546, pos = Position(33398, 32468, 8), revertTime = 1*60},
    }
}
local function revertWall(position, id)
    Game.createItem(id, 1, position)
    position:sendMagicEffect(CONST_ME_POFF)
end
local function revertLever(position)
    local leverItem = Tile(position):getItemById(1946)
    if leverItem then
        leverItem:transform(1945)
    end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        for i = 1, #config.itemPositions do
            local removeWall = Tile(config.itemPositions[i].pos):getItemById(config.itemPositions[i].id)
            if removeWall then
                removeWall:remove()
                config.itemPositions[i].pos:sendMagicEffect(CONST_ME_POFF)
                addEvent(revertWall, config.itemPositions[i].revertTime * 1000, config.itemPositions[i].pos, config.itemPositions[i].id)
            end
        end
        item:transform(1946)
        addEvent(revertLever, config.leverRevertTime * 1000, toPosition)
    end
    return true
end
 
Solution
Lua:
local config = {
    leverRevertTime = 1*60, --time in seconds instead of miliseconds
    itemPositions = {
        {id = 1546, pos = Position(33398, 32468, 8), revertTime = 1*60},
        {id = 1546, pos = Position(33398, 32468, 8), revertTime = 1*60},
    }
}
local function revertWall(position, id)
    Game.createItem(id, 1, position)
    position:sendMagicEffect(CONST_ME_POFF)
end
local function revertLever(position)
    local leverItem = Tile(position):getItemById(1946)
    if leverItem then
        leverItem:transform(1945)
    end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1945 then
        for i = 1, #config.itemPositions do
            local removeWall = Tile(config.itemPositions[i].pos):getItemById(config.itemPositions[i].id)
            if removeWall then
                removeWall:remove()
                config.itemPositions[i].pos:sendMagicEffect(CONST_ME_POFF)
                addEvent(revertWall, config.itemPositions[i].revertTime * 1000, config.itemPositions[i].pos, config.itemPositions[i].id)
            end
        end
        item:transform(1946)
        addEvent(revertLever, config.leverRevertTime * 1000, toPosition)
    end
    return true
end


Thank you so much, it worked :)
 
Back
Top