mirror of
https://github.com/minetest-mods/unified_inventory.git
synced 2024-12-29 12:10:24 +01:00
commit
2e00206f58
25
internal.lua
25
internal.lua
@ -107,14 +107,23 @@ function unified_inventory.get_formspec(player, page)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if def.type == "image" then
|
if def.type == "image" then
|
||||||
formspec[n] = "image_button["
|
if (def.condition == nil or def.condition(player) == true) then
|
||||||
formspec[n+1] = ( ui_peruser.main_button_x + 0.65 * (i - 1) - button_col * 0.65 * 4)
|
formspec[n] = "image_button["
|
||||||
formspec[n+2] = ","..(ui_peruser.main_button_y + button_row * 0.7)..";0.8,0.8;"
|
formspec[n+1] = ( ui_peruser.main_button_x + 0.65 * (i - 1) - button_col * 0.65 * 4)
|
||||||
formspec[n+3] = minetest.formspec_escape(def.image)..";"
|
formspec[n+2] = ","..(ui_peruser.main_button_y + button_row * 0.7)..";0.8,0.8;"
|
||||||
formspec[n+4] = minetest.formspec_escape(def.name)..";]"
|
formspec[n+3] = minetest.formspec_escape(def.image)..";"
|
||||||
formspec[n+5] = "tooltip["..minetest.formspec_escape(def.name)
|
formspec[n+4] = minetest.formspec_escape(def.name)..";]"
|
||||||
formspec[n+6] = ";"..(def.tooltip or "").."]"
|
formspec[n+5] = "tooltip["..minetest.formspec_escape(def.name)
|
||||||
n = n+7
|
formspec[n+6] = ";"..(def.tooltip or "").."]"
|
||||||
|
n = n+7
|
||||||
|
else
|
||||||
|
formspec[n] = "image["
|
||||||
|
formspec[n+1] = ( ui_peruser.main_button_x + 0.65 * (i - 1) - button_col * 0.65 * 4)
|
||||||
|
formspec[n+2] = ","..(ui_peruser.main_button_y + button_row * 0.7)..";0.8,0.8;"
|
||||||
|
formspec[n+3] = minetest.formspec_escape(def.image).."^[colorize:#808080:alpha]"
|
||||||
|
n = n+4
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
20
register.lua
20
register.lua
@ -59,8 +59,12 @@ unified_inventory.register_button("home_gui_set", {
|
|||||||
else
|
else
|
||||||
minetest.chat_send_player(player_name,
|
minetest.chat_send_player(player_name,
|
||||||
S("You don't have the \"home\" privilege!"))
|
S("You don't have the \"home\" privilege!"))
|
||||||
|
unified_inventory.set_inventory_formspec(player, unified_inventory.current_page[player_name])
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
condition = function(player)
|
||||||
|
return minetest.check_player_privs(player:get_player_name(), {home=true})
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
unified_inventory.register_button("home_gui_go", {
|
unified_inventory.register_button("home_gui_go", {
|
||||||
@ -77,8 +81,12 @@ unified_inventory.register_button("home_gui_go", {
|
|||||||
else
|
else
|
||||||
minetest.chat_send_player(player_name,
|
minetest.chat_send_player(player_name,
|
||||||
S("You don't have the \"home\" privilege!"))
|
S("You don't have the \"home\" privilege!"))
|
||||||
|
unified_inventory.set_inventory_formspec(player, unified_inventory.current_page[player_name])
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
condition = function(player)
|
||||||
|
return minetest.check_player_privs(player:get_player_name(), {home=true})
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
unified_inventory.register_button("misc_set_day", {
|
unified_inventory.register_button("misc_set_day", {
|
||||||
@ -97,8 +105,12 @@ unified_inventory.register_button("misc_set_day", {
|
|||||||
else
|
else
|
||||||
minetest.chat_send_player(player_name,
|
minetest.chat_send_player(player_name,
|
||||||
S("You don't have the settime privilege!"))
|
S("You don't have the settime privilege!"))
|
||||||
|
unified_inventory.set_inventory_formspec(player, unified_inventory.current_page[player_name])
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
condition = function(player)
|
||||||
|
return minetest.check_player_privs(player:get_player_name(), {settime=true})
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
unified_inventory.register_button("misc_set_night", {
|
unified_inventory.register_button("misc_set_night", {
|
||||||
@ -117,8 +129,12 @@ unified_inventory.register_button("misc_set_night", {
|
|||||||
else
|
else
|
||||||
minetest.chat_send_player(player_name,
|
minetest.chat_send_player(player_name,
|
||||||
S("You don't have the settime privilege!"))
|
S("You don't have the settime privilege!"))
|
||||||
|
unified_inventory.set_inventory_formspec(player, unified_inventory.current_page[player_name])
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
condition = function(player)
|
||||||
|
return minetest.check_player_privs(player:get_player_name(), {settime=true})
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
unified_inventory.register_button("clear_inv", {
|
unified_inventory.register_button("clear_inv", {
|
||||||
@ -133,6 +149,7 @@ unified_inventory.register_button("clear_inv", {
|
|||||||
.." of creative mode to prevent"
|
.." of creative mode to prevent"
|
||||||
.." accidental inventory trashing."
|
.." accidental inventory trashing."
|
||||||
.."\nUse the trash slot instead."))
|
.."\nUse the trash slot instead."))
|
||||||
|
unified_inventory.set_inventory_formspec(player, unified_inventory.current_page[player_name])
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
player:get_inventory():set_list("main", {})
|
player:get_inventory():set_list("main", {})
|
||||||
@ -140,6 +157,9 @@ unified_inventory.register_button("clear_inv", {
|
|||||||
minetest.sound_play("trash_all",
|
minetest.sound_play("trash_all",
|
||||||
{to_player=player_name, gain = 1.0})
|
{to_player=player_name, gain = 1.0})
|
||||||
end,
|
end,
|
||||||
|
condition = function(player)
|
||||||
|
return unified_inventory.is_creative(player:get_player_name())
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
unified_inventory.register_page("craft", {
|
unified_inventory.register_page("craft", {
|
||||||
|
Loading…
Reference in New Issue
Block a user