• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Carpets

Sizaro

Advanced OT User
Joined
Aug 20, 2007
Messages
5,180
Solutions
5
Reaction score
232
Location
Sweden
GitHub
coldensjo
In rl tibia there are a new kind of furniture, carpets.
However, since they are always at the bottom they will go under immovable objects. How do I fix this?
I was thinking if it was possible to browse them with the browse tile feature but that didn't work. How do I make it possible to browse them? Is that only Tibia.dat changes?
If that's the case, how do I make it impossible to use them on top of things that are immovable.

nhMqce4.gif

hRB7fee.gif


XML:
    <action itemid="26087" script="carpets.lua"/><!--yalaha carpet-->
    <action itemid="26109" script="carpets.lua"/><!--yalaha carpet-->  
    <action itemid="26088" script="carpets.lua"/><!--white fur -->
    <action itemid="26110" script="carpets.lua"/><!--white fur -->
    <action itemid="26089" script="carpets.lua"/><!--bamboo mat -->
    <action itemid="26111" script="carpets.lua"/><!--bamboo mat -->
    <action itemid="26366" script="carpets.lua"/><!--azure carpet-->
    <action itemid="26372" script="carpets.lua"/><!--azure carpet-->
    <action itemid="26363" script="carpets.lua"/><!--crimson carpet-->
    <action itemid="26371" script="carpets.lua"/><!--crimson carpet-->
    <action itemid="26367" script="carpets.lua"/><!--emerald carpet-->
    <action itemid="26373" script="carpets.lua"/><!--emerald carpet-->
    <action itemid="26368" script="carpets.lua"/><!--light parquet -->
    <action itemid="26374" script="carpets.lua"/><!--light parquet -->
    <action itemid="26369" script="carpets.lua"/><!--dark parquet -->
    <action itemid="26375" script="carpets.lua"/><!--dark parquet -->
    <action itemid="26370" script="carpets.lua"/><!--marble floor-->
    <action itemid="26376" script="carpets.lua"/><!--marble floor-->
    <action itemid="27072" script="carpets.lua"/><!--flowery carpet-->
    <action itemid="27080" script="carpets.lua"/><!--flowery carpet-->
    <action itemid="27073" script="carpets.lua"/><!--colourful carpet-->
    <action itemid="27081" script="carpets.lua"/><!--colourful carpet-->
    <action itemid="27074" script="carpets.lua"/><!--striped carpet-->
    <action itemid="27082" script="carpets.lua"/><!--striped carpet-->
    <action itemid="27075" script="carpets.lua"/><!--fur carpet-->
    <action itemid="27083" script="carpets.lua"/><!--fur carpet-->
    <action itemid="27076" script="carpets.lua"/><!--diamond carpet-->
    <action itemid="27084" script="carpets.lua"/><!--diamond carpet-->
    <action itemid="27077" script="carpets.lua"/><!--patterned carpet-->
    <action itemid="27085" script="carpets.lua"/><!--patterned carpet-->
    <action itemid="27078" script="carpets.lua"/><!--night sky carpet-->
    <action itemid="27086" script="carpets.lua"/><!--night sky carpet-->
    <action itemid="27079" script="carpets.lua"/><!--star carpet-->
    <action itemid="27087" script="carpets.lua"/><!--star carpet-->

LUA:
local foldedCarpet = {
    [25393] = 25392,    --rift carpet
    [25392] = 25393,    --rift carpet
    [26192] = 26193,    --void carpet
    [26193] = 26192,    --void carpet
    [26087] = 26109,     --yalahahari carpet
    [26109] = 26087,     --yalahahari carpet
    [26088] = 26110,     --white fur carpet
    [26110] = 26088,     --white fur carpet
    [26089] = 26111,     --bamboo mat carpet
    [26111] = 26089,    --bamboo matr carpet
    [26371] = 26363,     --crimson carpet
    [26363] = 26371,     --crimson carpet
    [26366] = 26372,     --azure carpet
    [26372] = 26366,     --azure carpet
    [26367] = 26373,     --emerald carpet
    [26373] = 26367,    --emerald carpet
    [26368] = 26374,     --light parquet carpet
    [26374] = 26368,     --light parquet carpet
    [26369] = 26375,    --dark parquet carpet
    [26375] = 26369,     --dark parquet carpet
    [26370] = 26376,     --mable floor
    [26370] = 26376,     --marble floor
    [27072] = 27080,     --flowery carpet
    [27080] = 27072,     --flowery carpet
    [27073] = 27081,     --Colourful Carpet
    [27081] = 27073,     --Colourful Carpet
    [27074] = 27082,     --striped carpet
    [27082] = 27074,     --striped carpet
    [27075] = 27083,    --fur carpet
    [27083] = 27075,    --fur carpet
    [27076] = 27084,     --diamond carpet
    [27084] = 27076,     --diamond carpet
    [27077] = 27085,     --patterned carpet
    [27085] = 27077,     --patterned carpet
    [27078] = 27086,     --night sky carpet
    [27086] = 27078,     --night sky carpet
    [27079] = 27087,     --star carpet
    [27087] = 27079     --star carpet
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local carpet = foldedCarpet[item.itemid]
    if not carpet then
    return false
end

    if fromPosition.x == CONTAINER_POSITION then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Put the item on the ground first.")
    elseif not fromPosition:getTile():getHouse() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You may only use this inside a house.")
    else
        item:transform(carpet)
    end
    return true
end
 
Code:
local tile = Tile(toPosition)
if tile then
    local tileItems = tile:getItems()
    if not table.contains(#tileItems, hasProperty(CONST_PROP_MOVEABLE)) then
        return false
    end
end

This should block using carpet where atleast one item is not moveable in the tile.
not tested.
 
Code:
local tile = Tile(toPosition)
if tile then
    local tileItems = tile:getItems()
    if not table.contains(#tileItems, hasProperty(CONST_PROP_MOVEABLE)) then
        return false
    end
end

This should block using carpet where atleast one item is not moveable in the tile.
not tested.
Wouldn't it be better to check whole tile by carpet id on use, so you could also have a carpet under this table?
 
Back
Top