For some reason functions addMonster and getTiles are not working for me as supposed to do.
Here is a small example code:
module(...)
local C = require("classic")
local M = require("menu")
local thelayout = nil
local mapwidth = 0
local mapheight = 0
function getlayout()
if thelayout == nil then
thelayout = C.Dsetup.layout.func()
mapwidth = (thelayout.width * 12) + thelayout.width + 1
mapheight = (thelayout.height * 12) + thelayout.height + 1
end
end
spawn_item = {
id = "spawn-bat",
text = "Spawn",
choice_min = 1,
choice_max = 1,
features = function(S)
getlayout()
kts.SetRespawnFunction(spawn())
end
}
function spawn()
local pos = { x, y }
local xmax = mapwidth
local ymax = mapheight
print("Spawn begin!")
for i=1,10000 do
pos.x = kts.RandomRange(0, xmax)
pos.y = kts.RandomRange(0, ymax)
cr = kts.AddMonster(pos, C.m_vampire_bat)
--print("x",pos.x,"y",pos.y)
if cr ~= nil then
print("A creature was added")
end
end
print("Spawn end!")
end
table.insert(kts.MENU.items, spawn_item)
but value, returned by kts.addMonster is always == nil. Similar situation was with getTiles (returns an empty array), used in a same way.
What I am doing wrong?