diff options
author | ShadowNinja <shadowninja@minetest.net> | 2014-05-11 22:00:32 -0400 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2014-05-11 22:00:32 -0400 |
commit | 043f6081452365daaa033c58e0738527ccb64c3d (patch) | |
tree | c7b586f1b42be2973425bf0d6911a072f2beb478 /api.lua | |
parent | ba956d683856f457edddaa9b9ad0c4b282bdefea (diff) |
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.
Diffstat (limited to 'api.lua')
-rw-r--r-- | api.lua | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -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 + |