]> git.lizzy.rs Git - xdecor.git/commitdiff
Fix #86 - crash in workbench: `attempt to concatenate a nil value`
authorAuke Kok <sofar@foo-projects.org>
Fri, 10 Nov 2017 05:50:29 +0000 (21:50 -0800)
committerAuke Kok <sofar@foo-projects.org>
Fri, 10 Nov 2017 05:50:29 +0000 (21:50 -0800)
Caused by a keystroke used in the formspec - this causes all
these fields not to be set, and the subsequent crash.

src/workbench.lua

index 0df3bf5d5d00e0546b5748ea11ef7098f76c49bb..80a4c5e52c1bd364f87a413bbd96dbe7e4f16224 100644 (file)
@@ -150,9 +150,11 @@ end
 function workbench.fields(pos, _, fields)
        if fields.quit then return end
        local meta = minetest.get_meta(pos)
-       workbench:set_formspec(meta, fields.back    and 1 or
-                                    fields.craft   and 2 or
-                                    fields.storage and 3)
+       local id = fields.back and 1 or
+                  fields.craft and 2 or
+                  fields.storage and 3
+       if not id then return end
+       workbench:set_formspec(meta, id)
 end
 
 function workbench.dig(pos)