Select creative inventory by default in creative

This commit is contained in:
Wuzzy 2019-08-31 15:15:54 +02:00
parent a4ea22f7bf
commit 0cfa34e501
2 changed files with 13 additions and 2 deletions

View File

@ -98,7 +98,14 @@ creative.get_creative_formspec = function(player, start_i, pagenum)
"listring[current_player;main]"
end
local init_playerdata = function(playername)
if not playerdata[playername] then
playerdata[playername] = { page = 1 }
end
end
local get_page_and_start_i = function(playername)
init_playerdata(playername)
local page = playerdata[playername].page
local start_i = (page - 1) * creative.slots_num
return page, start_i
@ -122,7 +129,7 @@ minetest.register_on_joinplayer(function(player)
if not minetest.settings:get_bool("creative_mode") then
return
end
playerdata[player:get_player_name()] = { page = 1 }
init_playerdata(player:get_player_name())
end)
minetest.register_on_leaveplayer(function(player)
playerdata[player:get_player_name()] = nil

View File

@ -347,5 +347,9 @@ end)
minetest.register_on_joinplayer(
function(player)
player:set_inventory_formspec(crafting.get_formspec(player:get_player_name()))
if minetest.settings:get_bool("creative_mode") then
player:set_inventory_formspec(creative.get_formspec(player:get_player_name()))
else
player:set_inventory_formspec(crafting.get_formspec(player:get_player_name()))
end
end)