Allow the torch arrow to be placed on walls and on ceiling

Fixes #6
This commit is contained in:
upsilon 2017-06-21 11:32:48 +02:00
parent df73f47285
commit 4930d2f518
No known key found for this signature in database
GPG Key ID: A80DAE1F266E1C3C
1 changed files with 12 additions and 6 deletions

View File

@ -145,18 +145,24 @@ if get_setting("fire_arrow") then
description = "Torch Arrow",
tiles = {"throwing_arrow_fire.png", "throwing_arrow_fire.png", "throwing_arrow_fire_back.png", "throwing_arrow_fire_front.png", "throwing_arrow_fire_2.png", "throwing_arrow_fire.png"},
on_hit_sound = "default_place_node",
on_hit = function(_, last_pos, _, _, hitter)
on_hit = function(pos, last_pos, _, _, hitter)
if minetest.get_node(last_pos).name ~= "air" then
minetest.log("warning", "[throwing] BUG: node at last_pos was not air")
return
end
local under_node_name = minetest.get_node({x = last_pos.x, y = last_pos.y-1, z = last_pos.z}).name
if under_node_name ~= "air" and name ~= "ignore" then
minetest.place_node(last_pos, {name="default:torch"})
else
return false, "Attached node default:torch can not be placed"
local r_pos = vector.round(pos)
local r_last_pos = vector.round(last_pos)
-- Make sure that only one key is different
if r_pos.y ~= r_last_pos.y then
r_last_pos.x = r_pos.x
r_last_pos.z = r_pos.z
elseif r_pos.x ~= r_last_pos.x then
r_last_pos.y = r_pos.y
r_last_pos.z = r_pos.z
end
minetest.registered_items["default:torch"].on_place(ItemStack("default:torch"), hitter,
{type="node", under=r_pos, above=r_last_pos})
end
})
end