mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-22 19:03:43 +01:00
Add assertions
This commit is contained in:
parent
4b97b08aa7
commit
4bca02f0db
15
init.lua
15
init.lua
@ -50,7 +50,16 @@ local function extract_groups(str)
|
||||
return str:sub(7):split(",")
|
||||
end
|
||||
|
||||
local function __func()
|
||||
return debug.getinfo(2, "n").name
|
||||
end
|
||||
|
||||
function craftguide.register_craft_type(name, def)
|
||||
local func = "craftguide." .. __func() .. "(): "
|
||||
assert(name, func .. "'name' field missing")
|
||||
assert(def.description, func .. "'description' field missing")
|
||||
assert(def.icon, func .. "'icon' field missing")
|
||||
|
||||
if not craftguide.craft_types[name] then
|
||||
craftguide.craft_types[name] = def
|
||||
end
|
||||
@ -62,6 +71,12 @@ craftguide.register_craft_type("digging", {
|
||||
})
|
||||
|
||||
function craftguide.register_craft(def)
|
||||
local func = "craftguide." .. __func() .. "(): "
|
||||
assert(def.type, func .. "'type' field missing")
|
||||
assert(def.width, func .. "'width' field missing")
|
||||
assert(def.output, func .. "'output' field missing")
|
||||
assert(def.items, func .. "'items' field missing")
|
||||
|
||||
craftguide.custom_crafts[#craftguide.custom_crafts + 1] = def
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user