Do you just have a table several level deep or am I completely off base here?
Code: Select all
state = {
entities = {
player,
monster,
npc_a,
...
},
world = {
in_interior = false,
map = overworld,
...
},
stats = {
playtime = 127,
achievements = {
...
}
}
}
Code: Select all
define_type("complex", {
x = "number",
y = "number"
})
-- works
local c = new_t("complex")
c.x = 10
print(c.x)
-- does not work
c.x = "a" -- type error: type complex's x field is number but got string!
c.y = 10 -- type error: type complex doesn't have a z field!
print(c.y) -- type error: type complex doesn't have a z field!
Let me know if it's not clear what I'm asking.