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

Wall Lever not working

Morineau

pig benis
Joined
Jul 19, 2009
Messages
37
Reaction score
2
Hi guys!

I've been trying to adapt this wall lever script to my tfs 1.2 server:


This is the script Im using:

Code:
<action actionid="1356" script="pilar.lua"/>

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local pillarTile = Tile(X, Y, Z)

    if item.itemid == 1945 then
        pillarTile:getPosition():sendMagicEffect(CONST_ME_POFF)
        pillarTile:getItemById(1515):remove()
        Item(item.uid):transform(1946)

        addEvent(function(pillarPos, lever)
            Game.createItem(1515, 1, pillarPos)      -- Create pillar
            pillarPos:sendMagicEffect(CONST_ME_POFF) -- Send POFF effect
            lever:transform(1945)                    -- Flip lever to the left
        end, 3000, pillarTile:getPosition(), Tile(toPosition):getItemById(1946))
  
    elseif item.itemid == 1946 then
        return false
    end
    return true
end

The pilar gets removed and then it gets created again but my lever is not turning to the left

Console Error:
data/actions/scripts/pilar.lua:12: attempt to index local 'lever' (a number value)
stack traceback:
[C]: in function '__index'

Could anybody please be so kind to help me?

Thanks!
 
Last edited:
I never worked on tfs newer than 0.4 but I guess you have not precised lever id, so it's trying to transform nothing into something.
Post automatically merged:

try adding
local lever = ID of lever
under or over
local pillarTile = Tile
 
Ok it got strange, so it's working now with this code:

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local pillarTile = Tile(406, 705, 7)
    local lever = 1945

    if item.itemid == 1945 then
        pillarTile:getPosition():sendMagicEffect(CONST_ME_POFF)
        pillarTile:getItemById(1515):remove()
        Item(item.uid):transform(1946)

        addEvent(function(pillarPos)
            Game.createItem(1515, 1, pillarPos)      -- Create pillar
            pillarPos:sendMagicEffect(CONST_ME_POFF) -- Send POFF effect
            Item(item.uid):transform(1945)                   -- Flip lever to the left
        end, 3000, pillarTile:getPosition(), Tile(toPosition):getItemById(1946))

    elseif item.itemid == 1946 then
        return false
    end
    return true

end

But the console prints this error:


Code:
Lua Script Error: [Action Interface]
data/actions/scripts/pilar.lua:onUse
LuaScriptInterface::luaAddEvent(). Argument #4 is unsafe
stack traceback:
        [C]: in function 'addEvent'
        data/actions/scripts/pilar.lua:10: in function <data/actions/scripts/pilar.lua:1>
 
Last edited:
.
Post automatically merged:

I guess this has to do with functions. They are not called properly or addEvent function is written the way it shouldnt be.
As I mentioned I have not worked with TFS 1.X never before so won't be able to help you any further
 
Last edited:
Back
Top