]> git.lizzy.rs Git - xdecor.git/commitdiff
Fix crash on mailbox
authorJean-Patrick Guerrero <jeanpatrick.guerrero@gmail.com>
Sat, 12 Mar 2016 20:45:11 +0000 (21:45 +0100)
committerJean-Patrick Guerrero <jeanpatrick.guerrero@gmail.com>
Sat, 12 Mar 2016 21:00:29 +0000 (22:00 +0100)
mailbox.lua

index 984ce3e3e1e38d7ab392034b1802230942f60fbe..a0f0528c428712b96a95e57c1f414af9a1fbb8e5 100644 (file)
@@ -18,11 +18,12 @@ function mailbox:formspec(pos, owner, num)
        if num == 1 then
                for i = 1, 7 do
                        if meta:get_string("giver"..i) ~= "" then
-                               giver = giver.."#FFFF00,"..meta:get_string("giver"..i):sub(1, 12)..
-                                       ","..i..",#FFFFFF,x "..meta:get_string("stack"..i):match("%s(%d+)")..","
+                               local giver_name = meta:get_string("giver"..i):sub(1,12)
+                               local stack_name = meta:get_string("stack"..i):match("[%w_:]+")
+                               local stack_count = meta:get_string("stack"..i):match("%s(%d+)") or 1
 
-                               img = img..i.."="..img_col(minetest.registered_items[
-                                       meta:get_string("stack"..i):match("(.*)%s")])..","
+                               giver = giver.."#FFFF00,"..giver_name..","..i..",#FFFFFF,x "..stack_count..","
+                               img = img..i.."="..img_col(minetest.registered_items[stack_name])..","
                        end
                end