• 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 doCleanTile not working as intended.

Xikini

I whore myself out for likes
Senator
Joined
Nov 17, 2010
Messages
6,828
Solutions
586
Reaction score
5,409
0.3.7

Whenever I restart server and attempt a simple wall break using "doCleanTile(pos[1])", it will not remove items that started on the map originally.

If I delete the wall and spawn it using my god it will then start to work normally.
Is there another command I should be using instead of doCleanTile?

Also, Another thing I can't seem to get to work is setting an actionID to a tile after using a lever or switch for instance.
Code:
addEvent(doSetItemActionId, time * 10010, config.actionID, pos[3])
When attempting to use this I get this error.
Code:
[19:3:56.648] [Error - Action Interface]
[19:3:56.649] In a timer event called from:
[19:3:56.649] data/actions/scripts/explosivebarrel.lua:onUse
[19:3:56.650] Description:
[19:3:56.650] (luaDoItemSetAttribute) Invalid data type
Thanks everyone in advance! I appreciate any comment/feedback/criticism/help that anyone offers.

Xikini

A small script that uses the function is below.
Code:
local time = 6
local config = {
   rock1 = 5622, -- rock 1 (left)
   rock2 = 5621, -- rock 2 (right)
   barrel = 8059, -- barrel
   actionID = 45151
}
local pos = {
   [1] = {x = 1536, y = 1499, z = 7}, -- rock 1 (left)
   [2] = {x = 1537, y = 1499, z = 7}, -- rock 2 (right)
   [3] = {x = 1533, y = 1500, z = 7}  -- barrel
   
}

function onUse(cid, item, frompos, item2, topos)
   if item.itemid == 8059 then -- if using correct item. (barrel)
       doCleanTile(pos[1])
       doCleanTile(pos[2])
       doCleanTile(pos[3])
       addEvent(doCreateItem,time * 10000, config.rock1, 1, pos[1])
       addEvent(doCreateItem,time * 10000, config.rock2, 1, pos[2])
       addEvent(doCreateItem,time * 10000, config.barrel, 1, pos[3])
       --addEvent(doSetItemActionId, time * 10010, config.actionID, pos[3])
   end
  return true
end
 
If I delete the wall and spawn it using my god it will then start to work normally.
If this is the case then the function is looking for the top most tile by default, maybe you need to include the stackpos?

Is there another command I should be using instead of doCleanTile?
These are not commands, they are called functions, a command is something entirely different.

I'm sure there is another "function" that could be used to remove the item, doesn't 0.3.7 have a function.lua file?

Check your docs or lib folder
 
Last edited:
If this is the case then the function is looking for the top most tile by default, maybe you need to include the stackpos?


These are not commands, they are called functions, a command is something entirely different.

I'm sure there is another "function" that could be used to remove the item, doesn't 0.3.7 have a function.lua file?

Check your docs or lib folder
The doCleanTile function works on any object that was not created by the map upon start-up.
I tried the stack position and it did not change that behaviour.

What we plan on doing.. is adding a global event which will add the walls/items upon start-up so that the scripts will run properly.
Can't really see another way.

Code:
local id = {  
   [1] = 2533,
   [2] = 2748,
   [3] = 3689,
   [4] = 2432
}

local pos = {
   [1] = {x = 1486, y = 1544, z = 7},
   [2] = {x = 1486, y = 1545, z = 7},
   [3] = {x = 1486, y = 1546, z = 7},
   [4] = {x = 1486, y = 1547, z = 7}
}

function onStartup()
   doCreateItem(id[1], 1, pos[1])
   doCreateItem(id[2], 1, pos[2])
   doCreateItem(id[3], 1, pos[3])
   doCreateItem(id[4], 1, pos[4])
   return true
end
 
Can't really see another way.
You haven't looked hard enough, in your root directory there is a doc folder which contains a file called LUA_FUNCTIONS this has all the functions for your server, I will name a few functions which can help you with this issue.

Some may seem irrelevant but actually aren't because I don't know your complete circumstances

Code:
LUA_FUNCTIONS

    getTileItemById(pos, itemId[, subType = -1])
    getTileItemsByType(pos, type)
    getTileThingByPos(pos)
    getTileInfo(pos)
    getTopCreature(pos)
    getClosestFreeTile(cid, targetpos[, extended = false[, ignoreHouse = true]])
    getThingFromPos(pos)
    getThing(uid)
    getThingPosition(uid)

    getItemProtection(uid)
    getItemDescriptionsById(itemid)

    getItemIdByName(name)

    doChangeTypeItem(uid, newtype)
    doDecayItem(uid)
    doRemoveItem(uid[, count = -1])
    doTransformItem(uid, toitemid[, count/subtype])

    isItemMovable(itemid)

    addEvent(callback, delay, ...)
    stopEvent(eventid)
 
It is not enough to just use tables, you have to learn how to cycle through those tables using loops.
Try this out see how it goes
Code:
local c = {
   item = {
        5622, -- rock 1 (left)
        5621 -- rock 2 (right)
        8059, -- barrel
    },
    -- get out of the habit of using reserved words as variable names
    time_ = 6, -- is suppose to be 6 seconds or 60 seconds? you had it set to 6 * 10k = 1 minute, seconds is 1000
    actionID = 45151,
    pos = {
        {x = 1536, y = 1499, z = 7}, -- rock 1 (left)
        {x = 1537, y = 1499, z = 7}, -- rock 2 (right)
        {x = 1533, y = 1500, z = 7}  -- barrel
    },
    itemToCheckFor = 8059,
    tile = {} -- this will be populated in the for loop inside onUse
}

function respawnItems(c) -- pass the whole table
    for i = 1, #c.pos do
        doCreateItem(c.item[i], 1, c.pos[i])
        if i == #c.pos then
            doSetItemActionId(c.tile, c.actionID)
        end
    end
end

-- you created a table, now you need to learn how to access it without being repetative
function onUse(cid, item, frompos, item2, topos)
    if item.itemid == c.itemToCheckFor then -- if using correct item. (barrel)
        for i = 1, #c.pos do -- index always starts at 1, unless specified otherwise
            if i == #c.pos then -- we have to put this 1st because if we remove it obviously there is no tile to get
                c.tile = getTileItemById(c.pos[i], c.item[i]).uid
            end
            doRemoveItem(getTileItemById(c.pos[i], c.item[i]).uid, 1)
        end
        addEvent(respawnItems, time_ * 1000, c) -- wait x amount of seconds to respawn the items
    end
  return true
end

This should really be
Code:
function respawnItems(c) -- pass the whole table
    for i = 1, #c.pos do
        if i == #c.pos then
            doSetItemActionId(doCreateItem(c.item[i], 1, c.pos[i]), c.actionID)
        else
            doCreateItem(c.item[i], 1, c.pos[i])
        end
    end
end
 
Last edited:
Back
Top