From ed13ef49039aca0bdec2a1ea7a1a9e8f5d59fb6c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 28 Dec 2016 18:10:05 +0100 Subject: Add some nil checks for nodes --- init.lua | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 79ae074..99cbd32 100644 --- a/init.lua +++ b/init.lua @@ -526,10 +526,12 @@ doc.add_category("nodes", { elseif data.def.damage_per_second == 1 then datastring = datastring .. S("This block causes a damage of @1 hit point per second.", data.def.damage_per_second) .. "\n" end - if data.def.drowning > 1 then - datastring = datastring .. S("This block decreases your breath and causes a drowning damage of @1 hit points every 2 seconds.", data.def.drowning) .. "\n" - elseif data.def.drowning == 1 then - datastring = datastring .. S("This block decreases your breath and causes a drowning damage of @1 hit point every 2 seconds.", data.def.drowning) .. "\n" + if data.def.drowning then + if data.def.drowning > 1 then + datastring = datastring .. S("This block decreases your breath and causes a drowning damage of @1 hit points every 2 seconds.", data.def.drowning) .. "\n" + elseif data.def.drowning == 1 then + datastring = datastring .. S("This block decreases your breath and causes a drowning damage of @1 hit point every 2 seconds.", data.def.drowning) .. "\n" + end end local fdap = data.def.groups.fall_damage_add_percent if fdap ~= nil then @@ -627,17 +629,19 @@ doc.add_category("nodes", { -- Block appearance --- Light - if data.def.light_source > 3 then - datastring = datastring .. S("This block is a light source with a light level of @1.", data.def.light_source).."\n" - elseif data.def.light_source > 0 then - datastring = datastring .. S("This block glows faintly with a light level of @1.", data.def.light_source).."\n" - end - if data.def.paramtype == "light" and data.def.sunlight_propagates then - datastring = datastring .. S("This block allows light to propagate with a small loss of brightness, and sunlight can even go through losslessly.").."\n" - elseif data.def.paramtype == "light" then - datastring = datastring .. S("This block allows light to propagate with a small loss of brightness.").."\n" - elseif data.def.sunlight_propagates then - datastring = datastring .. S("This block allows sunlight to propagate without loss in brightness.").."\n" + if data.def.light_source then + if data.def.light_source > 3 then + datastring = datastring .. S("This block is a light source with a light level of @1.", data.def.light_source).."\n" + elseif data.def.light_source > 0 then + datastring = datastring .. S("This block glows faintly with a light level of @1.", data.def.light_source).."\n" + end + if data.def.paramtype == "light" and data.def.sunlight_propagates then + datastring = datastring .. S("This block allows light to propagate with a small loss of brightness, and sunlight can even go through losslessly.").."\n" + elseif data.def.paramtype == "light" then + datastring = datastring .. S("This block allows light to propagate with a small loss of brightness.").."\n" + elseif data.def.sunlight_propagates then + datastring = datastring .. S("This block allows sunlight to propagate without loss in brightness.").."\n" + end end datastring = datastring .. factoid_custom("nodes", "light", data) datastring = newline2(datastring) -- cgit v1.2.3