1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-06-28 06:11:47 +02:00

modified unified_inventory to place buttons in 2 rows when +12

modified unified_inventory to hide buttons if player does not have the necessary privileges
modified other mods to adjust with unified_inventory
This commit is contained in:
2015-06-30 16:15:58 +02:00
parent 04e5e49904
commit a2b7be291f
9 changed files with 45 additions and 21 deletions

View File

@ -32,7 +32,8 @@ unified_inventory.register_page("bags", {
unified_inventory.register_button("bags", {
type = "image",
image = "ui_bags_icon.png",
tooltip = S("Bags")
tooltip = S("Bags"),
show_with = false, --Modif MFF (Crabman 30/06/2015)
})
for i = 1, 4 do

View File

@ -48,28 +48,34 @@ function unified_inventory.get_formspec(player, page)
return "" -- Invalid page name
end
local privs = minetest.get_player_privs(player_name) --Modif MFF (Crabman 30/06/2015) DEBUT,12 buttons max by row and not show if player has not privs requiered
local button_row = 0
local button_col = 0
local i = 1
-- Main buttons
for i, def in pairs(unified_inventory.buttons) do
if unified_inventory.lite_mode and i > 4 then
button_row = 1
button_col = 1
for _, def in pairs(unified_inventory.buttons) do
if (def.show_with == nil or def.show_with == false) or (privs[def.show_with] and privs[def.show_with] == true) then
if unified_inventory.lite_mode and i > 4 then
button_row = 1
button_col = 1
elseif not unified_inventory.lite_mode and i > 12 then
button_row = 1
i = 1
end
local tooltip = def.tooltip or ""
if def.type == "image" then
formspec = formspec.."image_button["
..( unified_inventory.main_button_x + 0.65 * (i - 1) - button_col * 0.65 * 4)
..","..(unified_inventory.main_button_y + button_row * 0.7)..";0.8,0.8;"
..minetest.formspec_escape(def.image)..";"
..minetest.formspec_escape(def.name)..";]"
.."tooltip["..minetest.formspec_escape(def.name)
..";"..tooltip.."]"
end
i = i + 1
end
local tooltip = def.tooltip or ""
if def.type == "image" then
formspec = formspec.."image_button["
..( unified_inventory.main_button_x + 0.65 * (i - 1) - button_col * 0.65 * 4)
..","..(unified_inventory.main_button_y + button_row * 0.7)..";0.8,0.8;"
..minetest.formspec_escape(def.image)..";"
..minetest.formspec_escape(def.name)..";]"
.."tooltip["..minetest.formspec_escape(def.name)
..";"..tooltip.."]"
end
end
end --Modif MFF (Crabman 30/06/2015) FIN
if fsdata.draw_inventory ~= false then
-- Player inventory

View File

@ -33,13 +33,15 @@ trash:set_size("main", 1)
unified_inventory.register_button("craft", {
type = "image",
image = "ui_craft_icon.png",
tooltip = S("Crafting Grid")
tooltip = S("Crafting Grid"),
show_with = false, --Modif MFF (Crabman 30/06/2015)
})
unified_inventory.register_button("craftguide", {
type = "image",
image = "ui_craftguide_icon.png",
tooltip = S("Crafting Guide")
tooltip = S("Crafting Guide"),
show_with = false, --Modif MFF (Crabman 30/06/2015)
})
if not unified_inventory.lite_mode then
@ -47,6 +49,7 @@ if not unified_inventory.lite_mode then
type = "image",
image = "ui_sethome_icon.png",
tooltip = S("Set home position"),
show_with = "interact", --Modif MFF (Crabman 30/06/2015)
action = function(player)
if home.sethome(player:get_player_name()) == true then --modif MFF
minetest.sound_play("dingdong",
@ -59,6 +62,7 @@ if not unified_inventory.lite_mode then
type = "image",
image = "ui_gohome_icon.png",
tooltip = S("Go home"),
show_with = "interact", --Modif MFF (Crabman 30/06/2015)
action = function(player)
if home.tohome(player:get_player_name()) == true then --modif MFF
minetest.sound_play("teleport",
@ -71,6 +75,7 @@ if not unified_inventory.lite_mode then
type = "image",
image = "ui_sun_icon.png",
tooltip = S("Set time to day"),
show_with = "settime", --Modif MFF (Crabman 30/06/2015)
action = function(player)
local player_name = player:get_player_name()
if minetest.check_player_privs(player_name, {settime=true}) then
@ -90,6 +95,7 @@ if not unified_inventory.lite_mode then
type = "image",
image = "ui_moon_icon.png",
tooltip = S("Set time to night"),
show_with = "settime", --Modif MFF (Crabman 30/06/2015)
action = function(player)
local player_name = player:get_player_name()
if minetest.check_player_privs(player_name, {settime=true}) then
@ -110,6 +116,7 @@ unified_inventory.register_button("clear_inv", {
type = "image",
image = "ui_trash_icon.png",
tooltip = S("Clear inventory"),
show_with = "creative", --Modif MFF (Crabman 30/06/2015)
action = function(player)
local player_name = player:get_player_name()
if not unified_inventory.is_creative(player_name) then

View File

@ -112,6 +112,7 @@ unified_inventory.register_button("waypoints", {
type = "image",
image = "ui_waypoints_icon.png",
tooltip = S("Waypoints"),
show_with = false, --Modif MFF (Crabman 30/06/2015)
})
local function update_hud(player, waypoints, temp, i)