• 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+ Fold carpets into backpack on command

Joriku

Working in the mines, need something?
Joined
Jul 16, 2016
Messages
1,085
Solutions
15
Reaction score
379
Location
Sweden
YouTube
Joriku
Is it possible to make a command that !folds the carpet from north of you into your backpack?


For example:

Carpet here ---
N = North
W = West
S = South
E = East
p = Player
the player looks north on a door which has a capret on it -- Look picture.
a29965013ad7c461f41f61e96d6d8a19.png

if the player types !fold the carpet on the door will come into the backpack from the spot north of the player. (North = The look position)

-- N
E- P-W
---S
 
Solution
Yep, now we're talking. :)

You can just remove all those lines from XML, uneccesary clutter.

And throw this into your /data/scripts folder:

carpets.lua
Lua:
-- List of carpets, and what they transform into when used
local foldedCarpet = {
    [25393] = 25392,
    [25392] = 25393, --rift carpet
    [26193] = 26192,
    [26192] = 26193, --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...
are you using another kind of client? why would you need a command if there is a wrap function inside client :p
I mean, can you explain?
 
Instead of bumping, do some research and tell us your findings.

You linked us the repo you use, OtservBR-Global, which is based on TFS 1.3. ok, fine.
But where is the code? Could you look into it, so we don't have to?

Have you tried to click on "Browse field" at the door, then select the carpet and see if you then can wrap/fold it?
 
Instead of bumping, do some research and tell us your findings.

You linked us the repo you use, OtservBR-Global, which is based on TFS 1.3. ok, fine.
But where is the code? Could you look into it, so we don't have to?

Have you tried to click on "Browse field" at the door, then select the carpet and see if you then can wrap/fold it?
Right..
The code doesn't exist yet. Trying to figure out how to do it myself but no progress so far more then onOuse.
I've tried everything in-game to get it up and it's not working, that's why iam turning to Otland for some help.
Usually in the posts I make I post all information I can give out on the post.
I'll see what I can find but right now I have nothing and no post on Otland about it.
 
Last edited by a moderator:
The existing "fold/unfold carpet" code should exist somewhere, right?

Is this C++, or Lua? Where is it?
Perhaps we can use that code as a reference when making the talkaction.
 
The existing "fold/unfold carpet" code should exist somewhere, right?

Is this C++, or Lua? Where is it?
Perhaps we can use that code as a reference when making the talkaction.
This?
actions.xml
XML:
<!-- Carpets -->
<action itemid="25392" script="others/carpets.lua"/> <!-- rift carpet-->
<action itemid="25393" script="others/carpets.lua"/> <!-- rift carpet-->
<action itemid="26192" script="others/carpets.lua"/> <!-- void carpet-->
<action itemid="26193" script="others/carpets.lua"/> <!-- void carpet-->
<action itemid="26087" script="others/carpets.lua"/> <!-- yalahar carpet-->
<action itemid="26109" script="others/carpets.lua"/> <!-- yalahar carpet-->
<action itemid="26088" script="others/carpets.lua"/> <!-- white fur -->
<action itemid="26110" script="others/carpets.lua"/> <!-- white fur -->
<action itemid="26089" script="others/carpets.lua"/> <!-- bamboo mat -->
<action itemid="26111" script="others/carpets.lua"/> <!-- bamboo mat -->
<action itemid="26366" script="others/carpets.lua"/> <!-- azure carpet -->
<action itemid="26372" script="others/carpets.lua"/> <!-- azure carpet -->
<action itemid="26363" script="others/carpets.lua"/> <!-- crimson carpet -->
<action itemid="26371" script="others/carpets.lua"/> <!-- crimson carpet -->
<action itemid="26367" script="others/carpets.lua"/> <!-- emerald carpet -->
<action itemid="26373" script="others/carpets.lua"/> <!-- emerald carpet -->
<action itemid="26368" script="others/carpets.lua"/> <!-- light parquet -->
<action itemid="26374" script="others/carpets.lua"/> <!-- light parquet -->
<action itemid="26369" script="others/carpets.lua"/> <!-- dark parquet -->
<action itemid="26375" script="others/carpets.lua"/> <!-- dark parquet -->
<action itemid="26370" script="others/carpets.lua"/> <!-- marble floor -->
<action itemid="26376" script="others/carpets.lua"/> <!-- marble floor -->
<action itemid="27084" script="others/carpets.lua"/> <!-- flowery carpet -->
<action itemid="27092" script="others/carpets.lua"/> <!-- flowery carpet -->
<action itemid="27085" script="others/carpets.lua"/> <!-- Colourful Carpet -->
<action itemid="27093" script="others/carpets.lua"/> <!-- Colourful Carpet -->
<action itemid="27086" script="others/carpets.lua"/> <!-- striped carpet -->
<action itemid="27094" script="others/carpets.lua"/> <!-- striped carpet -->
<action itemid="27087" script="others/carpets.lua"/> <!-- fur carpet -->
<action itemid="27095" script="others/carpets.lua"/> <!-- fur carpet -->
<action itemid="27088" script="others/carpets.lua"/> <!-- diamond carpet -->
<action itemid="27096" script="others/carpets.lua"/> <!-- diamond carpet -->
<action itemid="27089" script="others/carpets.lua"/> <!-- patterned carpet -->
<action itemid="27097" script="others/carpets.lua"/> <!-- patterned carpet -->
<action itemid="27090" script="others/carpets.lua"/> <!-- night sky carpet -->
<action itemid="27098" script="others/carpets.lua"/> <!-- night sky carpet -->
<action itemid="27091" script="others/carpets.lua"/> <!-- star carpet -->
<action itemid="27099" script="others/carpets.lua"/> <!-- star carpet -->
<action itemid="29349" script="others/carpets.lua"/> <!-- verdant carpet -->
<action itemid="29350" script="others/carpets.lua"/> <!-- verdant carpet -->
<action itemid="29351" script="others/carpets.lua"/> <!-- shaggy carpet -->
<action itemid="29352" script="others/carpets.lua"/> <!-- shaggy carpet -->
<action itemid="29353" script="others/carpets.lua"/> <!-- mystic carpet -->
<action itemid="29354" script="others/carpets.lua"/> <!-- mystic carpet -->
<action itemid="29355" script="others/carpets.lua"/> <!-- stone tile -->
<action itemid="29356" script="others/carpets.lua"/> <!-- stone tile -->
<action itemid="29357" script="others/carpets.lua"/> <!-- stone tile -->
<action itemid="29358" script="others/carpets.lua"/> <!-- wooden planks -->
<action itemid="29359" script="others/carpets.lua"/> <!-- wooden planks -->
<action itemid="29386" script="others/carpets.lua"/> <!-- wheat carpet -->
<action itemid="29387" script="others/carpets.lua"/> <!-- wheat carpet -->
<action itemid="29388" script="others/carpets.lua"/> <!-- crested carpet -->
<action itemid="29389" script="others/carpets.lua"/> <!-- crested carpet -->
<action itemid="29390" script="others/carpets.lua"/> <!-- decorated carpet -->
<action itemid="29391" script="others/carpets.lua"/> <!-- decorated carpet -->

carpets.lua
Lua:
local foldedCarpet = {
    [25393] = 25392,
    [25392] = 25393, --rift carpet
    [26193] = 26192,
    [26192] = 26193, --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
    [26376] = 26370, --marble floor
    [27084] = 27092, --flowery carpet
    [27092] = 27084, --flowery carpet
    [27085] = 27093, --Colourful Carpet
    [27093] = 27085, --Colourful Carpet
    [27086] = 27094, --striped carpet
    [27094] = 27086, --striped carpet
    [27087] = 27095, --fur carpet
    [27095] = 27087, --fur carpet
    [27088] = 27096, --diamond carpet
    [27096] = 27088, --diamond carpet
    [27089] = 27097, --patterned carpet
    [27097] = 27089, --patterned carpet
    [27090] = 27098, --night sky carpet
    [27098] = 27090, --night sky carpet
    [27091] = 27099, --star carpet
    [27099] = 27091, --star carpet
    [29350] = 29351, --verdant carpet
    [29351] = 29350, --verdant carpet
    [29352] = 29353, --shaggy carpet
    [29353] = 29352, --shaggy carpet
    [29355] = 29354, --mystic carpet
    [29354] = 29355, --mystic carpet
    [29356] = 29357, --stone tile
    [29357] = 29356, --stone tile
    [29359] = 29358, --wooden plank
    [29358] = 29359, --wooden plank
    [29386] = 29387, --wheat carpet
    [29387] = 29386, --wheat carpet
    [29388] = 29389, --crested carpet
    [29389] = 29388, --crested carpet
    [29390] = 29391, --decorated carpet
    [29391] = 29390, --decorated 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 floor first.")
    elseif not fromPosition:getTile():getHouse() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You may use this only inside a house.")
    else
        item:transform(carpet)
    end
    return true
end
 

Attachments

Yep, now we're talking. :)

You can just remove all those lines from XML, uneccesary clutter.

And throw this into your /data/scripts folder:

carpets.lua
Lua:
-- List of carpets, and what they transform into when used
local foldedCarpet = {
    [25393] = 25392,
    [25392] = 25393, --rift carpet
    [26193] = 26192,
    [26192] = 26193, --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
    [26376] = 26370, --marble floor
    [27084] = 27092, --flowery carpet
    [27092] = 27084, --flowery carpet
    [27085] = 27093, --Colourful Carpet
    [27093] = 27085, --Colourful Carpet
    [27086] = 27094, --striped carpet
    [27094] = 27086, --striped carpet
    [27087] = 27095, --fur carpet
    [27095] = 27087, --fur carpet
    [27088] = 27096, --diamond carpet
    [27096] = 27088, --diamond carpet
    [27089] = 27097, --patterned carpet
    [27097] = 27089, --patterned carpet
    [27090] = 27098, --night sky carpet
    [27098] = 27090, --night sky carpet
    [27091] = 27099, --star carpet
    [27099] = 27091, --star carpet
    [29350] = 29351, --verdant carpet
    [29351] = 29350, --verdant carpet
    [29352] = 29353, --shaggy carpet
    [29353] = 29352, --shaggy carpet
    [29355] = 29354, --mystic carpet
    [29354] = 29355, --mystic carpet
    [29356] = 29357, --stone tile
    [29357] = 29356, --stone tile
    [29359] = 29358, --wooden plank
    [29358] = 29359, --wooden plank
    [29386] = 29387, --wheat carpet
    [29387] = 29386, --wheat carpet
    [29388] = 29389, --crested carpet
    [29389] = 29388, --crested carpet
    [29390] = 29391, --decorated carpet
    [29391] = 29390 --decorated carpet
}

-- action converted to Revscriptsys
local action = Action()
-- Parse through carpets and register the itemids to the Action
for itemId, _ in pairs(foldedCarpet) do
    action:id(itemId)
end
-- Action onUse
function action.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 floor first.")
    elseif not fromPosition:getTile():getHouse() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You may use this only inside a house.")
    else
        item:transform(carpet)
    end
    return true
end
action:register()

-- Talkaction /fold
local talk_fold = TalkAction("!fold")
-- When player says talkaction command
function talk_fold.onSay(player, words, param)
    local tile = Tile(player:getPosition())
    local found = false
    -- Go through each item on tile player is standing on
    for i, item in pairs(tile:getItems()) do
        -- Is any of these items in the tile a carpet?
        local carpet = foldedCarpet[item.getId()] -- or item.itemid
        if carpet ~= nil then
            -- Transform it
            item:transform(carpet)
            found = true
        end
    end
    -- Inform user to stand on carpet if we found no carpet in his position.
    if not found then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Stand on top of carpet you want to fold/unfold.")
    end
    return true
end
talk:separator(" ")
talk:register()

Instead of messing about with calculation a players position based on his direction, figure out which tile is the relevant one, figure out if he has access to the house and all that, I simply made it so he has to stand on the same tile as the carpet is. Does that work for you?
 
Last edited:
Solution
Yep, now we're talking. :)

You can just remove all those lines from XML, uneccesary clutter.

And throw this into your /data/scripts folder:

carpets.lua
Lua:
-- List of carpets, and what they transform into when used
local foldedCarpet = {
    [25393] = 25392,
    [25392] = 25393, --rift carpet
    [26193] = 26192,
    [26192] = 26193, --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
    [26376] = 26370, --marble floor
    [27084] = 27092, --flowery carpet
    [27092] = 27084, --flowery carpet
    [27085] = 27093, --Colourful Carpet
    [27093] = 27085, --Colourful Carpet
    [27086] = 27094, --striped carpet
    [27094] = 27086, --striped carpet
    [27087] = 27095, --fur carpet
    [27095] = 27087, --fur carpet
    [27088] = 27096, --diamond carpet
    [27096] = 27088, --diamond carpet
    [27089] = 27097, --patterned carpet
    [27097] = 27089, --patterned carpet
    [27090] = 27098, --night sky carpet
    [27098] = 27090, --night sky carpet
    [27091] = 27099, --star carpet
    [27099] = 27091, --star carpet
    [29350] = 29351, --verdant carpet
    [29351] = 29350, --verdant carpet
    [29352] = 29353, --shaggy carpet
    [29353] = 29352, --shaggy carpet
    [29355] = 29354, --mystic carpet
    [29354] = 29355, --mystic carpet
    [29356] = 29357, --stone tile
    [29357] = 29356, --stone tile
    [29359] = 29358, --wooden plank
    [29358] = 29359, --wooden plank
    [29386] = 29387, --wheat carpet
    [29387] = 29386, --wheat carpet
    [29388] = 29389, --crested carpet
    [29389] = 29388, --crested carpet
    [29390] = 29391, --decorated carpet
    [29391] = 29390 --decorated carpet
}

-- action converted to Revscriptsys
local action = Action()
-- Parse through carpets and register the itemids to the Action
for itemId, _ in pairs(foldedCarpet) do
    action:id(itemId)
end
-- Action onUse
function action.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 floor first.")
    elseif not fromPosition:getTile():getHouse() then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "You may use this only inside a house.")
    else
        item:transform(carpet)
    end
    return true
end
action:register()

-- Talkaction /fold
local talk_fold = TalkAction("!fold")
-- When player says talkaction command
function talk_fold.onSay(player, words, param)
    local tile = Tile(player:getPosition())
    local found = false
    -- Go through each item on tile player is standing on
    for i, item in pairs(tile:getItems()) do
        -- Is any of these items in the tile a carpet?
        local carpet = foldedCarpet[item.getId()] -- or item.itemid
        if carpet ~= nil then
            -- Transform it
            item:transform(carpet)
            found = true
        end
    end
    -- Inform user to stand on carpet if we found no carpet in his position.
    if not found then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, "Stand on top of carpet you want to fold/unfold.")
    end
    return true
end
talk:separator(" ")
talk:register()

Instead of messing about with calculation a players position based on his direction, figure out which tile is the relevant one, figure out if he has access to the house and all that, I simply made it so he has to stand on the same tile as the carpet is. Does that work for you?
I'll try this whenever I manage to install Gesior.. this woun't even work to compleatley install the engine..
I would like it to be north of the player turn so that players could have carpets under tables in houses as an example.
 
I'll try this whenever I manage to install Gesior..
... Ever heard of Znote AAC? :p

this woun't even work to compleatley install the engine..
What? Your using TFS 1.3? It already supports Revscriptsys, and didnt you request this already?

I would like it to be north of the player turn so that players could have carpets under tables in houses as an example.
Hmm, good point. Well as a first step we should ensure/fix this script first, then we can easily adapt it to consider player lookdir and pick the position in front of the player.
 
Back
Top