Make the hammer a tool instead of an item
This commit is contained in:
parent
473158dc74
commit
e4aafc0cb8
@ -148,11 +148,6 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craftitem("xdecor:hammer", {
|
||||
description = "Hammer",
|
||||
inventory_image = "xdecor_hammer.png"
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "xdecor:hive",
|
||||
recipe = {
|
||||
|
17
nodes.lua
17
nodes.lua
@ -115,7 +115,6 @@ if minetest.get_modpath("bucket") then
|
||||
minetest.override_item("bucket:bucket_empty", {
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local inv = user:get_inventory()
|
||||
|
||||
if pointed_thing.type == "node" and
|
||||
minetest.get_node(pointed_thing.under).name == "xdecor:cauldron" then
|
||||
if inv:room_for_item("main", "bucket:bucket_water 1") then
|
||||
@ -316,12 +315,9 @@ xdecor.register("fire", {
|
||||
|
||||
minetest.register_tool("xdecor:flint_steel", {
|
||||
description = "Flint & Steel",
|
||||
stack_max = 1,
|
||||
inventory_image = "xdecor_flint_steel.png",
|
||||
tool_capabilities = {
|
||||
groupcaps = {
|
||||
flamable = {uses=65, maxlevel=1}
|
||||
}
|
||||
groupcaps = { flamable = {uses=65, maxlevel=1} }
|
||||
},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if pointed_thing.type == "node" and
|
||||
@ -342,6 +338,17 @@ minetest.register_tool("xdecor:flint_steel", {
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_tool("xdecor:hammer", {
|
||||
description = "Hammer",
|
||||
inventory_image = "xdecor_hammer.png",
|
||||
tool_capabilities = {
|
||||
groupcaps = { snappy = {uses=20, maxlevel=2} }
|
||||
},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if pointed_thing.type == "node" then return end -- The hammer ain't meant for digging but for repairing.
|
||||
end
|
||||
})
|
||||
|
||||
xdecor.register("ivy", {
|
||||
description = "Ivy",
|
||||
drawtype = "signlike",
|
||||
|
@ -52,7 +52,7 @@ local function xconstruct(pos)
|
||||
"image[1,2;1,1;xdecor_saw.png]"..
|
||||
"label[2,1.5;Output]"..
|
||||
"list[current_name;output;2,2;1,1;]"..
|
||||
"label[4.5,1.5;Damaged tool]"..
|
||||
"label[5,1.5;Tool]"..
|
||||
"list[current_name;src;5,2;1,1;]"..
|
||||
"image[6,2;1,1;xdecor_anvil.png]"..
|
||||
"label[6.8,1.5;Hammer]]"..
|
||||
@ -114,7 +114,7 @@ local function xput(pos, listname, index, stack, player)
|
||||
end
|
||||
if listname == "fuel" then
|
||||
if stack:get_name() == "xdecor:hammer" then
|
||||
return stack:get_count()
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
@ -208,27 +208,32 @@ end
|
||||
|
||||
minetest.register_abm({ -- Repair Tool's code by Krock, modified by kilbith.
|
||||
nodenames = {"xdecor:worktable"},
|
||||
interval = 5, chance = 1,
|
||||
interval = 1, chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local src = inv:get_stack("src", 1)
|
||||
local fuel = inv:get_stack("fuel", 1)
|
||||
local wear = src:get_wear()
|
||||
local repair = -1400
|
||||
local wear2 = fuel:get_wear()
|
||||
|
||||
local repair = -1400 -- Tool's repairing factor (higher in negative means greater repairing).
|
||||
local wearhammer = 700 -- Hammer's wearing factor (higher in positive means greater wearing).
|
||||
|
||||
if (src:is_empty() or wear == 0 or wear == 65535) then return end
|
||||
|
||||
local fuel = inv:get_stack("fuel", 1)
|
||||
if (fuel:is_empty() or fuel:get_name() ~= "xdecor:hammer") then
|
||||
return end
|
||||
|
||||
if (wear + repair < 0) then
|
||||
src:add_wear(repair + wear)
|
||||
src:add_wear(repair)
|
||||
fuel:add_wear(wearhammer)
|
||||
else
|
||||
src:add_wear(repair)
|
||||
fuel:add_wear(wearhammer)
|
||||
end
|
||||
|
||||
inv:set_stack("src", 1, src)
|
||||
inv:remove_item("fuel", "xdecor:hammer 1")
|
||||
inv:set_stack("fuel", 1, fuel)
|
||||
end
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user