forked from minetest-mods/unified_inventory
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.
This commit is contained in:
24
api.lua
24
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
|
||||
|
||||
|
Reference in New Issue
Block a user