summaryrefslogtreecommitdiff
path: root/anvil
diff options
context:
space:
mode:
Diffstat (limited to 'anvil')
-rw-r--r--anvil/init.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/anvil/init.lua b/anvil/init.lua
index 910c187..acc4996 100644
--- a/anvil/init.lua
+++ b/anvil/init.lua
@@ -5,14 +5,18 @@
-- * the hammer gets dammaged a bit at each repair step
---------------------------------------------------------------------------------------
+anvil = {
+ setting = {
+ item_displacement = 7/16,
+ }
+}
+
minetest.register_alias("castle:anvil", "anvil:anvil")
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")
-local item_displacement = 7/16
-
-- the hammer for the anvil
minetest.register_tool("anvil:hammer", {
description = S("Steel blacksmithing hammer"),
@@ -69,7 +73,7 @@ minetest.register_entity("anvil:item",{
})
local remove_item = function(pos, node)
- local objs = minetest.get_objects_inside_radius({x = pos.x, y = pos.y + item_displacement, z = pos.z}, .5)
+ local objs = minetest.get_objects_inside_radius({x = pos.x, y = pos.y + anvil.setting.item_displacement, z = pos.z}, .5)
if objs then
for _, obj in ipairs(objs) do
if obj and obj:get_luaentity() and obj:get_luaentity().name == "anvil:item" then
@@ -83,7 +87,7 @@ local update_item = function(pos, node)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if not inv:is_empty("input") then
- pos.y = pos.y + item_displacement
+ pos.y = pos.y + anvil.setting.item_displacement
tmp.nodename = node.name
tmp.texture = inv:get_stack("input", 1):get_name()
local e = minetest.add_entity(pos,"anvil:item")
@@ -283,7 +287,7 @@ minetest.register_node("anvil:anvil", {
minetest.chat_send_player( puncher:get_player_name(), S('Your @1 has been repaired successfully.', tool_desc))
return
else
- pos.y = pos.y + item_displacement
+ pos.y = pos.y + anvil_item_displacement
minetest.sound_play({name="anvil_clang"}, {pos=pos})
minetest.add_particlespawner({
amount = 10,
@@ -321,7 +325,7 @@ minetest.register_lbm({
nodenames = { "anvil:anvil" },
run_at_every_load = true,
action = function(pos, node, active_object_count, active_object_count_wider)
- local test_pos = {x=pos.x, y=pos.y + item_displacement, z=pos.z}
+ local test_pos = {x=pos.x, y=pos.y + anvil_item_displacement, z=pos.z}
if #minetest.get_objects_inside_radius(test_pos, 0.5) > 0 then return end
update_item(pos, node)
end