• 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 Checking if the monster can be created.

Derex

New Member
Joined
Oct 10, 2010
Messages
24
Reaction score
2
Hey, I need to create square of monsters by command:
Code:
doCreateMonster(monster, spawnpoint, true)
but in this square some walls can exist or the ground can not exist and then I get the bug in my engine that the monster can't be summoned. How pass this bug? I looking for something like:
If "The monster cannot be sumoned" then
I'm using TFS 0.3.6.
Have any one idea how to do something like this?
Thanks.
 
Something like raid but like I said I only need help with this one problem. I won't full script because I like do something by my own because then i know what's going on the server, but thanks for willingness :)
 
u can do it with raids and write this >
monsters = {
[1] = {name = 'Rat', count = 32},
[2] = {name = 'Cave Rat', count = 12},
[3] = {name = 'Munster', count = 1}
},
extended = true,
position = {x = 32347, y = 32214, z = 7},
messages = {'Rat Plague in Thais!'}
},
 
u can do it with raids and write this >
monsters = {
[1] = {name = 'Rat', count = 32},
[2] = {name = 'Cave Rat', count = 12},
[3] = {name = 'Munster', count = 1}
},
extended = true,
position = {x = 32347, y = 32214, z = 7},
messages = {'Rat Plague in Thais!'}
},
u can change the name and the position "D and the city
name
 
Ahilphino, thanks! It had solved bug when the wall exist on the square but I still have a problem when the ground doesn't exist.
Megagaea, I'm using TFS 0.3.6.
 
Ahilphino, thanks! It had solved bug when the wall exist on the square but I still have a problem when the ground doesn't exist.
Megagaea, I'm using TFS 0.3.6.
Code:
     getTileInfo(pos)
     --this is its properties
     protection
     nopvp
     nologout
     pvp
     refresh
     trashed
     house
     bed
     depot
     things
     creatures
     items
     topItems
     downItems
     -- example
     getTileInfo(pos).downItems

Check your luascript.cpp to see if it has any additional properties

A possible way to check the tile is to create a table and a function to handle the properties of the position.
Code:
    local properties = {
        protection,
        nopvp,
        nologout,
        pvp,
        refresh,
        trashed,
        house,
        bed,
        depot,
        things,
        creatures,
        items,
        topItems,
        downItems
    }

    function positionAndPropertyCheck(pos, property)
        local t = {}
        if type(property) == "table" then
            for i in pairs(property) do
                if getTileInfo(pos).property[i] ~= nil then
                    t[#t+1] = property[i]
                else
                    t[#t+1] = false
                end
            end
        else
            if getTileInfo(pos).property ~= nil then
                    t[#t+1] = property
                else
                    t[#t+1] = false
                end
            end
        end
        return t
    end

local position = {x = 50, y = 50, z = 7}

-- some code here
local tempTable = {}

tempTable = positionAndPropertyCheck(position, properties)

Even if properties that is passed to the function is not a table it will still return a table. In theory :)

You can then use unpack() to export the contents based on the size of the table or just cycle through them.. just throwing ideas out there :p
 
Last edited:
Hey, I need to create square of monsters by command:
Code:
doCreateMonster(monster, spawnpoint, true)
but in this square some walls can exist or the ground can not exist and then I get the bug in my engine that the monster can't be summoned. How pass this bug? I looking for something like:
If "The monster cannot be sumoned" then
I'm using TFS 0.3.6.
Have any one idea how to do something like this?
Thanks.
Code:
doCreateMonster(monster, spawnpoint, true)
The 'true' in your original code is telling it to send the error to console for debugging.
If you set it to false the error's should stop appearing.
 
Back
Top