2021-07-11 16:07:54 +02:00
|
|
|
-- Localize globals
|
|
|
|
local getmetatable, AreaStore, ItemStack
|
2021-07-14 11:51:47 +02:00
|
|
|
= getmetatable, AreaStore, ItemStack
|
2021-07-11 16:07:54 +02:00
|
|
|
|
|
|
|
-- Metatable lookup for classes specified in lua_api.txt, section "Class reference"
|
|
|
|
local AreaStoreMT = getmetatable(AreaStore())
|
|
|
|
local ItemStackMT = getmetatable(ItemStack"")
|
|
|
|
local metatables = {
|
2021-07-14 11:51:47 +02:00
|
|
|
[AreaStoreMT] = {name = "AreaStore", method = AreaStoreMT.to_string},
|
|
|
|
[ItemStackMT] = {name = "ItemStack", method = ItemStackMT.to_table},
|
|
|
|
-- TODO expand
|
2021-07-11 16:07:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
(...).luon = modlib.luon.new{
|
2021-07-14 11:51:47 +02:00
|
|
|
aux_write = function(_, value)
|
|
|
|
local type = metatables[getmetatable(value)]
|
|
|
|
if type then
|
|
|
|
return type.name, type.method(value)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
aux_read = {
|
|
|
|
AreaStore = function(...)
|
|
|
|
local store = AreaStore()
|
|
|
|
store:from_string(...)
|
|
|
|
return store
|
|
|
|
end,
|
|
|
|
ItemStack = ItemStack
|
|
|
|
}
|
2021-07-11 16:07:54 +02:00
|
|
|
}
|