Merge pull request #9 from Treer/master
Support more item groups in recipes
This commit is contained in:
commit
cd7b2409ff
@ -9,16 +9,19 @@ minetest.register_craftitem("main:apple", {
|
||||
minetest.register_craftitem("main:stick", {
|
||||
description = "Stick",
|
||||
inventory_image = "stick.png",
|
||||
groups = {stick = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("main:coal", {
|
||||
description = "Coal",
|
||||
inventory_image = "coal.png",
|
||||
groups = {coal = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("main:charcoal", {
|
||||
description = "Charcoal",
|
||||
inventory_image = "charcoal.png",
|
||||
groups = {coal = 1}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("main:iron", {
|
||||
|
@ -16,7 +16,7 @@ end
|
||||
|
||||
|
||||
minetest.register_node("redstone:button_off", {
|
||||
description = "Crafting Table",
|
||||
description = "Button",
|
||||
tiles = {"stone.png"},
|
||||
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,dig_immediate=1},
|
||||
sounds = main.stoneSound(),
|
||||
@ -56,7 +56,7 @@ minetest.register_node("redstone:button_off", {
|
||||
on_destruct = on_button_destroy,
|
||||
})
|
||||
minetest.register_node("redstone:button_on", {
|
||||
description = "Crafting Table",
|
||||
description = "Button",
|
||||
tiles = {"stone.png"},
|
||||
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,dig_immediate=1},
|
||||
sounds = main.stoneSound(),
|
||||
|
@ -97,14 +97,26 @@ local recipe_converter = function (items, width)
|
||||
|
||||
return(usable_recipe)
|
||||
end
|
||||
|
||||
local map_group_to_item = {
|
||||
["coal"] = "main:coal",
|
||||
["glass"] = "main:glass",
|
||||
["sand"] = "main:sand",
|
||||
["stick"] = "main:stick",
|
||||
["stone"] = "main:cobble",
|
||||
["tree"] = "main:tree",
|
||||
["wood"] = "main:wood"
|
||||
}
|
||||
|
||||
get_if_group = function(item)
|
||||
if item == "group:stone" then
|
||||
return("main:cobble")
|
||||
elseif item == "group:wood" then
|
||||
return("main:wood")
|
||||
else
|
||||
return(item)
|
||||
if item ~= nil and item:sub(1,6) == "group:" then
|
||||
local group_name = item:sub(7, item:len())
|
||||
local mapped_item = map_group_to_item[group_name]
|
||||
if mapped_item ~= nil then
|
||||
return(mapped_item)
|
||||
end
|
||||
end
|
||||
return(item)
|
||||
end
|
||||
|
||||
|
||||
|
@ -179,14 +179,7 @@ minetest.register_node("torch:wall", {
|
||||
minetest.register_craft({
|
||||
output = "torch:torch 4",
|
||||
recipe = {
|
||||
{"main:coal"},
|
||||
{"main:stick"}
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "torch:torch 4",
|
||||
recipe = {
|
||||
{"main:charcoal"},
|
||||
{"main:stick"}
|
||||
{"group:coal"},
|
||||
{"group:stick"}
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user