Creative: Fix '-' glitch in playername
authortenplus1 <tenplus1@users.noreply.github.com>
Fri, 6 May 2016 14:14:38 +0000 (15:14 +0100)
committerparamat <mat.gregory@virginmedia.com>
Sat, 7 May 2016 01:13:00 +0000 (02:13 +0100)
Fix the glitch when players use the '-' character in their username
on a server, causing creative inventory to not pass page 2

mods/creative/init.lua

index a2c8858d56aa097fcc53cb2e4a5157c815cc9409..5ef8dcf0104c5aa08607ba328efc229e10295de0 100644 (file)
@@ -194,8 +194,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
                creative.set_creative_formspec(player, 0)
        else
                local formspec = player:get_inventory_formspec()
-               local start_i = formspec:match("list%[.-" .. player_name .. ";.-;(%d+)%]")
-               start_i = tonumber(start_i) or 0
+               local start_i = player_inventory[player_name].start_i or 0
 
                if fields.creative_prev then
                        start_i = start_i - 3*8
@@ -212,6 +211,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
                        end
                end
 
+               player_inventory[player_name].start_i = start_i
                creative.set_creative_formspec(player, start_i)
        end
 end)