• 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+ create tile on no ground tile 1.5

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
881
Solutions
7
Reaction score
122
Location
Brazil
YouTube
caruniawikibr
Hey guys, I'm trying to make the bridge do and undo when pulling levers, but it doesn't create the floor, the lever moves

Lua:
function onUse(cid, item, frompos, item2, topos)

gatepos1 = {x=32426, y=32201, z=14, stackpos=1}
getgate1 = getThingfromPos(gatepos1)
gatepos2 = {x=32426, y=32202, z=14, stackpos=1}
getgate2 = getThingfromPos(gatepos2)

switchpos1 = {x=32428, y=32198, z=14}
switchpos2 = {x=32428, y=32203, z=14}


    
if item.itemid == 1946 then   

doCreateItem(1284,1,gatepos1)
doCreateItem(1284,1,gatepos2)

doTransformItem(getTileItemById(switchpos1, 1946).uid,1945)
doTransformItem(getTileItemById(switchpos2, 1946).uid,1945)         

elseif item.itemid == 1945 then

doRemoveItem(1284,1,gatepos1)
doRemoveItem(1284,1,gatepos2)

doTransformItem(getTileItemById(switchpos1, 1945).uid,1946)
doTransformItem(getTileItemById(switchpos2, 1945).uid,1946)
      
else
doPlayerSendCancel(cid,"Sorry not possible.")
end
  return 1
  end

Screenshot_1.png
 

In short this is the solution :


Lua:
function Position:createItem(itemid, count)
    local toTile = Tile(self)
    if not toTile or not toTile:getItems() or not toTile:getGround() then
        doAreaCombatHealth(0, 0, self, 0, 0, 0, CONST_ME_NONE)
        Game.createItem(itemid, count, self)
    end
end
Then use it like pos:createItem(itemid, count).
Cred to @StreamSide
(Keep in mind that your positions need to look like this: Position({x,y,z})
 
Lua:
function Position:createItem(itemid, count)
    local toTile = Tile(self)
    if not toTile or not toTile:getItems() or not toTile:getGround() then
        doAreaCombatHealth(0, 0, self, 0, 0, 0, CONST_ME_NONE)
        Game.createItem(itemid, count, self)
    end
end

function onUse(cid, item, frompos, item2, topos)

    gatepos1 = Position({
        x = 32426,
        y = 32201,
        z = 14,
        stackpos = 1
    })
    getgate1 = getThingfromPos(gatepos1)
    gatepos2 = Position({
        x = 32426,
        y = 32202,
        z = 14,
        stackpos = 1
    })
    getgate2 = getThingfromPos(gatepos2)

    switchpos1 = {
        x = 32428,
        y = 32198,
        z = 14
    }
    switchpos2 = {
        x = 32428,
        y = 32203,
        z = 14
    }

    if item.itemid == 1946 then

        gatepos1:createItem(1284, 1)
        gatepos2:createItem(1284, 1)

        doTransformItem(getTileItemById(switchpos1, 1946).uid, 1945)
        doTransformItem(getTileItemById(switchpos2, 1946).uid, 1945)

    elseif item.itemid == 1945 then

        doRemoveItem(1284, 1, gatepos1)
        doRemoveItem(1284, 1, gatepos2)

        doTransformItem(getTileItemById(switchpos1, 1945).uid, 1946)
        doTransformItem(getTileItemById(switchpos2, 1945).uid, 1946)

    else
        doPlayerSendCancel(cid, "Sorry not possible.")
    end
    return 1
end
Something like this should do. Not tested tho.
 
same thing happened with my old script, no error appears, the 2 levers move but the floor is not created
Lua:
local switchBridge = Action()

local leverOn = 1946
local leverOff = 1945
local bridgeTile = 405

local bridgePos1 = Position({
    x = 1090,
    y = 1003,
    z = 8
})
local leverTile1 = Position({
    x = 1089,
    y = 1002,
    z = 8
})
local bridgePos2 = Position({
    x = 1091,
    y = 1003,
    z = 8
})
local leverTile2 = Position({
    x = 1092,
    y = 1004,
    z = 8
})

function Position:createItem(itemid, count)
    local toTile = Tile(self)
    if not toTile or not toTile:getItems() or not toTile:getGround() then
        doAreaCombatHealth(0, 0, self, 0, 0, 0, CONST_ME_NONE)
        Game.createItem(itemid, count, self)
    end
end

function switchBridge.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not player then
        return
    end

    if item.itemid == leverOff then
        Tile(leverTile1):getItemById(leverOff):transform(leverOn)
        Tile(leverTile2):getItemById(leverOff):transform(leverOn)
        bridgePos1:createItem(bridgeTile, 1)
        bridgePos2:createItem(bridgeTile, 1)
    else
        local bridgeTilePos1 = Tile(bridgePos1):getItemById(bridgeTile)
        local bridgeTilePos2 = Tile(bridgePos2):getItemById(bridgeTile)
        Tile(leverTile1):getItemById(leverOn):transform(leverOff)
        Tile(leverTile2):getItemById(leverOn):transform(leverOff)
        bridgeTilePos1:remove()
        bridgeTilePos2:remove()
    end
end

switchBridge:aid(32191)
switchBridge:register()

I'd do it like that if I did it for my server. You will have to check if there is a player on the bridge tho, so if there are one teleport him to one of the sides.
 
I've tried tapping here, but the script doesn't create objects in empty, null, or unfloored places. And way would be to use Game.loadMap and another problem would be some way to remove it when using lever again
 
bandicam 2023-03-21 13-27-09-835.gif

TFS 1x +
Lua:
local t = {
    Position(32426, 32201, 14),
    Position(32426, 32202, 14),
    Position(32427, 32201, 14),
    Position(32427, 32202, 14),
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
       
    if item.itemid == 1945 then
        t[1]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(22362, 1, t[1])  
        t[2]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(22362, 1, t[2])      
        t[3]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(22362, 1, t[3])      
        t[4]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(22362, 1, t[4])      
        t[1]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(1284, 1, t[1])
        t[2]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(1284, 1, t[2])
        t[3]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(1284, 1, t[3])
        t[4]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(1284, 1, t[4])
    end
   
    if item.itemid == 1946 then
        local tile = t[1]:getTile()
        if tile then
            local stone = tile:getItemById(1284)
            if stone then
                stone:remove()
                t[1]:sendMagicEffect(CONST_ME_POFF)
            end
        end

        local tile = t[2]:getTile()
        if tile then
            local stone = tile:getItemById(1284)
            if stone then
                stone:remove()
                t[2]:sendMagicEffect(CONST_ME_POFF)
            end
        end

        local tile = t[3]:getTile()
        if tile then
            local stone = tile:getItemById(1284)
            if stone then
                stone:remove()
                t[3]:sendMagicEffect(CONST_ME_POFF)
            end
        end
       
        local tile = t[4]:getTile()
        if tile then
            local stone = tile:getItemById(1284)
            if stone then
                stone:remove()
                t[4]:sendMagicEffect(CONST_ME_POFF)
            end
        end
end
    return item:transform(item.itemid == 1945 and 1946 or 1945)  
end


Edit: I had to create a non-sprite object as a floor, so I could create the bridge on top of this non-sprite object
 
Last edited:

Attachments

Last edited:
Can use my script as a guide.

add/remove/replace

 
Ohh, this is a revscript btw. So it should be located in data/scripts/actions not data/actions/scrips
Post automatically merged:

Oh and Im like gigga stupid. I used actionId's so you'll have to put actionid "32191" on the levers for mine to work.
 
Last edited:
Ohh, this is a revscript btw. So it should be located in data/scripts/actions not data/actions/scrips
Post automatically merged:

Oh and Im like gigga stupid. I used actionId's so you'll have to put actionid "32191" on the levers for mine to work.
it didn't work for me, I don't know if it's the version.
I keep trying
 
View attachment 74278

TFS 1x +
Lua:
local t = {
    Position(32426, 32201, 14),
    Position(32426, 32202, 14),
    Position(32427, 32201, 14),
    Position(32427, 32202, 14),
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
     
    if item.itemid == 1945 then
        t[1]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(22362, 1, t[1])
        t[2]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(22362, 1, t[2])    
        t[3]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(22362, 1, t[3])    
        t[4]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(22362, 1, t[4])    
        t[1]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(1284, 1, t[1])
        t[2]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(1284, 1, t[2])
        t[3]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(1284, 1, t[3])
        t[4]:sendMagicEffect(CONST_ME_POFF)
        Game.createItem(1284, 1, t[4])
    end
 
    if item.itemid == 1946 then
        local tile = t[1]:getTile()
        if tile then
            local stone = tile:getItemById(1284)
            if stone then
                stone:remove()
                t[1]:sendMagicEffect(CONST_ME_POFF)
            end
        end

        local tile = t[2]:getTile()
        if tile then
            local stone = tile:getItemById(1284)
            if stone then
                stone:remove()
                t[2]:sendMagicEffect(CONST_ME_POFF)
            end
        end

        local tile = t[3]:getTile()
        if tile then
            local stone = tile:getItemById(1284)
            if stone then
                stone:remove()
                t[3]:sendMagicEffect(CONST_ME_POFF)
            end
        end
     
        local tile = t[4]:getTile()
        if tile then
            local stone = tile:getItemById(1284)
            if stone then
                stone:remove()
                t[4]:sendMagicEffect(CONST_ME_POFF)
            end
        end
end
    return item:transform(item.itemid == 1945 and 1946 or 1945)
end


Edit: I had to create a non-sprite object as a floor, so I could create the bridge on top of this non-sprite object

i change line local tile = t[4]:getTile()
to local tile = t[4]:getTile(Position)
and work Constme Poff
but no create item
Post automatically merged:

Now Work, i chnge to scripts/action <3 ty so much u save me <3
 
Last edited:
i change line local tile = t[4]:getTile()
to local tile = t[4]:getTile(Position)
and work Constme Poff
but no create item
Post automatically merged:


Now Work, i chnge to scripts/action <3 ty so much u save me <3
Post script for me?
 
Lua:
local mintwalinswitch = Action()

local leverOn = 1945
local leverOff = 1946
local bridgeTile = 1284

local bridgePos1 = Position({
    x = 32426,
    y = 32201,
    z = 14
})
local bridgePos2 = Position({
    x = 32426,
    y = 32202,
    z = 14
})

local bridgePos3 = Position({
    x = 32427,
    y = 32201,
    z = 14
})
local bridgePos4 = Position({
    x = 32427,
    y = 32202,
    z = 14
})


local leverTile1 = Position({
    x = 32428,
    y = 32198,
    z = 14
})

local leverTile2 = Position({
    x = 32428,
    y = 32203,
    z = 14
})

function Position:createItem(itemid, count)
    local toTile = Tile(self)
    if not toTile or not toTile:getItems() or not toTile:getGround() then
        doAreaCombatHealth(0, 0, self, 0, 0, 0, CONST_ME_NONE)
        Game.createItem(itemid, count, self)
    end
end

function mintwalinswitch.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not player then
        return
    end

    if item.itemid == leverOff then
        Tile(leverTile1):getItemById(leverOff):transform(leverOn)
        Tile(leverTile2):getItemById(leverOff):transform(leverOn)
        bridgePos1:createItem(bridgeTile, 1)
        bridgePos2:createItem(bridgeTile, 1)
        bridgePos3:createItem(bridgeTile, 1)
        bridgePos4:createItem(bridgeTile, 1)
    else
        local bridgeTilePos1 = Tile(bridgePos1):getItemById(bridgeTile)
        local bridgeTilePos2 = Tile(bridgePos2):getItemById(bridgeTile)
        local bridgeTilePos3 = Tile(bridgePos3):getItemById(bridgeTile)
        local bridgeTilePos4 = Tile(bridgePos4):getItemById(bridgeTile)
        Tile(leverTile1):getItemById(leverOn):transform(leverOff)
        Tile(leverTile2):getItemById(leverOn):transform(leverOff)
        bridgeTilePos1:remove()
        bridgeTilePos2:remove()
        bridgeTilePos3:remove()
        bridgeTilePos4:remove()
    end
end

mintwalinswitch:aid(4127)
mintwalinswitch:register()
Post automatically merged:

unfortunately my otland account is bugged, i can't mark the answer solved.
 
Back
Top