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

Script for 1.2 TFS

Lucifer

Active Member
Joined
Dec 27, 2014
Messages
145
Reaction score
33
Location
Sweden
Iam Searching for a Script when i pull the lever it will remove a wall.

And a other script with func !spells

Please help me.
 
Solution
Lua:
local config = {
    walls = {
        [1] = {position = Position(1276, 995, 7), chance = 100, id = 1546},
        [2] = {position = Position(1412, 1000, 6), chance = 20, id = 1546},
    },
    levers = {notPulled = 1945, pulled = 1946}
}
local function revertThings(leverPosition)
    for _, wall in ipairs(config.walls) do
        local tile = Tile(wall.position)
        if tile then
            local wallItem = tile:getItemById(wall.id)
            if not wallItem then
                Game.createItem(wall.id, 1, wall.position)
            end
        end
    end
    local tile = Tile(leverPosition)
    if tile then
        local item = tile:getItemById(config.levers.pulled)
        if item then...
  • local config = {
  • walls = {
  • [1] = {position = Position(x, y, z), chance = 100, id = 1033},
  • [2] = {position = Position(x, y, z), chance = 20, id = 1033},
  • },
  • positions = {
  • Position(x, y, z),
  • Position(x, y, z),
  • },

Where do i write the position now?

  • },
  • levers = {notPulled = 1000, pulled = 1001}
  • }

Will it be like this or do i need to put lever id?

Bec i cant make it work.
P0WxwWN.png


@Discovery
@Nekiro
 
Last edited:
You need to edit the config.
levers table holds ids, of not pulled lever and pulled lever.
x, y, z are your positions Position(1000, 1000, 7), id is id of wall and chance is chance in %
 
@Nekiro

Code:
local config = {
    walls = {
        [1] = {position = Position(1276, 995, 7), chance = 100, id = 1546},
        [2] = {position = Position(1412, 1000, 6), chance = 20, id = 1546},
    },
    positions = {
        Position(1289, 998, 7),
        Position(1289, 999, 7),
    },
    levers = {notPulled = 1945, pulled = 1946}
}
local function revertThings(leverPosition)
    for _, wall in ipairs(config.walls) do
        local tile = Tile(wall.position)
        if tile then
            local wall = tile:getItemById(wall.id)
            if not wall then
                Game.createItem(wall.id, 1, wall.position)
            end
        end
    end
  
    local tile = Tile(leverPosition)
    if tile then
        local item = tile:getItemById(config.levers.pulled)
        if item then
            item:transform(config.levers.notPulled)
        end
    end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item:getId() == config.levers.notPulled then
        for _, wall in ipairs(config.walls) do
            local tile = Tile(wall.position)
            if tile then
                local wall = tile:getItemById(wall.id)
                if wall and math.random(1, 100) <= wall.chance then
                    wall:remove()
                end
            end
        end
        item:transform(config.levers.pulled)
        addEvent(revertThings, 2 * 60 * 1000, item:getPosition())
    end
    return true
end
 
Yeah my bad, wrong variable name.

Code:
local config = {
    walls = {
        [1] = {position = Position(1276, 995, 7), chance = 100, id = 1546},
        [2] = {position = Position(1412, 1000, 6), chance = 20, id = 1546},
    },
    levers = {notPulled = 1945, pulled = 1946}
}
local function revertThings(leverPosition)
    for _, wall in ipairs(config.walls) do
        local tile = Tile(wall.position)
        if tile then
            local wall = tile:getItemById(wall.id)
            if not wall then
                Game.createItem(wall.id, 1, wall.position)
            end
        end
    end
    local tile = Tile(leverPosition)
    if tile then
        local item = tile:getItemById(config.levers.pulled)
        if item then
            item:transform(config.levers.notPulled)
        end
    end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item:getId() == config.levers.notPulled then
        for _, wall in ipairs(config.walls) do
            local tile = Tile(wall.position)
            if tile then
                local wallItem = tile:getItemById(wall.id)
                if wallItem and math.random(1, 100) <= wall.chance then
                    wallItem:remove()
                end
            end
        end
        item:transform(config.levers.pulled)
        addEvent(revertThings, 2 * 60 * 1000, item:getPosition())
    end
    return true
end
 
Last edited:
Lua:
local config = {
    walls = {
        [1] = {position = Position(1276, 995, 7), chance = 100, id = 1546},
        [2] = {position = Position(1412, 1000, 6), chance = 20, id = 1546},
    },
    levers = {notPulled = 1945, pulled = 1946}
}
local function revertThings(leverPosition)
    for _, wall in ipairs(config.walls) do
        local tile = Tile(wall.position)
        if tile then
            local wallItem = tile:getItemById(wall.id)
            if not wallItem then
                Game.createItem(wall.id, 1, wall.position)
            end
        end
    end
    local tile = Tile(leverPosition)
    if tile then
        local item = tile:getItemById(config.levers.pulled)
        if item then
            item:transform(config.levers.notPulled)
        end
    end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item:getId() == config.levers.notPulled then
        for _, wall in ipairs(config.walls) do
            local tile = Tile(wall.position)
            if tile then
                local wallItem = tile:getItemById(wall.id)
                if wallItem and math.random(1, 100) <= wall.chance then
                    wallItem:remove()
                end
            end
        end
        item:transform(config.levers.pulled)
        addEvent(revertThings, 2 * 60 * 1000, item:getPosition())
    end
    return true
end
 
Solution
@Nekiro Its work perfect! Thank you very much

I have 1 question is it hard to add text "you have lucky today" when you get "lucky" and remove the other "lucky-wall"?
And maybe for the "normal wall"count the seconds until it closes again?

Edit: How can i make to remove than 1 wall in (lucky-wall)

@Discovery thank you for all the help and tips!
 
Last edited:
Back
Top