hell/crafting.lua
2020-03-06 11:52:34 +01:00

254 lines
5.2 KiB
Lua

minetest.register_craft({
output = "hell:fim",
recipe = {
{"hell:shroom_head"},
{"hell:fruit_no_leaf"},
{"hell:shroom_head"},
}
})
minetest.register_craft({
output = "hell:fruit_leaves",
recipe = {
{"hell:fruit_leaf", "hell:fruit_leaf", "hell:fruit_leaf"},
{"hell:fruit_leaf", "hell:fruit_leaf", "hell:fruit_leaf"},
{"hell:fruit_leaf", "hell:fruit_leaf", "hell:fruit_leaf"},
}
})
minetest.register_craft({
output = "hell:pick_mushroom",
recipe = {
{"hell:shroom_head", "hell:shroom_head", "hell:shroom_head"},
{"", "hell:shroom_stem", ""},
{"", "hell:shroom_stem", ""},
}
})
minetest.register_craft({
output = "hell:pick_wood",
recipe = {
{"hell:wood_cooked", "hell:wood_cooked", "hell:wood_cooked"},
{"", "group:stick", ""},
{"", "group:stick", ""},
}
})
for _,m in pairs({"hellrack", "hellrack_blue", "white"}) do
local input = "hell:"..m
minetest.register_craft({
output = "hell:pick_"..m,
recipe = {
{input, input, input},
{"", "group:stick", ""},
{"", "group:stick", ""},
}
})
minetest.register_craft({
output = "hell:axe_"..m,
recipe = {
{input, input},
{input, "group:stick"},
{"", "group:stick"},
}
})
minetest.register_craft({
output = "hell:sword_"..m,
recipe = {
{input},
{input},
{"group:stick"},
}
})
minetest.register_craft({
output = "hell:shovel_"..m,
recipe = {
{input},
{"group:stick"},
{"group:stick"},
}
})
end
minetest.register_craft({
output = "hell:hellrack_brick 4",
recipe = {
{"hell:hellrack", "hell:hellrack"},
{"hell:hellrack", "hell:hellrack"},
}
})
minetest.register_craft({
output = "hell:hellrack_brick_black 4",
recipe = {
{"hell:hellrack_black", "hell:hellrack_black"},
{"hell:hellrack_black", "hell:hellrack_black"},
}
})
minetest.register_craft({
output = "hell:hellrack_brick_blue 4",
recipe = {
{"hell:hellrack_blue", "hell:hellrack_blue"},
{"hell:hellrack_blue", "hell:hellrack_blue"},
}
})
minetest.register_craft({
output = "default:furnace",
recipe = {
{"hell:hellrack_brick", "hell:hellrack_brick", "hell:hellrack_brick"},
{"hell:hellrack_brick", "", "hell:hellrack_brick"},
{"hell:hellrack_brick", "hell:hellrack_brick", "hell:hellrack_brick"},
}
})
minetest.register_craft({
output = "hell:extractor",
recipe = {
{"hell:hellrack_brick", "hell:blood_top_cooked", "hell:hellrack_brick"},
{"hell:blood_cooked", "hell:shroom_stem", "hell:blood_cooked"},
{"hell:hellrack_brick", "hell:blood_stem_cooked", "hell:hellrack_brick"},
}
})
minetest.register_craft({
output = "hell:wood 4",
recipe = {
{"hell:blood_stem"},
}
})
minetest.register_craft({
output = "hell:wood_empty 4",
recipe = {
{"hell:blood_stem_empty"},
}
})
minetest.register_craft({
output = "hell:stick 4",
recipe = {
{"hell:wood_empty"},
}
})
minetest.register_craft({
output = "hell:torch",
recipe = {
{"hell:bark"},
{"group:stick"},
}
})
minetest.register_craft({
output = "hell:forest_wood",
recipe = {
{"hell:forest_planks", "hell:forest_planks", "hell:forest_planks"},
{"hell:forest_planks", "", "hell:forest_planks"},
{"hell:forest_planks", "hell:forest_planks", "hell:forest_planks"},
}
})
minetest.register_craft({
output = "hell:forest_planks 8",
recipe = {
{"hell:forest_wood"},
}
})
minetest.register_craft({
output = "hell:forest_planks 7",
recipe = {
{"hell:tree"},
},
})
local sound_allowed = true
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
if itemstack:get_name() ~= "hell:forest_planks"
or itemstack:get_count() ~= 7 then
return
end
local tree
for i = 1,9 do
if old_craft_grid[i]:get_name() == "hell:tree" then
tree = i
break
end
end
if not tree then -- do nth if theres no tree
return
end
local rdif = math.random(-1,1) -- add a bit randomness
local barkstack = ItemStack("hell:bark "..4-rdif)
local inv = player:get_inventory()
if not inv:room_for_item("main", barkstack) then -- disallow crafting if there's not enough free space
craft_inv:set_list("craft", old_craft_grid)
itemstack:set_name("")
return
end
itemstack:set_count(7+rdif)
inv:add_item("main", barkstack)
if not sound_allowed then -- avoid playing the sound multiple times, e.g. when middle mouse click
return
end
minetest.sound_play("default_wood_footstep", {pos=player:getpos(), gain=0.25})
sound_allowed = false
minetest.after(0, function()
sound_allowed = true
end)
end)
minetest.register_craft({
output = "default:paper",
recipe = {
{"hell:grass_dried", "hell:grass_dried", "hell:grass_dried"},
}
})
minetest.register_craft({
type = "cooking",
output = "default:coal_lump",
recipe = "hell:tree",
})
minetest.register_craft({
type = "cooking",
output = "hell:grass_dried",
recipe = "hell:grass",
})
minetest.register_craft({
type = "cooking",
output = "hell:pearl",
recipe = "hell:fim",
})
minetest.register_craft({
type = "cooking",
output = "hell:hotbed",
recipe = "hell:blood_extracted",
})
for _,i in ipairs({"hell:blood", "hell:blood_top", "hell:blood_stem", "hell:wood"}) do
local cooked = i.."_cooked"
minetest.register_craft({
type = "cooking",
output = cooked,
recipe = i,
})
minetest.register_craft({
type = "fuel",
recipe = cooked,
burntime = 30,
})
end