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

Spellbook script:

[spells.lua]
Lua:
function onSay(player, words, param)
    local text = ""
    local spells = {}
    for _, spell in ipairs(player:getInstantSpells()) do
        if spell.level ~= 0 then
            if spell.manapercent > 0 then
                spell.mana = spell.manapercent .. "%"
            end
            spells[#spells + 1] = spell
        end
    end

    table.sort(spells, function(a, b) return a.level < b.level end)

    local prevLevel = -1
    for i, spell in ipairs(spells) do
        local line = ""
        if prevLevel ~= spell.level then
            if i ~= 1 then
                line = "\n"
            end
            line = line .. "Spells for Level " .. spell.level .. "\n"
            prevLevel = spell.level
        end
        text = text .. line .. "  " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
    end

    player:showTextDialog(2175, text)
    return true
end

XML:
    <talkaction words="!spells" script="spells.lua" />
 
@Discovery Thank you but my english is very bad and its not easy to learn when the english is bad

But i really need someone help me with the script.

When u pull the lever it will remove a wall in 120 sec and then it will come back but if u have lucky it will remove a other wall in x position in 120 sec and not the other "normal"

It will remove a wall but if u have lucky it will remove a other wall and not the "normal wall"

i Need the script for tfs 1.2

Maybe its to hard to make that script in basic lua to

Thank you for helping and sorry for my bad english!
 
Than you very much Discovery. I have try and try in 6h with no sucsess. I maybe need to learn lua basic anyways. I will need to use translate but i will make it a try.

But maybee u can help me with this script for this time
To remove wall when u pull lever in 120 seconds but if u have lucky u will remove a other wall in 120 sec.
 
Well, you need start create a script like blocks. Brick by Brick.

How much walls have in this room? haha I really no understand..
But well...

something like that:
(just a scratch)
Lua:
    <action actionid="22666" script="wall_remove.lua"/>


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local storage = 22666
    local time_n = os.time()
    local wall_item_id = 2525

    local walls = {
        [1] = Position(1000,1000,7), -- x, y, z positions
        [2] = Position(1000,500,7) -- Position of the another wall
    }
    if(math.random(1,10) <= 1) and time_n >= Game.getStorageValue(storage) then -- 10% chance

        local lucky_wall = math.random(1,#walls)

        local tile = Tile(walls[lucky_wall])
        local wall_check = tile:getItemById(wall_item_id)
        if wall_check then
            wall_check:remove()
        end
        Game.setStorageValue(storage,(time_n+120)) -- 120 seconds to current time in a Global Storage
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, 'Try again in 2 minutes.')
        Game.setStorageValue(storage,(time_n+120)) -- 120 seconds to current time in a Global Storage
    end
    return true
end

-- Not tested...
Is important to learn bro! If you'll be a hostage of the knowledge.
 
Thank you bro, all respect for you!

The script u make dont work.
Somethinkg is wrong with it.

Just want to ask about the script just want to learn me.

local storage = 22666
local wall_item_id = 2525

Action id on lever and wall?
wall id?

  1. local walls = {
  2. [1] = Position(1000,1000,7), -- x, y, z
  3. [2] = Position(1000,500,7) --
position for the walls?


  1. if(math.random(1,10) <= 1) and time_n >= Game.getStorageValue(storage) then -- 10% chance

  2. local lucky_wall = math.random(1,#walls)

  3. local tile = Tile(walls[lucky_wall])
the lucky wall removd?
 
@Inoxic Try quote me next time! Like that: @Discovery

Well.. You no need put a actionid in the wall, just the Position(x,y,z) vectors... like in Map editor positions..

About the lever, put the actionid "22666"

Yes, this is the lucky (chance) of the wall will be removed ifnot -> create a delay again.
 
@Discovery Thanks for all help Discovery!

I will try to learn about the tutorials in youtube and otland.

Btw the script u write are not working.
I dont know if it have to be different if it is for tfs 1.2 client 10.98


Code:
local wallPosition = Position(1276, 995, 7) --wall position
local wall = 22573 --wall ID
local revertTime = 1 * 60 * 1000 --time: 1=1min
local function revertWall()
    Game.createItem(wall, 1, wallPosition)
    wallPosition: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
        local removeWall = Tile(wallPosition):getItemById(wall)
        if removeWall then
            removeWall:remove()
            wallPosition:sendMagicEffect(CONST_ME_POFF)
            addEvent(revertWall, revertTime)
        end
        item:transform(1946)
        addEvent(revertLever, revertTime, toPosition)
    end
    return true
end


This work but i want the "lucky wall" to.
 
@Discovery

I want to do a quest for my server.
But in order to do the quest, you must pull the lever to remove the wall to continue the quest.
But if you are lucky, another wall will be removed to take a much shorter way to the quest.

So pull a lever that removes the usual wall or the lucky wall. lucky should be 20%

So the "usual" wall should always be removed, but if you're lucky, the "lucky-wall" will be removed and not the usual one.
And you have 120 seconds to pass until the wall "come back"

It is a 10.98 server with TFS 1.2

I hope really you understand.
 
Oh ... is really more simple of that script I maded for you! HAHAHAHAHA
@Inoxic
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local storage = 22666
    local time_n = os.time()
    local wall_item_id = 2525

    local walls_remove_pos = Position(1000,1000,7)
    local lucky_wall_pos = Position(1000,500,7)

    if time_n >= Game.getStorageValue(storage) then

        if (math.random(1,10) <= 1) then -- 10% chance
            local lucky_wall = Tile(lucky_wall_pos)
            local lucky_wall_check = lucky_wall:getItemById(wall_item_id)
            if lucky_wall_check then
                   lucky_wall_check:remove()
             end
          end

        local tile = Tile(walls_remove_pos)
        local wall_check = tile:getItemById(wall_item_id)
        if wall_check then
            wall_check:remove()
        end

        Game.setStorageValue(storage,(time_n+120)) -- 120 seconds to current time in a Global Storage
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, 'Try again in 2 minutes.')
        Game.setStorageValue(storage,(time_n+120)) -- 120 seconds to current time in a Global Storage
    end
    return true
end

This script no include transformation of the leverID ... or create another wall.. Just remove a wall in the position.
 
6oyLhNx.png


@Discovery
 
Oh ... is really more simple of that script I maded for you! HAHAHAHAHA
@Inoxic
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local storage = 22666
    local time_n = os.time()
    local wall_item_id = 2525

    local walls_remove_pos = Position(1000,1000,7)
    local lucky_wall_pos = Position(1000,500,7)

    if time_n >= Game.getStorageValue(storage) then

        if (math.random(1,10) <= 1) then -- 10% chance
            local lucky_wall = Tile(lucky_wall_pos)
            local lucky_wall_check = lucky_wall:getItemById(wall_item_id)
            if lucky_wall_check then
                   lucky_wall_check:remove()
             end
          end

        local tile = Tile(walls_remove_pos)
        local wall_check = tile:getItemById(wall_item_id)
        if wall_check then
            wall_check:remove()
        end

        Game.setStorageValue(storage,(time_n+120)) -- 120 seconds to current time in a Global Storage
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, 'Try again in 2 minutes.')
        Game.setStorageValue(storage,(time_n+120)) -- 120 seconds to current time in a Global Storage
    end
    return true
end

This script no include transformation of the leverID ... or create another wall.. Just remove a wall in the position.
if you define constant values in scope of function they will get reinitialized every time someone use the action, move them out of function scope.

@Inoxic
Lua:
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),
    },
    levers = {notPulled = 1000, pulled = 1001}
}

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
 
Back
Top