I don't know what is wrong, if someone can help
when there is no more space (position) of this error
"Tile" returns like nil
tfs 1.2
Lua:
local storage = 5845
local config = {
first_room_pos = Position(33851, 28794, 8),
distX= 8,
distY= 3,
distZ= 1,
rX= 1,
rY= 1,
rZ= 2,
}
local function isBusyable(position)
local tile = Tile(position)
if not tile then
return false
end
local ground = tile:getGround()
if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
return false
end
local player = tile:getTopCreature()
if player then
if player:isPlayer() then
return false
end
end
local items = tile:getItems()
for i = 1, tile:getItemCount() do
local item = items[i]
local itemType = item:getType()
if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
return false
end
end
return true
end
local function addTrainers(position, arrayPos)
if not isBusyable(position) then
for places = 1, #arrayPos do
local trainer = Tile(arrayPos[places]):getTopCreature()
if not trainer then
local monster = Game.createMonster("Target", arrayPos[places])
monster:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
end
end
end
local function calculatingRoom(uid, position, coluna, linha, andar)
local player = Player(uid)
if coluna >= config.rX then
coluna = 0
linha = linha <= (config.rY) and linha + 1 or false
if not linha then
linha = 0
andar = andar <= (config.rZ) and andar - 1 or false
end
end
if andar then
local room_pos = {x = position.x + (coluna * config.distX), y = position.y + (linha * config.distY), z = position.z + (andar * config.distZ)}
if isBusyable(room_pos) then
player:teleportTo(room_pos)
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
addTrainers(room_pos, {{x = room_pos.x - 1, y = room_pos.y + 1, z = room_pos.z}, {x = room_pos.x + 1 , y = room_pos.y + 1, z = room_pos.z}})
else
calculatingRoom(uid, position, coluna + 1, linha, andar)
end
else
player:sendCancelMessage("Couldn't find any position for you right now.")
player:teleportTo(Position(32369, 32241, 7))
end
end
function onStepIn(creature, item, position, fromPosition)
if not creature:isPlayer() then
return false
end
print(tile)
if creature:getStorageValue(storage) - os.time() > 0 then
creature:sendTextMessage(MESSAGE_INFO_DESCR, "You gotta wait a few seconds before you can enter trainning room again")
creature:teleportTo(fromPosition, true)
return true
end
calculatingRoom(creature.uid, config.first_room_pos, 0, 0, 0)
return true
end
Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/Novos/trainer_entrar.lua:onStepIn
data/movements/scripts/Novos/trainer_entrar.lua:14: stack overflow
stack traceback:
[C]: in function 'Tile'
data/movements/scripts/Novos/trainer_entrar.lua:14: in function 'isBusyable'
data/movements/scripts/Novos/trainer_entrar.lua:68: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
...
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:73: in function 'calculatingRoom'
data/movements/scripts/Novos/trainer_entrar.lua:92: in function <data/movements/scripts/Novos/trainer_entrar.lua:81>
tfs 1.2