]> git.lizzy.rs Git - worldedit.git/commitdiff
Fix exiting mtschemprob entry dialog with ESC
authorsfan5 <sfan5@live.de>
Fri, 5 Aug 2016 14:41:37 +0000 (16:41 +0200)
committersfan5 <sfan5@live.de>
Fri, 5 Aug 2016 14:41:37 +0000 (16:41 +0200)
worldedit_commands/init.lua

index eedc3721bdbccb44f8f985b4c7304b92e70638c0..ca2b9e4dde96a40d9d4f9a3587afc7ac77c7c873 100644 (file)
@@ -1152,8 +1152,8 @@ minetest.register_chatcommand("/mtschemprob", {
                                return\r
                        end\r
                        for k,v in pairs(problist) do\r
-                               local prob = math.floor(((v["prob"] / 256) * 100) * 100 + 0.5) / 100\r
-                               text = text .. minetest.pos_to_string(v["pos"]) .. ": " .. prob .. "% | "\r
+                               local prob = math.floor(((v.prob / 256) * 100) * 100 + 0.5) / 100\r
+                               text = text .. minetest.pos_to_string(v.pos) .. ": " .. prob .. "% | "\r
                        end\r
                        worldedit.player_notify(name, "currently set node probabilities:")\r
                        worldedit.player_notify(name, text)\r
@@ -1163,16 +1163,14 @@ minetest.register_chatcommand("/mtschemprob", {
        end,\r
 })\r
 \r
-minetest.register_on_player_receive_fields(\r
-       function(player, formname, fields)\r
-               if (formname == "prob_val_enter") and (fields.text ~= "") then\r
-                       local name = player:get_player_name()\r
-                       local prob_entry = {pos=worldedit.prob_pos[name], prob=tonumber(fields.text)}\r
-                       local index = table.getn(worldedit.prob_list[name]) + 1\r
-                       worldedit.prob_list[name][index] = prob_entry\r
-               end\r
+minetest.register_on_player_receive_fields(function(player, formname, fields)\r
+       if formname == "prob_val_enter" and not (fields.text == "" or fields.text == nil) then\r
+               local name = player:get_player_name()\r
+               local prob_entry = {pos=worldedit.prob_pos[name], prob=tonumber(fields.text)}\r
+               local index = table.getn(worldedit.prob_list[name]) + 1\r
+               worldedit.prob_list[name][index] = prob_entry\r
        end\r
-)\r
+end)\r
 \r
 minetest.register_chatcommand("/clearobjects", {\r
        params = "",\r
@@ -1182,4 +1180,4 @@ minetest.register_chatcommand("/clearobjects", {
                local count = worldedit.clear_objects(worldedit.pos1[name], worldedit.pos2[name])\r
                worldedit.player_notify(name, count .. " objects cleared")\r
        end),\r
-})
\ No newline at end of file
+})\r