diff --git a/shooter.lua b/shooter.lua index 432dab0..f4b574c 100644 --- a/shooter.lua +++ b/shooter.lua @@ -20,7 +20,7 @@ local timer = 0 local shots = {} local function spawn_particles(p, v, d, texture) - if texture.type ~= "string" then + if type(texture) ~= "string" then texture = SHOOTER_EXPLOSION_TEXTURE end local pos = vector.add(p, vector.multiply(v, {x=d, y=d, z=d})) @@ -55,26 +55,25 @@ local function punch_node(pos, def) return end local item = minetest.registered_items[node.name] - if not item.groups then - return - end - for k, v in pairs(def.groups) do - local level = item.groups[k] or 0 - if level >= v then - minetest.remove_node(pos) - local sounds = item.sounds - if sounds then - local soundspec = sounds.dug - if soundspec then - soundspec.pos = pos - minetest.sound_play(soundspec.name, soundspec) + if item and item.groups then + for k, v in pairs(def.groups) do + local level = item.groups[k] or 0 + if level >= v then + minetest.remove_node(pos) + local sounds = item.sounds + if sounds then + local soundspec = sounds.dug + if soundspec then + soundspec.pos = pos + minetest.sound_play(soundspec.name, soundspec) + end end + local tiles = item.tiles + if tiles then + return tiles[1] + end + break end - local tiles = item.tiles - if tiles then - return tiles[1] - end - break end end end