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

TFS 1.X+ Switch script not working tfs 1.5 (8.0 by Nekiro)

Hashcube

Member
Joined
Jun 28, 2023
Messages
17
Reaction score
6
Hi. I struggle to make my switch work. Tried so far a lot of scripts and wrote some code on my own but nothing worked.
What I try to achieve is if player uses switch, then door on positon XYZ transforms from closed to open.

Procedure:

  • In RME set action id 9002 on switch
  • add <action itemid="9002" script="quests/door.lua" /> to data\actions\actions.xml

1 of the scripts I tried:
source
quests/door.lua
Lua:
local doorPosition = Position(1106, 853, 12)
local relocatePosition = Position(1107, 853, 12)


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 1946 then
        local doorItem = Tile(doorPosition):getItemById(5108)
        if doorItem then
            doorItem:transform(5109)
            doorItem:setActionId(1002)
            item:transform(1945)
        end
    else
        local tile = Tile(doorPosition)
        local doorItem = tile:getItemById(5109)
        if doorItem then
            tile:relocateTo(relocatePosition, true)


            doorItem:transform(5108)
            doorItem:setActionId(1001)
            item:transform(1946)
        end
    end
    return true
end
 
Last edited:
Back
Top