Lark created a cryogenic chamber that used a similar concept, here is his code so that you can see how he made this work:
Code: Select all
list = { --a list of all possible monsters to spawn randomly. Note: groups are not supported; one occupant per chamber, please!
"crab",
"crowern",
"goromorg",
"green_slime",
"herder",
"herder_big",
"herder_small",
"ogre",
"scavenger",
"shrakk_torr",
"skeleton_archer",
"skeleton_warrior",
"snail",
"spider",
"uggardian",
"warden",
"wyvern"}
--
--- Initial start - only runs once to spawn or detect initial occupant and to give it items randomly
--
if initial then
initial = false
if # monsters > 0 then
occupant = monsters[1]
else
if occupant == "random" then
if random_nil then local plus = 1 else plus = 0 end
occupant = list[math.random(1, # list + plus)]
end
if occupant ~= nil then
monster = spawn(occupant, self.level, self.x, self.y, self.facing)
monster:setLevel(rank)
monsters = findAll(self.level, self.x, self.y, {":setAIState"})
workable = findAll(self.level, self.x, self.y, {":addItem", ":setAIState"}, "all")
end
end
Stuff like initial and occupant are defined elsewhere in Lark's code, feel free to
check his stuff out here.
-Mark