From 4d0fd5b93c2b046eb0dcbd6ace375d200cb28675 Mon Sep 17 00:00:00 2001 From: stujones11 Date: Tue, 24 Dec 2013 21:44:51 +0000 Subject: [PATCH] Fix nil item exception and node particle texture --- shooter.lua | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) 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