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

Lua Doors script tfs 1.2

gubbo123

New Member
Joined
Aug 15, 2017
Messages
151
Solutions
1
Reaction score
3
This is my script, i'm trying to replicate the cipsoft door system, but i'm not succeeding i'm having difficulty with the logic and how to apply it in the script

Lua:
door = openHorizontalDoors[item:getId()]
    if door then
        local doorCreature = Tile(toPosition):getTopCreature()
        if doorCreature ~= nil then
            toPosition.x = toPosition.x + 1
            local query = Tile(toPosition):queryAdd(doorCreature, bit.bor(FLAG_IGNOREBLOCKCREATURE, FLAG_PATHFINDING))
            if query ~= RETURNVALUE_NOERROR then
                toPosition.x = toPosition.x - 1
                toPosition.y = toPosition.y + 1
                query = Tile(toPosition):queryAdd(doorCreature, bit.bor(FLAG_IGNOREBLOCKCREATURE, FLAG_PATHFINDING))
            end

            if query ~= RETURNVALUE_NOERROR then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, query)
                return true
            end

            doorCreature:teleportTo(toPosition, true)
        end
        item:transform(door, 1)
        item:decay()
    end

I recorded a video on the original server to better understand the mechanism, could someone help me with this? I've been trying for some time

Video

thank you very much in advance
 
This is my script, i'm trying to replicate the cipsoft door system, but i'm not succeeding i'm having difficulty with the logic and how to apply it in the script

Lua:
door = openHorizontalDoors[item:getId()]
    if door then
        local doorCreature = Tile(toPosition):getTopCreature()
        if doorCreature ~= nil then
            toPosition.x = toPosition.x + 1
            local query = Tile(toPosition):queryAdd(doorCreature, bit.bor(FLAG_IGNOREBLOCKCREATURE, FLAG_PATHFINDING))
            if query ~= RETURNVALUE_NOERROR then
                toPosition.x = toPosition.x - 1
                toPosition.y = toPosition.y + 1
                query = Tile(toPosition):queryAdd(doorCreature, bit.bor(FLAG_IGNOREBLOCKCREATURE, FLAG_PATHFINDING))
            end

            if query ~= RETURNVALUE_NOERROR then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, query)
                return true
            end

            doorCreature:teleportTo(toPosition, true)
        end
        item:transform(door, 1)
        item:decay()
    end

I recorded a video on the original server to better understand the mechanism, could someone help me with this? I've been trying for some time

Video

thank you very much in advance
Based on what's shown, it's coded to search for open tile in this order: EAST, SOUTH, WEST, NORTH
 
You could make it loop over each tile and search for empty walkable tiles, if no walkable tile is empty then push onto items. Search in the order Xikini said, it seems right.

The :isWalkable() method could be used for evaluating the tiles. Also :getItemCount could probably be used.

I think you also need to look for magic fields and avoid those if possible. Cip Tibia still works like that, right? Or did they change it so that the field got removed if a player got pushed onto it? 🤔 Can't remember. But I know that in the good old days, you had to use items, like in your video, to push people onto magic fields (and kill them without getting unjustified kills>: D )
 
Back
Top