34 lines
918 B
Lua
34 lines
918 B
Lua
blueprint = {}
|
|
blueprint.all = {}
|
|
|
|
function blueprint.register_blueprint(name, def)
|
|
table.insert(def.materials, "blueprint:"..name)
|
|
table.insert(blueprint.all, "blueprint:"..name)
|
|
|
|
minetest.register_craftitem(":blueprint:"..name, {
|
|
description = "Blueprint : " .. def.description,
|
|
inventory_image = "blueprint_blueprint.png^[colorize:"..def.color..":80",
|
|
})
|
|
|
|
minetest.register_craft({
|
|
type = "shapeless",
|
|
output = def.out,
|
|
recipe = def.materials,
|
|
replacements = {
|
|
{"blueprint:"..name, "blueprint:"..name}
|
|
}
|
|
})
|
|
end
|
|
|
|
minetest.register_craftitem("blueprint:empty", {
|
|
description = "Empty Blueprint",
|
|
inventory_image = "blueprint_empty.png",
|
|
on_place = function(itemstack, placer, pointed_thing)
|
|
placer:get_inventory():add_item("main", blueprint.all[math.random(#blueprint.all)])
|
|
itemstack:take_item()
|
|
return itemstack
|
|
end
|
|
})
|
|
|
|
table.insert(default.treasure_chest_items, "blueprint:empty")
|