cauldron fixes, ingot
This commit is contained in:
parent
b90bf73886
commit
5fcd007217
25
cauldron.lua
25
cauldron.lua
@ -4,11 +4,12 @@ local _fldlib = minetest.get_modpath("fluid_lib") ~= nil
|
||||
magicalities.cauldron = {
|
||||
recipes = {
|
||||
{
|
||||
items = {"default:coal_lump 9"},
|
||||
items = {"default:steel_ingot", "default:obsidian"},
|
||||
requirements = {
|
||||
earth = 5
|
||||
earth = 1,
|
||||
dark = 1,
|
||||
},
|
||||
output = "default:diamond"
|
||||
output = "magicalities:tellium"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -16,6 +17,7 @@ magicalities.cauldron = {
|
||||
local function flatten_stacks(stacks)
|
||||
local temp = {}
|
||||
for _, stack in pairs(stacks) do
|
||||
if not stack:is_empty() then
|
||||
local name = stack:get_name()
|
||||
if not temp[name] then
|
||||
temp[name] = stack:get_count()
|
||||
@ -23,6 +25,7 @@ local function flatten_stacks(stacks)
|
||||
temp[name] = temp[name] + stack:get_count()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local stacks_new = {}
|
||||
for name,count in pairs(temp) do
|
||||
@ -33,12 +36,13 @@ local function flatten_stacks(stacks)
|
||||
end
|
||||
|
||||
local function get_recipe(items_found, wand)
|
||||
local flatstacks = flatten_stacks(items_found)
|
||||
local match = {}
|
||||
for _,r in pairs(magicalities.cauldron.recipes) do
|
||||
local pass = true
|
||||
for _,item in pairs(r.items) do
|
||||
local found = false
|
||||
for _,item2 in pairs(items_found) do
|
||||
for _,item2 in pairs(flatstacks) do
|
||||
local i1 = ItemStack(item)
|
||||
local i2 = ItemStack(item2)
|
||||
if i1:get_name() == i2:get_name() and i2:get_count() >= i1:get_count() then
|
||||
@ -124,7 +128,7 @@ local _clddef = {
|
||||
if not user or user:get_player_name() == "" then return itemstack end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local stacks = flatten_stacks(inv:get_list("items"))
|
||||
local stacks = inv:get_list("items")
|
||||
local recipe = get_recipe(stacks, itemstack)
|
||||
|
||||
if user:get_player_control().sneak then
|
||||
@ -136,6 +140,8 @@ local _clddef = {
|
||||
|
||||
if not recipe then return itemstack end
|
||||
|
||||
for j = 1, 16 do
|
||||
if not recipe then break end
|
||||
for _,st in pairs(recipe.items) do
|
||||
for _,sta in pairs(stacks) do
|
||||
if sta:get_name() == st then
|
||||
@ -144,12 +150,15 @@ local _clddef = {
|
||||
end
|
||||
end
|
||||
|
||||
--inv:set_list("items", stacks)
|
||||
minetest.item_drop(ItemStack(recipe.output), user, user:get_pos())
|
||||
itemstack = magicalities.wands.wand_take_contents(itemstack, recipe.requirements)
|
||||
inv:set_list("items", stacks)
|
||||
recipe = get_recipe(stacks, itemstack)
|
||||
end
|
||||
|
||||
inv:set_list("items", {})
|
||||
node.name = "magicalities:cauldron"
|
||||
minetest.swap_node(pos, node)
|
||||
minetest.item_drop(ItemStack(recipe.output), user, user:get_pos())
|
||||
itemstack = magicalities.wands.wand_take_contents(itemstack, recipe.requirements)
|
||||
magicalities.wands.update_wand_desc(itemstack)
|
||||
|
||||
return itemstack
|
||||
|
@ -14,3 +14,8 @@ minetest.register_craftitem("magicalities:cap_gold", {
|
||||
inventory_image = "magicalities_cap_gold.png"
|
||||
})
|
||||
|
||||
minetest.register_craftitem("magicalities:tellium", {
|
||||
description = "Tellium Ingot",
|
||||
inventory_image = "magicalities_tellium_ingot.png",
|
||||
groups = {ingot = 1, tellium = 1}
|
||||
})
|
||||
|
18
register.lua
18
register.lua
@ -159,4 +159,22 @@ if minetest.get_modpath("craftguide") ~= nil then
|
||||
items = {"group:"..g},
|
||||
})
|
||||
end
|
||||
|
||||
-- Cauldron
|
||||
craftguide.register_craft_type("cauldron", {
|
||||
description = "Cauldron",
|
||||
icon = "magicalities_cauldron.png",
|
||||
})
|
||||
|
||||
for g,v in pairs(magicalities.cauldron.recipes) do
|
||||
local height = math.ceil(#v.items / 3)
|
||||
local width = math.floor(#v.items % 3)
|
||||
craftguide.register_craft({
|
||||
type = "cauldron",
|
||||
output = v.output,
|
||||
height = height,
|
||||
width = width,
|
||||
items = v.items,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
BIN
textures/magicalities_tellium_ingot.png
Normal file
BIN
textures/magicalities_tellium_ingot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
@ -278,6 +278,7 @@ local function use_wand(itemstack, user, pointed_thing)
|
||||
end
|
||||
|
||||
-- Call use on the node
|
||||
if pointed_thing.type == "node" then
|
||||
local pos = pointed_thing.under
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if node and node.name ~= "air" then
|
||||
@ -286,6 +287,7 @@ local function use_wand(itemstack, user, pointed_thing)
|
||||
return ndef['_wand_use'](pos, node, itemstack, user, pointed_thing)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
magicalities.wands.update_wand_desc(itemstack)
|
||||
return itemstack
|
||||
|
Loading…
Reference in New Issue
Block a user