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

Solved Level doors are not closing after being used

Felipe93

Ghost Member
Joined
Mar 21, 2015
Messages
1,990
Solutions
9
Reaction score
334
Location
Chile
Hi

I'm using tfs 1.5 all doors works good but level doors are not getting closed also ain't getting errors in console
this is the door script
Lua:
local openOddDoors = {
    [12695] = { locked = 13237, closed = 12692 },
    [12703] = { locked = 13236, closed = 12701 },
    [14635] = { locked = 14634, closed = 14633 },
    [17435] = { locked = 14641, closed = 14640 },
    [26533] = { locked = 26530, closed = 26529 },
    [26534] = { locked = 26532, closed = 26531 },
    [31176] = { locked = 31175, closed = 27559 },
    [31024] = { locked = 31021, closed = 31020 },
    [31025] = { locked = 31023, closed = 31022 },
    [31541] = { locked = 31314, closed = 31314 },
    [31542] = { locked = 31315, closed = 31315 },
    [32691] = { locked = 32705, closed = 32689 },
    [32692] = { locked = 32706, closed = 32690 },
    [32695] = { locked = 32707, closed = 32693 },
    [32696] = { locked = 32708, closed = 32694 },
    [33432] = { locked = 33429, closed = 33428 },
    [33433] = { locked = 33431, closed = 33430 },
    [33493] = { locked = 33490, closed = 33489 },
    [33494] = { locked = 33492, closed = 33491 },
    [34152] = { locked = 34150, closed = 34150 },
    [34153] = { locked = 34151, closed = 34151 },
    [36292] = { locked = 36289, closed = 36288 },
    [36293] = { locked = 36291, closed = 36290 },
    [37596] = { locked = 37593, closed = 37592 },
    [37597] = { locked = 37595, closed = 37594 },  
    [39119] = { locked = 39116, closed = 39115 },
    [39120] = { locked = 39118, closed = 39117 }
}
local closedOddDoors = {  
    [12692] = { locked = 13237, open = 12695 },
    [12701] = { locked = 13236, open = 12703 },
    [14633] = { locked = 14634, open = 14635 },
    [14640] = { locked = 14641, open = 17435 },
    [26529] = { locked = 26530, open = 26533 },
    [26531] = { locked = 26532, open = 26534 },
    [27559] = { locked = 31175, open = 31176 },
    [31020] = { locked = 31021, open = 31024 },
    [31022] = { locked = 31023, open = 31025 },
    [31314] = { locked = 31314, open = 31541 },
    [31315] = { locked = 31315, open = 31542 },
    [32689] = { locked = 32705, open = 32691 },
    [32690] = { locked = 32706, open = 32692 },
    [32693] = { locked = 32707, open = 32695 },
    [32694] = { locked = 32708, open = 32696 },
    [33428] = { locked = 33429, open = 33432 },
    [33430] = { locked = 33431, open = 33433 },
    [33489] = { locked = 33490, open = 33493 },
    [33491] = { locked = 33492, open = 33494 },
    [34150] = { locked = 34150, open = 34152 },
    [34151] = { locked = 34151, open = 34153 },
    [36288] = { locked = 36289, open = 36292 },
    [36290] = { locked = 36291, open = 36293 },
    [37592] = { locked = 37593, open = 37596 },
    [37594] = { locked = 37595, open = 37597 },
    [39115] = { locked = 39116, open = 39119 },
    [39117] = { locked = 39118, open = 39120 }
}
local lockedOddDoors = {
    [13237] = { closed = 12692, open = 12695 },
    [13236] = { closed = 12701, open = 12703 },
    [14634] = { closed = 14633, open = 14635 },
    [14641] = { closed = 14640, open = 17435 },
    [26530] = { closed = 26529, open = 26533 },
    [26532] = { closed = 26531, open = 26534 },
    [31175] = { closed = 27559, open = 31176 },
    [31021] = { closed = 31020, open = 31024 },
    [31023] = { closed = 31022, open = 31025 },
    [32705] = { closed = 32689, open = 32691 },
    [32706] = { closed = 32690, open = 32692 },
    [32707] = { closed = 32693, open = 32695 },
    [32708] = { closed = 32694, open = 32696 },
    [33429] = { closed = 33428, open = 33432 },
    [33431] = { closed = 33430, open = 33433 },
    [33490] = { closed = 33489, open = 33493 },
    [33492] = { closed = 33491, open = 33494 },
    [36289] = { closed = 36288, open = 36292 },
    [36291] = { closed = 36290, open = 36293 },
    [37593] = { closed = 37592, open = 37596 },
    [37595] = { closed = 37594, open = 37597 },
    [39116] = { closed = 39115, open = 39119 },
    [39118] = { closed = 39117, open = 39120 }
}

local positionOffsets = {
    {x = 1, y = 0}, -- east
    {x = 0, y = 1}, -- south
    {x = -1, y = 0}, -- west
    {x = 0, y = -1}, -- north
}

--[[
When closing a door with a creature in it findPushPosition will find the most appropriate
adjacent position following a prioritization order.
The function returns the position of the first tile that fulfills all the checks in a round.
The function loops trough east -> south -> west -> north on each following line in that order.
In round 1 it checks if there's an unhindered walkable tile without any creature.
In round 2 it checks if there's a tile with a creature.
In round 3 it checks if there's a tile blocked by a movable tile-blocking item.
In round 4 it checks if there's a tile blocked by a magic wall or wild growth.
]]
local function findPushPosition(creature, round)
    local pos = creature:getPosition()
    for _, offset in ipairs(positionOffsets) do
        local offsetPosition = Position(pos.x + offset.x, pos.y + offset.y, pos.z)
        local tile = Tile(offsetPosition)
        if tile then
            local creatureCount = tile:getCreatureCount()
            if round == 1 then
                if tile:queryAdd(creature) == RETURNVALUE_NOERROR and creatureCount == 0 then
                    if not tile:hasFlag(TILESTATE_PROTECTIONZONE) or (tile:hasFlag(TILESTATE_PROTECTIONZONE) and creature:canAccessPz()) then
                        return offsetPosition
                    end
                end
            elseif round == 2 then
                if creatureCount > 0 then
                    if not tile:hasFlag(TILESTATE_PROTECTIONZONE) or (tile:hasFlag(TILESTATE_PROTECTIONZONE) and creature:canAccessPz()) then
                        return offsetPosition
                    end
                end
            elseif round == 3 then
                local topItem = tile:getTopDownItem()
                if topItem then
                    if topItem:getType():isMovable() then
                        return offsetPosition
                    end
                end
            else
                if tile:getItemById(ITEM_MAGICWALL) or tile:getItemById(ITEM_WILDGROWTH) then
                    return offsetPosition
                end
            end
        end
    end
    if round < 4 then
        return findPushPosition(creature, round + 1)
    end
end

local door = Action()

function door.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemId = item:getId()
    local transformTo = 0
    if table.contains(closedQuestDoors, itemId) then
        if player:getStorageValue(item.actionid) ~= -1 or player:getGroup():getAccess() then
            item:transform(itemId + 1)
            player:teleportTo(toPosition, true)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The door seems to be sealed against unwanted intruders.")
        end
        return true
    elseif table.contains(closedLevelDoors, itemId) then
        if item.actionid > 0 and player:getLevel() >= item.actionid - actionIds.levelDoor or player:getGroup():getAccess() then
            item:transform(itemId + 1)
            player:teleportTo(toPosition, true)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Only the worthy may pass.")
        end
        return true
    elseif table.contains(keys, itemId) then
        local tile = Tile(toPosition)
        if not tile then
            return false
        end
        target = tile:getTopVisibleThing()
        if target.actionid == 0 then
            return false
        end
        if table.contains(keys, target.itemid) then
            return false
        end
        if not table.contains(openDoors, target.itemid) and not table.contains(closedDoors, target.itemid) and not table.contains(lockedDoors, target.itemid) then
            return false
        end
        if item.actionid ~= target.actionid then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "The key does not match.")
            return true
        end
        if lockedOddDoors[target.itemid] then
            transformTo = lockedOddDoors[target.itemid].open
        else
            transformTo = target.itemid + 2
        end
        if table.contains(openDoors, target.itemid) then
            if openOddDoors[target.itemid] then
                transformTo = openOddDoors[target.itemid].locked
            else
                transformTo = target.itemid - 2
            end
        elseif table.contains(closedDoors, target.itemid) then
            if closedOddDoors[target.itemid] then
                transformTo = closedOddDoors[target.itemid].locked
            else
                transformTo = target.itemid - 1
            end
        end
        target:transform(transformTo)
        return true
    elseif table.contains(lockedDoors, itemId) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It is locked.")
        return true
    elseif table.contains(openDoors, itemId) or table.contains(openExtraDoors, itemId) or table.contains(openHouseDoors, itemId) then
        local creaturePositionTable = {}
        local doorCreatures = Tile(toPosition):getCreatures()
        if doorCreatures and #doorCreatures > 0 then
            for _, doorCreature in pairs(doorCreatures) do
                local pushPosition = findPushPosition(doorCreature, 1)
                if not pushPosition then
                    player:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM)
                    return true
                end
                table.insert(creaturePositionTable, {creature = doorCreature, position = pushPosition})
            end
            for _, tableCreature in ipairs(creaturePositionTable) do
                tableCreature.creature:teleportTo(tableCreature.position, true)
            end
        end
        if openOddDoors[itemId] then
            transformTo = openOddDoors[itemId].closed
        else
            transformTo = itemId - 1
        end
        item:transform(transformTo)
        return true
    elseif table.contains(closedDoors, itemId) or table.contains(closedExtraDoors, itemId) or table.contains(closedHouseDoors, itemId) then
        if closedOddDoors[itemId] then
            transformTo = closedOddDoors[itemId].open
        else
            transformTo = itemId + 1
        end
        item:transform(transformTo)
        return true
    end
    return false
end

local doorTables = {keys, openDoors, closedDoors, lockedDoors, openExtraDoors, closedExtraDoors, openHouseDoors, closedHouseDoors, closedQuestDoors, closedLevelDoors}
for _, doors in pairs(doorTables) do
    for _, doorId in pairs(doors) do
        door:id(doorId)
    end
end
door:register()

local door = Action()

function door.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemId = item:getId()
    if table.contains(closedQuestDoors, itemId) then
        if player:getStorageValue(item.actionid) ~= -1 or player:getGroup():getAccess() then
            item:transform(itemId + 1)
            player:teleportTo(toPosition, true)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The door seems to be sealed against unwanted intruders.")
        end
        return true
    elseif table.contains(closedLevelDoors, itemId) then
        if item.actionid > 0 and player:getLevel() >= item.actionid - actionIds.levelDoor or player:getGroup():getAccess() then
            item:transform(itemId + 1)
            player:teleportTo(toPosition, true)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Only the worthy may pass.")
        end
        return true
    elseif table.contains(keys, itemId) then
        local tile = Tile(toPosition)
        if not tile then
            return false
        end
        target = tile:getTopVisibleThing()
        if target.actionid == 0 then
            return false
        end
        if table.contains(keys, target.itemid) then
            return false
        end
        if not table.contains(openDoors, target.itemid) and not table.contains(closedDoors, target.itemid) and not table.contains(lockedDoors, target.itemid) then
            return false
        end
        if item.actionid ~= target.actionid then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "The key does not match.")
            return true
        end
        local transformTo = target.itemid + 2
        if table.contains(openDoors, target.itemid) then
            transformTo = target.itemid - 2
        elseif table.contains(closedDoors, target.itemid) then
            transformTo = target.itemid - 1
        end
        target:transform(transformTo)
        return true
    elseif table.contains(lockedDoors, itemId) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It is locked.")
        return true
    elseif table.contains(openDoors, itemId) or table.contains(openExtraDoors, itemId) or table.contains(openHouseDoors, itemId) then
        local creaturePositionTable = {}
        local doorCreatures = Tile(toPosition):getCreatures()
        if doorCreatures and #doorCreatures > 0 then
            for _, doorCreature in pairs(doorCreatures) do
                local pushPosition = findPushPosition(doorCreature, 1)
                if not pushPosition then
                    player:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM)
                    return true
                end
                table.insert(creaturePositionTable, {creature = doorCreature, position = pushPosition})
            end
            for _, tableCreature in ipairs(creaturePositionTable) do
                tableCreature.creature:teleportTo(tableCreature.position, true)
            end
        end
   
        item:transform(itemId - 1)
        return true
    elseif table.contains(closedDoors, itemId) or table.contains(closedExtraDoors, itemId) or table.contains(closedHouseDoors, itemId) then
        item:transform(itemId + 1)
        return true
    end
    return false
end

local doorTables = {keys, openDoors, closedDoors, lockedDoors, openExtraDoors, closedExtraDoors, openHouseDoors, closedHouseDoors, closedQuestDoors, closedLevelDoors}
for _, doors in pairs(doorTables) do
    for _, doorId in pairs(doors) do
        door:id(doorId)
    end
end
door:register()

this is global.lua
Code:
ropeSpots = {
    384, 418, 8278, 8592, 13189, 14435, 14436, 14857, 15635, 19518, 24621, 24622, 24623, 24624, 26019
}

keys = {
    2086, 2087, 2088, 2089, 2090, 2091, 2092, 10032
}

openDoors = {
    1211, 1214, 1233, 1236, 1251, 1254, 3546, 3537, 4915, 4918, 5100, 5109, 5118, 5127, 5136, 5139, 5142,
    5145, 5280, 5283, 5734, 5737, 6194, 6197, 6251, 6254, 6893, 6902, 7035, 7044, 8543, 8546, 9167, 9170,
    9269, 9272, 10270, 10273, 10470, 10479, 10777, 10786, 12094, 12101, 12190, 12199, 19842, 19851, 19982,
    19991, 20275, 20284
}
closedDoors = {
    1210, 1213, 1232, 1235, 1250, 1253, 3536, 3545, 4914, 4917, 5099, 5108, 5117, 5126, 5135, 5138, 5141,
    5144, 5279, 5282, 5733, 5736, 6193, 6196, 6250, 6253, 6892, 6901, 7034, 7043, 8542, 8545, 9166, 9169,
    9268, 9271, 10269, 10272, 10766, 10785, 10469, 10478, 12093, 12100, 12189, 12198, 19841, 19850, 19981,
    19990, 20274, 20283
}
lockedDoors = {
    1209, 1212, 1231, 1234, 1249, 1252, 3535, 3544, 4913, 4916, 5098, 5107, 5116, 5125, 5134, 5137, 5140,
    5143, 5278, 5281, 5732, 5735, 6192, 6195, 6249, 6252, 6891, 6900, 7033, 7042, 8541, 8544, 9165, 9168,
    9267, 9270, 10268, 10271, 10468, 10477, 10775, 10784, 12092, 12099, 12188, 12197, 19840, 19849, 19980,
    19989, 20273, 20282
}

openExtraDoors = {
    1540, 1542, 6796, 6798, 6800, 6802, 7055, 7057, 13021, 13023, 17236, 17238, 25159, 25161
}
closedExtraDoors = {
    1539, 1541, 6795, 6797, 6799, 6801, 7054, 7056, 13020, 13022, 17235, 17237, 25158, 25160
}

openHouseDoors = {
    1220, 1222, 1238, 1240, 3539, 3548, 5083, 5085, 5102, 5111, 5120, 5129, 5285, 5287, 5516, 5518, 6199,
    6201, 6256, 6258, 6895, 6904, 7037, 7046, 8548, 8550, 9172, 9174, 9274, 9276, 10275, 10277, 10472, 10481,
    18209, 19844, 19853, 19984, 19993, 20277, 20286
}
closedHouseDoors = {
    1219, 1221, 1237, 1239, 3538, 3547, 5082, 5084, 5101, 5110, 5119, 5128, 5284, 5286, 5515, 5517, 6198,
    6200, 6255, 6257, 6894, 6903, 7036, 7045, 8547, 8549, 9171, 9173, 9273, 9275, 10274, 10276, 10471, 10480,
    18208, 19843, 19852, 19983, 19992, 20276, 20285
}

openQuestDoors = {
    1224, 1226, 1242, 1244, 1256, 1258, 3543, 3552, 5106, 5115, 5124, 5133, 5289, 5291, 5746, 5749, 6203,
    6205, 6260, 6262, 6899, 6908, 7041, 7050, 8552, 8554, 9176, 9178, 9278, 9280, 10279, 10281, 10476, 10485,
    10783, 10792, 12098, 12105, 12194, 12203, 19848, 19857, 19988, 19997, 20281, 20290, 25163, 25165
}

closedQuestDoors = {
    1223, 1225, 1241, 1243, 1255, 1257, 3542, 3551, 5105, 5114, 5123, 5132, 5288, 5290, 5745, 5748, 6202,
    6204, 6259, 6261, 6898, 6907, 7040, 7049, 8551, 8553, 9175, 9177, 9277, 9279, 10278, 10280, 10475, 10484,
    10782, 10791, 12097, 12104, 12193, 12202, 19847, 19856, 19987, 19996, 20280, 20289, 25162, 25164
}

openLevelDoors = {
    1228, 1230, 1246, 1248, 1260, 1262, 3541, 3550, 5104, 5113, 5122, 5131, 5293, 5295, 6207, 6209, 6264,
    6266, 6897, 6906, 7039, 7048, 8556, 8558, 9180, 9182, 9282, 9284, 10283, 10285, 10474, 10483, 10781,
    10790, 12096, 12103, 12196, 12205, 19846, 19855, 19986, 19995, 20279, 20288
}

closedLevelDoors = {
    1227, 1229, 1245, 1247, 1259, 1261, 3540, 3549, 5103, 5112, 5121, 5130, 5292, 5294, 6206, 6208, 6263,
    6265, 6896, 6905, 7038, 7047, 8555, 8557, 9179, 9181, 9281, 9283, 10282, 10284, 10473, 10482, 10780,
    10789, 12095, 12102, 12195, 12204, 19845, 19854, 19985, 19994, 20278--, --20287
}


 
Last edited:
There should be a movement script that registered a movement action to all Open quest doors and all open level doors to close then onStepOut

Check your movements scripts?

Lua Script Error: [Scripts Interface]
C:\Users\felip\Desktop\TFS-8.0-7.72 otb-RPG\data\scripts\movements\closing_door.lua
...8.0-7.72 otb-RPG\data\scripts\movements\closing_door.lua:36: bad argument #1 to 'ipairs' (table expected, got nil)
stack traceback:
[C]: at 0x7ff7b15d27b0
[C]: in function 'ipairs'
...8.0-7.72 otb-RPG\data\scripts\movements\closing_door.lua:36: in main chunk
closing_door.lua [error]
Solved i had the table disabled at global.lua
thank you @pink_panther
 
Last edited:
Says table expected, got nil, as in openLevelDoors is not defined

You should you have that stuff registered in global.lua? Its saying it can't find your list of openLevelDoors

OR check for any other errors on server startup to see if something else is failing to load
 
Says table expected, got nil, as in openLevelDoors is not defined

You should you have that stuff registered in global.lua? Its saying it can't find your list of openLevelDoors

OR check for any other errors on server startup to see if something else is failing to load
yes i forgot it that was the problem
 
Pushing direction in not sure...

A Simple way would be to sort all the regular doors in toedoor that are vertical or horizontal
then just change the push function to always push east on verical doors and south on horizontal doors for 7.4

7.5+ doors will push east or west for veritcal doors and south or north for horizontal doors. It uses the other direction of the path is blocked, so

Lua:
local verticalDoors = {
    [1643] = 1642,
    [1647] = 1646,
    [1661] = 1660,
    [1665] = 1664,
    [1675] = 1674,
    [1679] = 1678,
    [1697] = 1696,
    [1699] = 1698,
}

local horizontalDoors = {
    [1645] = 1644,
    [1649] = 1648,
    [1663] = 1662,
    [1667] = 1666,
    [1677] = 1676,
    [1681] = 1680,
    [1688] = 1687,
    [1690] = 1689,
}

function onStepOut(creature, item, fromPosition, toPosition)
    local door = verticalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(1, 0, 0))
        item:transform(door)
        item:decay()
        return true
    end
    
    door = horizontalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(0, 1, 0))
        item:transform(door)
        item:decay()
        return true
    end
end
 
Pushing direction in not sure...

A Simple way would be to sort all the regular doors in toedoor that are vertical or horizontal
then just change the push function to always push east on verical doors and south on horizontal doors for 7.4

7.5+ doors will push east or west for veritcal doors and south or north for horizontal doors. It uses the other direction of the path is blocked, so

Lua:
local verticalDoors = {
    [1643] = 1642,
    [1647] = 1646,
    [1661] = 1660,
    [1665] = 1664,
    [1675] = 1674,
    [1679] = 1678,
    [1697] = 1696,
    [1699] = 1698,
}

local horizontalDoors = {
    [1645] = 1644,
    [1649] = 1648,
    [1663] = 1662,
    [1667] = 1666,
    [1677] = 1676,
    [1681] = 1680,
    [1688] = 1687,
    [1690] = 1689,
}

function onStepOut(creature, item, fromPosition, toPosition)
    local door = verticalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(1, 0, 0))
        item:transform(door)
        item:decay()
        return true
    end
 
    door = horizontalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(0, 1, 0))
        item:transform(door)
        item:decay()
        return true
    end
end
created an script inside /data/scripts/movements and it does not give me errors but it does not work either
Lua:
local verticalHorizontalDoors = MoveEvent()
verticalHorizontalDoors:type("stepout")
local verticalDoors = {
    [1643] = 1642,
    [1647] = 1646,
    [1661] = 1660,
    [1665] = 1664,
    [1675] = 1674,
    [1679] = 1678,
    [1697] = 1696,
    [1699] = 1698,
}

local horizontalDoors = {
    [1645] = 1644,
    [1649] = 1648,
    [1663] = 1662,
    [1667] = 1666,
    [1677] = 1676,
    [1681] = 1680,
    [1688] = 1687,
    [1690] = 1689,
}

--function onStepOut(creature, item, fromPosition, toPosition)
function verticalHorizontalDoors.onStepOut(creature, item, position, fromPosition)
    local door = verticalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(1, 0, 0))
        item:transform(door)
        item:decay()
        return true
    end
   
    door = horizontalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(0, 1, 0))
        item:transform(door)
        item:decay()
        return true
    end
end

verticalHorizontalDoors:register()
my bad this is the script i changed the ids but is not working either
Lua:
local verticalHorizontalDoors = MoveEvent()
verticalHorizontalDoors:type("stepout")
local verticalDoors = {
    [1210] = 1211,
    [1647] = 1646,
    [1661] = 1660,
    [1665] = 1664,
    [1675] = 1674,
    [1679] = 1678,
    [1697] = 1696,
    [1699] = 1698,
}

local horizontalDoors = {
    [1213] = 1214,
    [1649] = 1648,
    [1663] = 1662,
    [1667] = 1666,
    [1677] = 1676,
    [1681] = 1680,
    [1688] = 1687,
    [1690] = 1689,
}

--function onStepOut(creature, item, fromPosition, toPosition)
function verticalHorizontalDoors.onStepOut(creature, item, position, fromPosition)
    local door = verticalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(1, 0, 0))
        item:transform(door)
        item:decay()
        return true
    end
    
    door = horizontalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(0, 1, 0))
        item:transform(door)
        item:decay()
        return true
    end
end

verticalHorizontalDoors:register()
 
Last edited:
register id's missing
but for
Lua:
local verticalDoors = {
    [1210] = 1211,
and
Code:
local horizontalDoors = {
    [1213] = 1214,
the script is not giving errors but not working the doors giving problem are the horizontal not the vertical
Lua:
local verticalHorizontalDoors = MoveEvent()
verticalHorizontalDoors:type("stepout")
local verticalDoors = {
    [1210] = 1211,
}

local horizontalDoors = {
    [1213] = 1214,
}

--function onStepOut(creature, item, fromPosition, toPosition)
function verticalHorizontalDoors.onStepOut(creature, item, position, fromPosition)
    local door = verticalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(1, 0, 0))
        item:transform(door)
        item:decay()
        return true
    end
    
    door = horizontalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(0, 1, 0))
        item:transform(door)
        item:decay()
        return true
    end
end

verticalHorizontalDoors:register()
 
The script is an old one, goes under data\movements, not the newer data\scripts\moevements

need to register the ids too in movements xml
i disabled the script from revscripts
Code:
 #vertical_horizontal_doors.lua [disabled]
there are no errors in console while using the script
Code:
The Forgotten Server - Version 1.5 (8.00 downgrade)

Compiled with Microsoft Visual C++ version 1933
Compiled on Nov 19 2022 18:10:48 for platform x64
Linked with LuaJIT 2.1.0-beta3 for Lua support

A server downgraded by Nekiro
Visit our forum for updates, support, and resources: https://otland.net/.

>> Loading config
>> Establishing database connection... MySQL 3.3.1
>> Running database manager
>> Loading vocations
>> Loading items... OTB v1.3.50
>> Loading script systems
>> Using LuaJIT 2.1.0-beta3
>> Loading lua libs
> create_functions.lua [loaded]
> defaults_move_event.lua [loaded]
> event_callbacks.lua [loaded]
> helper_constructors.lua [loaded]
> register_monster_type.lua [loaded]
>> Loading lua scripts
> #dqh_walls.lua [disabled]
> #multiple_lever.lua [disabled]
> #onstep_in_out_tile.lua [disabled]
> #change_gold.lua [disabled]
> #dolls.lua [disabled]
> #spellbook.lua [disabled]
> #transforms.lua [disabled]
> #voodoo_doll.lua [disabled]
> #gold_converter.lua [disabled]
> #saw.lua [disabled]
> #default_onDropLoot  original.lua [disabled]
> #vertical_horizontal_doors.lua [disabled]
> #example.lua [disabled]
> #example.lua [disabled]
>> ["others"]
> change_gold.lua [loaded]
> dolls.lua [loaded]
> doors.lua [loaded]
> voodoo_doll.lua [loaded]
>> ["creaturescripts"]
> scarab_death.lua [loaded]
>> ["monster"]
> default_onDropLoot.lua [loaded]
>> ["player"]
> default_onLook.lua [loaded]
> default_onLookInBattleList.lua [loaded]
> default_onMoveItem.lua [loaded]
> default_onReportBug.lua [loaded]
> default_onReportRuleViolation.lua [loaded]
>> ["movements"]
> closing_door.lua [loaded]
>> ["scripts"]
> onlosspremium.lua [loaded]
>> ["talkactions"]
> position.lua [loaded]
>> Loading monsters
>> Loading lua monsters
>> Loading outfits
>> Checking world type... PVP
>> Loading map
> Map size: 33500x33500.
> Map loading time: 2.319 seconds.
> Loaded house items in: 0.006 s
>> Initializing gamestate
>> Loaded all modules, server starting up...
>> Forgotten Server Online!

GM Ratx has logged in.
movements.xml
XML:
        <!-- vertical doors -->
        <movevent event="StepOut" itemid="1210" script="vertical_horizontal_doors.lua"/>
    <movevent event="StepOut" itemid="1211" script="vertical_horizontal_doors.lua"/>
    <!-- horizontal doors -->
        <movevent event="StepOut" itemid="1213" script="vertical_horizontal_doors.lua"/>
    <movevent event="StepOut" itemid="1214" script="vertical_horizontal_doors.lua"/>
    <movevent event="StepOut" script="vertical_horizontal_doors.lua" /><!--doors fix-->
    <!-- Switch Tiles -->
Lua:
local verticalDoors = {
    [1210] = 1211,
}

local horizontalDoors = {
    [1213] = 1214,
}
function onStepOut(creature, item, fromPosition, toPosition)
    local door = verticalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(1, 0, 0))
        item:transform(door)
        item:decay()
        return true
    end
   
    door = horizontalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(0, 1, 0))
        item:transform(door)
        item:decay()
        return true
    end
end
what might be missing?
 
Is it firing at all?

Put print("Door onStepOut") at the top of this function function onStepOut(creature, item, fromPosition, toPosition)

then see if it prints anytthing in the console when you use the doors, if it doesn't somethings not regiustered properly.

If it does, but the doors dont do anyhting, after that try print(door) after line 9 and see if it is finding the door id
 
Is it firing at all?

Put print("Door onStepOut") at the top of this function function onStepOut(creature, item, fromPosition, toPosition)

then see if it prints anytthing in the console when you use the doors, if it doesn't somethings not regiustered properly.

If it does, but the doors dont do anyhting, after that try print(door) after line 9 and see if it is finding the door id
nope is not firing at all
Lua:
local verticalDoors = {
    [1210] = 1211,
}

local horizontalDoors = {
    [1213] = 1214,
}
print("Door onStepOut")
function onStepOut(creature, item, fromPosition, toPosition)
    local door = verticalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(1, 0, 0))
        item:transform(door)
        item:decay()
        return true
    end
 
    door = horizontalDoors[item:getId()]
    if door then
        doRelocate(item:getPosition(), item:getPosition():moveRel(0, 1, 0))
        item:transform(door)
        item:decay()
        return true
    end
Code:
        <!-- vertical doors -->
        <movevent event="StepOut" itemid="1210" script="vertical_horizontal_doors.lua"/>
    <movevent event="StepOut" itemid="1211" script="vertical_horizontal_doors.lua"/>
    <!-- horizontal doors -->
        <movevent event="StepOut" itemid="1213" script="vertical_horizontal_doors.lua"/>
    <movevent event="StepOut" itemid="1214" script="vertical_horizontal_doors.lua"/>
    <movevent event="StepOut" script="vertical_horizontal_doors.lua" /><!--doors fix-->
    <!-- Switch Tiles -->
and nothing appears on console if i use a door but by some reason the console is displaying onstepout door like 8 times
Code:
The Forgotten Server - Version 1.5 (8.00 downgrade)

Compiled with Microsoft Visual C++ version 1933
Compiled on Nov 19 2022 18:10:48 for platform x64
Linked with LuaJIT 2.1.0-beta3 for Lua support

A server downgraded by Nekiro
Visit our forum for updates, support, and resources: https://otland.net/.

>> Loading config
>> Establishing database connection... MySQL 3.3.1
>> Running database manager
>> Loading vocations
>> Loading items... OTB v1.3.50
[Warning - Items::parseItemNode] Unknown shootType: demonicarrow
[Warning - Items::parseItemNode] Unknown shootType: energycarrow
[Warning - Items::parseItemNode] Unknown shootType: blessedbolt
[Warning - Items::parseItemNode] Unknown shootType: zaoanspear
[Warning - Items::parseItemNode] Unknown shootType: nordicspear
[Warning - Items::parseItemNode] Unknown shootType: patinabolt
[Warning - Items::parseItemNode] Unknown shootType: blessedarrow
[Warning - Items::parseItemNode] Unknown shootType: spinalarrow
[Warning - Items::parseItemNode] Unknown shootType: calcocitabolt
[Warning - Items::parseItemNode] Unknown shootType: patinaarrow
>> Loading script systems
>> Using LuaJIT 2.1.0-beta3
>> Loading lua libs
> create_functions.lua [loaded]
> defaults_move_event.lua [loaded]
> event_callbacks.lua [loaded]
> helper_constructors.lua [loaded]
> register_monster_type.lua [loaded]
Door onStepOut
Door onStepOut
Door onStepOut
Door onStepOut
Door onStepOut
Door onStepOut
Door onStepOut
Door onStepOut
Door onStepOut
Door onStepOut
>> Loading lua scripts
> #dqh_walls.lua [disabled]
> #multiple_lever.lua [disabled]
> #onstep_in_out_tile.lua [disabled]
> #vertical_horizontal_doors.lua [disabled]
> #change_gold.lua [disabled]
> #dolls.lua [disabled]
> #spellbook.lua [disabled]
> #transforms.lua [disabled]
> #voodoo_doll.lua [disabled]
> #gold_converter.lua [disabled]
> #saw.lua [disabled]
> #default_onDropLoot  original.lua [disabled]
> #example.lua [disabled]
> #example.lua [disabled]
>> ["others"]
> change_gold.lua [loaded]
> dolls.lua [loaded]
> doors.lua [loaded]
> voodoo_doll.lua [loaded]
>> ["creaturescripts"]
> scarab_death.lua [loaded]
>> ["monster"]
> default_onDropLoot.lua [loaded]
>> ["player"]
> default_onLook.lua [loaded]
> default_onLookInBattleList.lua [loaded]
> default_onMoveItem.lua [loaded]
> default_onReportBug.lua [loaded]
> default_onReportRuleViolation.lua [loaded]
>> ["movements"]
> closing_door.lua [loaded]
>> ["scripts"]
> onlosspremium.lua [loaded]
>> ["talkactions"]
> position.lua [loaded]
>> Loading monsters
>> Loading lua monsters
>> Loading outfits
>> Checking world type... PVP
>> Loading map
> Map size: 33500x33500.
> Map loading time: 2.345 seconds.
[Warning - Monsters::loadMonster] Cant load spell. data/monster/bosses/mahrdis.xml
> Loaded house items in: 0.007 s
>> Initializing gamestate
>> Loaded all modules, server starting up...
>> Forgotten Server Online!

ahh i noticed that i get this error
Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/vertical_horizontal_doors.lua:onStepOut
data/movements/scripts/vertical_horizontal_doors.lua:13: attempt to call method 'moveRel' (a nil value)
stack traceback:
        [C]: in function 'moveRel'
        data/movements/scripts/vertical_horizontal_doors.lua:13: in function <data/movements/scripts/vertical_horizontal_doors.lua:10>
        [C]: in function 'teleportTo'
        data/events/scripts/player.lua:84: in function <data/events/scripts/player.lua:79>
Post automatically merged:

change this
Lua:
--function Player:onTurn(direction)
  --  if self:getDirection() == direction and self:getGroup():getAccess() then
      --  local nextPosition = self:getPosition()
    --    nextPosition:getNextPosition(direction)

        --self:teleportTo(nextPosition, true)
    --end
    --return true
--end
to this
function Player:eek:nTradeRequest(target, item)
if hasEventCallback(EVENT_CALLBACK_ONTRADEREQUEST) then
return EventCallback(EVENT_CALLBACK_ONTRADEREQUEST, self, target, item)
end
return true
end
in data/events/player.lua now it does not gives error in console, but it's not working either
 
Last edited:
this is my door.lua
Lua:
local door = Action()

function door.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local itemId = item:getId()
    if table.contains(closedQuestDoors, itemId) then
        if player:getStorageValue(item.actionid) ~= -1 or player:getGroup():getAccess() then
            item:transform(itemId + 1)
            player:teleportTo(toPosition, true)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The door seems to be sealed against unwanted intruders.")
        end
        return true
    elseif table.contains(closedLevelDoors, itemId) then
        if item.actionid > 0 and player:getLevel() >= item.actionid - actionIds.levelDoor or player:getGroup():getAccess() then
            item:transform(itemId + 1)
            player:teleportTo(toPosition, true)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Only the worthy may pass.")
        end
        return true
    elseif table.contains(keys, itemId) then
        local tile = Tile(toPosition)
        if not tile then
            return false
        end
        target = tile:getTopVisibleThing()
        if target.actionid == 0 then
            return false
        end
        if table.contains(keys, target.itemid) then
            return false
        end
        if not table.contains(openDoors, target.itemid) and not table.contains(closedDoors, target.itemid) and not table.contains(lockedDoors, target.itemid) then
            return false
        end
        if item.actionid ~= target.actionid then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "The key does not match.")
            return true
        end
        local transformTo = target.itemid + 2
        if table.contains(openDoors, target.itemid) then
            transformTo = target.itemid - 2
        elseif table.contains(closedDoors, target.itemid) then
            transformTo = target.itemid - 1
        end
        target:transform(transformTo)
        return true
    elseif table.contains(lockedDoors, itemId) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It is locked.")
        return true
    elseif table.contains(openDoors, itemId) or table.contains(openExtraDoors, itemId) or table.contains(openHouseDoors, itemId) then
       local doorCreature = Tile(toPosition):getTopCreature()
        if doorCreature then
            toPosition.x = toPosition.x + 1
            doorCreature:teleportTo(toPosition, true)
        end
    
        item:transform(itemId - 1)
        return true
    elseif table.contains(closedDoors, itemId) or table.contains(closedExtraDoors, itemId) or table.contains(closedHouseDoors, itemId) then
        item:transform(itemId + 1)
        return true
    end
    return false
end

local doorTables = {keys, openDoors, closedDoors, lockedDoors, openExtraDoors, closedExtraDoors, openHouseDoors, closedHouseDoors, closedQuestDoors, closedLevelDoors}
for _, doors in pairs(doorTables) do
    for _, doorId in pairs(doors) do
        door:id(doorId)
    end
end
door:register()
 
solved thanks to everyone who tried to help me
Lua:
solved removed offseftposition check and added this also a new table containing horizontaldoors inside doors.lua
Lua:
 elseif table.contains(horizontalDoors, itemId) then
        local horizontalDoors = Tile(toPosition):getTopCreature()
        if horizontalDoors then
            toPosition.y = toPosition.y + 1
            horizontalDoors:teleportTo(toPosition, true)
            end
 
Back
Top