From 043f6081452365daaa033c58e0738527ccb64c3d Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Sun, 11 May 2014 22:00:32 -0400 Subject: Move around some group code and make the craftguide render well without a recipe This also keeps recipes aligned to the right, close to the arrow. It also calculates the craft's height. --- api.lua | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'api.lua') diff --git a/api.lua b/api.lua index 29af43b..3314645 100644 --- a/api.lua +++ b/api.lua @@ -107,20 +107,29 @@ function unified_inventory.register_craft(options) table.insert(unified_inventory.crafts_table[itemstack:get_name()],options) end + local craft_type_defaults = { width = 3, height = 3, uses_crafting_grid = false, } -function unified_inventory.canonicalise_craft_type(name, options) - if not options.description then options.description = name end + + +function unified_inventory.craft_type_defaults(name, options) + if not options.description then + options.description = name + end setmetatable(options, {__index = craft_type_defaults}) return options end + + function unified_inventory.register_craft_type(name, options) - unified_inventory.registered_craft_types[name] = unified_inventory.canonicalise_craft_type(name, options) + unified_inventory.registered_craft_types[name] = + unified_inventory.craft_type_defaults(name, options) end + unified_inventory.register_craft_type("normal", { description = "Crafting", width = 3, @@ -128,6 +137,7 @@ unified_inventory.register_craft_type("normal", { uses_crafting_grid = true, }) + unified_inventory.register_craft_type("shapeless", { description = "Mixing", width = 3, @@ -135,26 +145,26 @@ unified_inventory.register_craft_type("shapeless", { uses_crafting_grid = true, }) + unified_inventory.register_craft_type("cooking", { description = "Cooking", width = 1, height = 1, }) + unified_inventory.register_craft_type("digging", { description = "Digging", width = 1, height = 1, }) -function unified_inventory.register_group_representative_item(groupname, itemname) - unified_inventory.registered_group_representative_items[groupname] = itemname -end function unified_inventory.register_page(name, def) unified_inventory.pages[name] = def end + function unified_inventory.register_button(name, def) if not def.action then def.action = function(player) @@ -165,9 +175,11 @@ function unified_inventory.register_button(name, def) table.insert(unified_inventory.buttons, def) end + function unified_inventory.is_creative(playername) if minetest.check_player_privs(playername, {creative=true}) or minetest.setting_getbool("creative_mode") then return true end end + -- cgit v1.2.3