The code below can be tested. You will see that the table is not correct when viewed inside ZeroBraneStudio but prints out correctly.
local dbg = require("builtins.scripts.mobdebug")
function init(self)
dbg.start()
local options = {
spawn_types = {
{animal_cat = 2},
{animal_dog = 2},
{animal_fish = 2},
{object_crate = 1},
{object_dynamite = 1},
{object_chainsaw = 1}
}
}
local spawn_types = {}
local type_mapping = {
animal_cat = {class = hash("animal"), type = hash("cat")},
animal_dog = {class = hash("animal"), type = hash("dog")},
animal_fish = {class = hash("animal"), type = hash("fish")},
animal_giraffe = {class = hash("animal"), type = hash("giraffe")},
object_crate = {class = hash("object"), type = hash("crate")},
object_dynamite = {class = hash("object"), type = hash("dynamite")},
object_chainsaw = {class = hash("object"), type = hash("chainsaw")}
}
local class
local type
local spawn_type
for k, v in pairs(options.spawn_types) do
for class_type, ratio in pairs(v) do
class = type_mapping[class_type].class
type = type_mapping[class_type].type
spawn_type = {class = class, type = type, ratio = ratio}
spawn_types[k] = spawn_type
end
end
print("Level can spawn:")
pprint(spawn_types) --break here and look at spawn_types in ZeroBraneStudio
end