Fixed crash with unknown objects
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Wed, 15 Nov 2017 17:04:09 +0000 (18:04 +0100)
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Wed, 15 Nov 2017 17:04:09 +0000 (18:04 +0100)
init.lua

index 0969ead..8eb1348 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -176,9 +176,13 @@ smartshop.update_info=function(pos)
                        --if string.find(stuff["name" ..i],":")~=nil then\r
                        --      stuff["name" ..i]=stuff["name" ..i].split(stuff["name" ..i],":")[2]\r
                   --end\r
-                       stuff["name"..i] = core.registered_items[stuff["name"..i]].description\r
-                       stuff["buy" ..i]="(" ..stuff["buy" ..i] ..") "\r
-                       stuff["name" ..i]=stuff["name" ..i] .."\n"\r
+                  if core.registered_items[stuff["name"..i]] then\r
+                     stuff["name"..i] = core.registered_items[stuff["name"..i]].description\r
+                  else\r
+                     stuff["name"..i] = "Unknown Object"\r
+                  end\r
+                  stuff["buy" ..i]="(" ..stuff["buy" ..i] ..") "\r
+                  stuff["name" ..i]=stuff["name" ..i] .."\n"\r
                end\r
        end\r
                meta:set_string("infotext",\r