Extra error checking.
This commit is contained in:
parent
aa999e2ed5
commit
bf26b8bee1
25 changed files with 897 additions and 314 deletions
|
@ -23,34 +23,11 @@ local default_material = {
|
|||
}
|
||||
|
||||
local function parti(pos)
|
||||
minetest.add_particlespawner(25, 0.3,
|
||||
pos, pos,
|
||||
{x=2, y=0.2, z=2}, {x=-2, y=2, z=-2},
|
||||
{x=0, y=-6, z=0}, {x=0, y=-10, z=0},
|
||||
0.2, 1,
|
||||
0.2, 2,
|
||||
true, "wallhammer_parti.png")
|
||||
end
|
||||
|
||||
local function get_pointed_thing(player, range)
|
||||
local plpos = player:getpos()
|
||||
plpos.y = plpos.y+1.625
|
||||
local dir = player:get_look_dir()
|
||||
local p2 = vector.add(plpos, vector.multiply(dir, range))
|
||||
local _,pos = minetest.line_of_sight(plpos, p2)
|
||||
if not pos then
|
||||
return
|
||||
end
|
||||
local check = minetest.get_node(pos)
|
||||
if string.find(check.name, '_foot') then
|
||||
pos = vector.add(pos, dir)
|
||||
print('added')
|
||||
end
|
||||
return {
|
||||
under = vector.round(pos),
|
||||
above = vector.round(vector.subtract(pos, dir)),
|
||||
type = "node"
|
||||
}
|
||||
|
||||
minetest.add_particlespawner(25, 0.3, pos, pos, {x=2, y=0.2, z=2}, {x=-2, y=2, z=-2}, {x=0, y=-6, z=0}, {x=0, y=-10, z=0}, 0.2, 1, 0.2, 2, true, "wallhammer_parti.png")
|
||||
end
|
||||
|
||||
minetest.register_tool( "fun_caves:wall_hammer",{
|
||||
|
@ -66,13 +43,23 @@ minetest.register_tool( "fun_caves:wall_hammer",{
|
|||
damage_groups = {fleshy=4},
|
||||
},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if not (pointed_thing and user and itemstack) then
|
||||
return
|
||||
end
|
||||
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
|
||||
local pos = pointed_thing.under
|
||||
if not pos then
|
||||
return
|
||||
end
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
if not node then
|
||||
return
|
||||
end
|
||||
|
||||
for i in ipairs (default_material) do
|
||||
local item = default_material [i][1]
|
||||
|
@ -85,7 +72,11 @@ minetest.register_tool( "fun_caves:wall_hammer",{
|
|||
end
|
||||
|
||||
if node.name == item then
|
||||
minetest.set_node(pos,{name = "fun_caves:"..mat.."_foot", param2=minetest.dir_to_facedir(user:get_look_dir())})
|
||||
local node = {
|
||||
name = "fun_caves:"..mat.."_foot",
|
||||
param2=minetest.dir_to_facedir(user:get_look_dir())
|
||||
}
|
||||
minetest.set_node(pos, node)
|
||||
parti(pos)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue