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