mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-19 01:21:05 +01:00
Added enchanted book to disenchant and drop items when destroyed
This commit is contained in:
parent
58d36d4596
commit
9580fdb81b
2 changed files with 23 additions and 1 deletions
|
@ -1,7 +1,10 @@
|
|||
-- Code based from mcl_anvils
|
||||
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local MAX_WEAR = 65535
|
||||
|
||||
-- formspecs
|
||||
local function get_grindstone_formspec()
|
||||
return "size[9,8.75]"..
|
||||
"image[3,1.5;1.5,1;gui_crafting_arrow.png]"..
|
||||
|
@ -117,6 +120,7 @@ local function update_grindstone_slots(meta)
|
|||
new_output = ""
|
||||
end
|
||||
-- Check if at least one input has an item
|
||||
-- Check if the item is's an enchanted book or tool
|
||||
elseif (not input1:is_empty() and input2:is_empty()) or (input1:is_empty() and not input2:is_empty()) then
|
||||
if input2:is_empty() then
|
||||
local def1 = input1:get_definition()
|
||||
|
@ -126,6 +130,9 @@ local function update_grindstone_slots(meta)
|
|||
local wear = input1:get_wear()
|
||||
local new_item = create_new_item(name, meta, wear)
|
||||
new_output = transfer_curse(input1, new_item)
|
||||
elseif input1:get_name() == "mcl_enchanting:book_enchanted" then
|
||||
local new_item = ItemStack("mcl_books:book")
|
||||
new_output = transfer_curse(input1, new_item)
|
||||
else
|
||||
new_output = ""
|
||||
end
|
||||
|
@ -137,6 +144,9 @@ local function update_grindstone_slots(meta)
|
|||
local wear = input2:get_wear()
|
||||
local new_item = create_new_item(name, meta, wear)
|
||||
new_output = transfer_curse(input2, new_item)
|
||||
elseif input2:get_name() == "mcl_enchanting:book_enchanted" then
|
||||
local new_item = ItemStack("mcl_books:book")
|
||||
new_output = transfer_curse(input2, new_item)
|
||||
else
|
||||
new_output = ""
|
||||
end
|
||||
|
@ -152,6 +162,18 @@ local function update_grindstone_slots(meta)
|
|||
end
|
||||
end
|
||||
|
||||
-- Drop any items inside the grindstone if destroyed
|
||||
local function drop_grindstone_items(pos, meta)
|
||||
local inv = meta:get_inventory()
|
||||
for i=1, inv:get_size("input") do
|
||||
local stack = inv:get_stack("input", i)
|
||||
if not stack:is_empty() then
|
||||
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
|
||||
minetest.add_item(p, stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("mcl_grindstone:grindstone", {
|
||||
description = S("Grindstone"),
|
||||
_tt_help = S("Used to disenchant/fix tools"),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name = mcl_grindstone
|
||||
author = TheRandomLegoBrick, ChrisPHP
|
||||
depends = mcl_experience, mcl_sounds
|
||||
description = Adds a cool looking block for the weaponsmiths jobsite
|
||||
description = Adds a cool looking block for the weaponsmiths jobsite and to disenchant or repair tools.
|
||||
|
|
Loading…
Reference in a new issue