From: Perttu Ahola Date: Wed, 25 Jul 2012 15:18:34 +0000 (+0300) Subject: Add visible page number to creative inventory X-Git-Tag: 0.4.2-rc1~5 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8643caac3cd07262eef8fe148810adf46e3a961b;p=oweals%2Fminetest_game.git Add visible page number to creative inventory --- diff --git a/mods/creative_inventory/init.lua b/mods/creative_inventory/init.lua index 04a48a9c..6106a7d8 100644 --- a/mods/creative_inventory/init.lua +++ b/mods/creative_inventory/init.lua @@ -62,22 +62,25 @@ minetest.after(0, function() print("creative inventory size: "..dump(creative_inventory.creative_inventory_size)) end) -creative_inventory.set_creative_formspec = function(player, start_i) +creative_inventory.set_creative_formspec = function(player, start_i, pagenum) + pagenum = math.floor(pagenum) + local pagemax = math.floor((creative_inventory.creative_inventory_size-1) / (6*4) + 1) player:set_inventory_formspec("size[13,7.5]".. --"image[6,0.6;1,2;player.png]".. "list[current_player;main;5,3.5;8,4;]".. "list[current_player;craft;8,0;3,3;]".. "list[current_player;craftpreview;12,1;1,1;]".. "list[detached:creative;main;0.3,0.5;4,6;"..tostring(start_i).."]".. - "button[0.3,6.5;1.9,1;creative_prev;<<]".. - "button[2.4,6.5;1.9,1;creative_next;>>]") + "label[2.0,6.55;"..tostring(pagenum).."/"..tostring(pagemax).."]".. + "button[0.3,6.5;1.6,1;creative_prev;<<]".. + "button[2.7,6.5;1.6,1;creative_next;>>]") end minetest.register_on_joinplayer(function(player) -- If in creative mode, modify player's inventory forms if not minetest.setting_getbool("creative_mode") then return end - creative_inventory.set_creative_formspec(player, 0) + creative_inventory.set_creative_formspec(player, 0, 1) end) minetest.register_on_player_receive_fields(function(player, formname, fields) if not minetest.setting_getbool("creative_mode") then @@ -107,6 +110,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) start_i = 0 end - creative_inventory.set_creative_formspec(player, start_i) + creative_inventory.set_creative_formspec(player, start_i, start_i / (6*4) + 1) end)