From b21c3d368077aa3a1c42ff1582cda6263c018585 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Wed, 6 Mar 2019 17:01:02 -0500 Subject: updated cottages, areasprotector, bees, biome_lib, technic, facade, farming redo, homedecor, maptools, mesecons, moreblocks, moreores, pipeworks, quartz, travelnet, unified_inventory, unifieddyes, xban2 delete the playeranim mod, not 5.0.0 compatible. --- anvil/init.lua | 152 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 81 insertions(+), 71 deletions(-) (limited to 'anvil') diff --git a/anvil/init.lua b/anvil/init.lua index e4bc8bd..fa554cd 100644 --- a/anvil/init.lua +++ b/anvil/init.lua @@ -6,9 +6,9 @@ --------------------------------------------------------------------------------------- anvil = { - setting = { - item_displacement = 7/16, - } + setting = { + item_displacement = 7/16, + } } minetest.register_alias("castle:anvil", "anvil:anvil") @@ -24,7 +24,7 @@ minetest.register_tool("anvil:hammer", { _doc_items_usagehelp = S("Use this hammer to strike blows upon an anvil bearing a damaged tool and you can repair it. It can also be used for smashing stone, but it is not well suited to this task."), image = "anvil_tool_steelhammer.png", inventory_image = "anvil_tool_steelhammer.png", - + tool_capabilities = { full_punch_interval = 0.8, max_drop_level=1, @@ -133,27 +133,29 @@ minetest.register_node("anvil:anvil", { {-0.35,-0.1,-0.2,0.35,0.1,0.2}, } }, + on_construct = function(pos) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() inv:set_size("input", 1) end, - + after_place_node = function(pos, placer) local meta = minetest.get_meta(pos) meta:set_string("owner", placer:get_player_name() or "") + meta:set_string("infotext",placer:get_player_name().."'s anvil") end, - + can_dig = function(pos,player) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() - + if not inv:is_empty("input") then return false end return true end, - + allow_metadata_inventory_put = function(pos, listname, index, stack, player) local meta = minetest.get_meta(pos) if listname~="input" then @@ -162,30 +164,33 @@ minetest.register_node("anvil:anvil", { if (listname=='input' and(stack:get_wear() == 0 or minetest.get_item_group(stack:get_name(), "not_repaired_by_anvil") ~= 0 - or stack:get_name() == "technic:water_can" + or stack:get_name() == "technic:water_can" or stack:get_name() == "technic:lava_can" )) then - + minetest.chat_send_player( player:get_player_name(), S('This anvil is for damaged tools only.')) return 0 end - + if meta:get_inventory():room_for_item("input", stack) then return stack:get_count() end return 0 end, - + allow_metadata_inventory_take = function(pos, listname, index, stack, player) if listname~="input" then return 0 end return stack:get_count() end, - + on_rightclick = function(pos, node, clicker, itemstack) + local meta = minetest.get_meta(pos) + local name = clicker:get_player_name() + + if name ~= meta:get_string("owner") then return itemstack end if itemstack:get_count() == 0 then - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() + local inv = meta:get_inventory() if not inv:is_empty("input") then local return_stack = inv:get_stack("input", 1) inv:set_stack("input", 1, nil) @@ -193,7 +198,7 @@ minetest.register_node("anvil:anvil", { clicker:get_inventory():set_stack("main", wield_index, return_stack) remove_item(pos, node) return return_stack - end + end end local this_def = minetest.registered_nodes[node.name] if this_def.allow_metadata_inventory_put(pos, "input", 1, itemstack:peek_item(), clicker) > 0 then @@ -203,9 +208,10 @@ minetest.register_node("anvil:anvil", { inv:add_item("input", s) update_item(pos,node) end + return itemstack end, - + on_punch = function(pos, node, puncher) if( not( pos ) or not( node ) or not( puncher )) then return @@ -214,7 +220,10 @@ minetest.register_node("anvil:anvil", { local wielded = puncher:get_wielded_item() local meta = minetest.get_meta(pos) local inv = meta:get_inventory() - + if meta:get_string("owner") ~= puncher:get_player_name() then + return + end + if wielded:get_count() == 0 then if not inv:is_empty("input") then local return_stack = inv:get_stack("input", 1) @@ -222,60 +231,59 @@ minetest.register_node("anvil:anvil", { local wield_index = puncher:get_wield_index() puncher:get_inventory():set_stack("main", wield_index, return_stack) remove_item(pos, node) - end + end end - + -- only punching with the hammer is supposed to work if wielded:get_name() ~= 'anvil:hammer' then return end - local input = inv:get_stack('input',1) - + -- only tools can be repaired - if( not( input ) - or input:is_empty() - or input:get_name() == "technic:water_can" - or input:get_name() == "technic:lava_can" ) then + if( not( input ) + or input:is_empty() + or input:get_name() == "technic:water_can" + or input:get_name() == "technic:lava_can" ) then return end - + -- 65535 is max damage local damage_state = 40-math.floor(input:get_wear()/1638) - + local tool_name = input:get_name() local hud2 = nil local hud3 = nil if( input:get_wear()>0 ) then hud2 = puncher:hud_add({ - hud_elem_type = "statbar", - text = "default_cloud.png^[colorize:#ff0000:256", - number = 40, - direction = 0, -- left to right - position = {x=0.5, y=0.65}, - alignment = {x = 0, y = 0}, - offset = {x = -320, y = 0}, - size = {x=32, y=32}, + hud_elem_type = "statbar", + text = "default_cloud.png^[colorize:#ff0000:256", + number = 40, + direction = 0, -- left to right + position = {x=0.5, y=0.65}, + alignment = {x = 0, y = 0}, + offset = {x = -320, y = 0}, + size = {x=32, y=32}, }) hud3 = puncher:hud_add({ - hud_elem_type = "statbar", - text = "default_cloud.png^[colorize:#00ff00:256", - number = damage_state, - direction = 0, -- left to right - position = {x=0.5, y=0.65}, - alignment = {x = 0, y = 0}, - offset = {x = -320, y = 0}, - size = {x=32, y=32}, + hud_elem_type = "statbar", + text = "default_cloud.png^[colorize:#00ff00:256", + number = damage_state, + direction = 0, -- left to right + position = {x=0.5, y=0.65}, + alignment = {x = 0, y = 0}, + offset = {x = -320, y = 0}, + size = {x=32, y=32}, }) end minetest.after(2, function() - if( puncher ) then - puncher:hud_remove(hud2) - puncher:hud_remove(hud3) + if( puncher ) then + puncher:hud_remove(hud2) + puncher:hud_remove(hud3) end end) - + -- tell the player when the job is done if( input:get_wear() == 0 ) then local tool_desc @@ -290,28 +298,28 @@ minetest.register_node("anvil:anvil", { pos.y = pos.y + anvil.setting.item_displacement minetest.sound_play({name="anvil_clang"}, {pos=pos}) minetest.add_particlespawner({ - amount = 10, - time = 0.1, - minpos = pos, - maxpos = pos, - minvel = {x=2, y=3, z=2}, - maxvel = {x=-2, y=1, z=-2}, - minacc = {x=0, y= -10, z=0}, - maxacc = {x=0, y= -10, z=0}, - minexptime = 0.5, - maxexptime = 1, - minsize = 1, - maxsize = 1, - collisiondetection = true, - vertical = false, - texture = "anvil_spark.png", + amount = 10, + time = 0.1, + minpos = pos, + maxpos = pos, + minvel = {x=2, y=3, z=2}, + maxvel = {x=-2, y=1, z=-2}, + minacc = {x=0, y= -10, z=0}, + maxacc = {x=0, y= -10, z=0}, + minexptime = 0.5, + maxexptime = 1, + minsize = 1, + maxsize = 1, + collisiondetection = true, + vertical = false, + texture = "anvil_spark.png", }) end - + -- do the actual repair input:add_wear( -5000 ) -- equals to what technic toolshop does in 5 seconds inv:set_stack("input", 1, input) - + -- damage the hammer slightly wielded:add_wear( 100 ) puncher:set_wielded_item( wielded ) @@ -358,16 +366,18 @@ minetest.register_lbm({ minetest.register_craft({ output = "anvil:anvil", recipe = { - {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, - {'', "default:steel_ingot",'' }, - {"default:steel_ingot","default:steel_ingot","default:steel_ingot"} }, + {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, + {'', "default:steel_ingot",'' }, + {"default:steel_ingot","default:steel_ingot","default:steel_ingot"} + } }) minetest.register_craft({ output = "anvil:hammer", recipe = { - {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, - {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, - {"group:stick", '', ''} }, + {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, + {"default:steel_ingot","default:steel_ingot","default:steel_ingot"}, + {"group:stick","",""} + } }) -- cgit v1.2.3