forked from minetest-mods/unified_inventory
Compare commits
37 Commits
70fdb8556b
...
formspec_v
Author | SHA1 | Date | |
---|---|---|---|
0f3ed05da9 | |||
784a4a60a5 | |||
ce160eea55 | |||
eb3b8d9626 | |||
c84c23ff04 | |||
7ad7a6b3a9 | |||
d558d0355d | |||
ff200762c8 | |||
1334ca0202 | |||
cfe21b93fb | |||
036804716e | |||
6da359e9d2 | |||
e4f6e1adc4 | |||
ea4151dfa7 | |||
d063af1d27 | |||
250d038d0b | |||
8a7d8268ad | |||
51de368949 | |||
e61ae0e149 | |||
531442c63e | |||
62881d9938 | |||
55692900f9 | |||
d52303a89e | |||
b9e4b9e455 | |||
4d52ebe774 | |||
73ce55646c | |||
4b39bc86cb | |||
0df814d9d4 | |||
8056bdf966 | |||
7e27f584eb | |||
5140853a3a | |||
a0c06516f4 | |||
5ec4b986bb | |||
0616d1f76b | |||
eb6697aa0d | |||
a5a09bcd3a | |||
e8e1d4d705 |
@ -24,7 +24,7 @@ Unified Inventory replaces the default survival and creative inventory.
|
||||
|
||||
## Requirements
|
||||
|
||||
* Minetest 5.4.0+
|
||||
* Minetest 5.0.0+
|
||||
|
||||
# Licenses
|
||||
|
||||
@ -96,4 +96,4 @@ Other files from Wikimedia Commons:
|
||||
|
||||
RealBadAngel: (CC-BY-4.0)
|
||||
|
||||
* Everything else.
|
||||
* Everything else.
|
4
api.lua
4
api.lua
@ -316,8 +316,8 @@ end
|
||||
function ui.make_trash_slot(xpos, ypos)
|
||||
return
|
||||
ui.single_slot(xpos, ypos)..
|
||||
"image["..xpos..","..ypos..";1.25,1.25;ui_trash_slot_icon.png]"..
|
||||
"list[detached:trash;main;"..(xpos + ui.list_img_offset)..","..(ypos + ui.list_img_offset)..";1,1;]"
|
||||
"image["..xpos..","..ypos..";1.25,1.25;ui_trash_slot_icon.png^[opacity:95]"..
|
||||
"list[detached:trash;main;"..xpos..","..ypos..";1,1;]"
|
||||
end
|
||||
|
||||
function ui.make_inv_img_grid(xpos, ypos, width, height, bright)
|
||||
|
2
bags.lua
2
bags.lua
@ -137,7 +137,7 @@ end
|
||||
local function load_bags_metadata(player, bags_inv)
|
||||
local player_inv = player:get_inventory()
|
||||
local meta = player:get_meta()
|
||||
local bags_meta = meta:get("unified_inventory:bags")
|
||||
local bags_meta = meta:get_string("unified_inventory:bags")
|
||||
local bags = bags_meta and minetest.deserialize(bags_meta) or {}
|
||||
local dirty_meta = false
|
||||
if not bags_meta then
|
||||
|
4
init.lua
4
init.lua
@ -113,7 +113,7 @@ dofile(modpath.."/api.lua")
|
||||
for _, style in ipairs({ui.style_full, ui.style_lite}) do
|
||||
style.items_per_page = style.pagecols * style.pagerows
|
||||
style.standard_inv = string.format("list[current_player;main;%f,%f;8,4;]",
|
||||
style.std_inv_x + ui.list_img_offset, style.std_inv_y + ui.list_img_offset)
|
||||
style.std_inv_x+0.13, style.std_inv_y+0.13)
|
||||
|
||||
style.standard_inv_bg = ui.make_inv_img_grid(style.std_inv_x, style.std_inv_y, 8, 1, true)..
|
||||
ui.make_inv_img_grid(style.std_inv_x, style.std_inv_y + ui.imgscale, 8, 3)
|
||||
@ -159,5 +159,3 @@ dofile(modpath.."/item_names.lua")
|
||||
if minetest.get_modpath("datastorage") then
|
||||
dofile(modpath.."/waypoints.lua")
|
||||
end
|
||||
|
||||
minetest.log("action", "[unified_inventory] loaded.")
|
||||
|
@ -72,21 +72,17 @@ function ui.get_formspec(player, page)
|
||||
end
|
||||
end
|
||||
|
||||
local j = 1 --Modif NALC (sys4 20/11/2018) 12 buttons max by row
|
||||
for i, def in pairs(filtered_inv_buttons) do
|
||||
|
||||
if draw_lite_mode and i > 4 then
|
||||
button_row = 1
|
||||
button_col = 1
|
||||
elseif not draw_lite_mode and j > 12 then
|
||||
button_row = 1
|
||||
j = 1
|
||||
end
|
||||
|
||||
if def.type == "image" then
|
||||
if (def.condition == nil or def.condition(player) == true) then
|
||||
formspec[n] = string.format("image_button[%f,%f;%f,%f;%s;%s;]",
|
||||
ui_peruser.main_button_x + ui_peruser.btn_spc * (j - 1) - button_col * ui_peruser.btn_spc * 4, -- Modif NALC
|
||||
ui_peruser.main_button_x + ui_peruser.btn_spc * (i - 1) - button_col * ui_peruser.btn_spc * 4,
|
||||
ui_peruser.main_button_y + button_row * ui_peruser.btn_spc,
|
||||
ui_peruser.btn_size,ui_peruser.btn_size,
|
||||
F(def.image),
|
||||
@ -95,13 +91,12 @@ function ui.get_formspec(player, page)
|
||||
n = n+2
|
||||
else
|
||||
formspec[n] = string.format("image[%f,%f;%f,%f;%s^[colorize:#808080:alpha]",
|
||||
ui_peruser.main_button_x + ui_peruser.btn_spc * (j - 1) - button_col * ui_peruser.btn_spc * 4, -- Modif NALC
|
||||
ui_peruser.main_button_x + ui_peruser.btn_spc * (i - 1) - button_col * ui_peruser.btn_spc * 4,
|
||||
ui_peruser.main_button_y + button_row * ui_peruser.btn_spc,
|
||||
ui_peruser.btn_size,ui_peruser.btn_size,def.image)
|
||||
n = n+1
|
||||
end
|
||||
end
|
||||
j = j + 1 -- Modif NALC
|
||||
end
|
||||
|
||||
if fsdata.draw_inventory ~= false then
|
||||
|
51
register.lua
51
register.lua
@ -41,6 +41,55 @@ ui.register_button("craftguide", {
|
||||
tooltip = S("Crafting Guide")
|
||||
})
|
||||
|
||||
ui.register_button("home_gui_set", {
|
||||
type = "image",
|
||||
image = "ui_sethome_icon.png",
|
||||
tooltip = S("Set home position"),
|
||||
hide_lite=true,
|
||||
action = function(player)
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.check_player_privs(player_name, {home=true}) then
|
||||
ui.set_home(player, player:get_pos())
|
||||
local home = ui.home_pos[player_name]
|
||||
if home ~= nil then
|
||||
minetest.sound_play("dingdong",
|
||||
{to_player=player_name, gain = 1.0})
|
||||
minetest.chat_send_player(player_name,
|
||||
S("Home position set to: @1", minetest.pos_to_string(home)))
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(player_name,
|
||||
S("You don't have the \"home\" privilege!"))
|
||||
ui.set_inventory_formspec(player, ui.current_page[player_name])
|
||||
end
|
||||
end,
|
||||
condition = function(player)
|
||||
return minetest.check_player_privs(player:get_player_name(), {home=true})
|
||||
end,
|
||||
})
|
||||
|
||||
ui.register_button("home_gui_go", {
|
||||
type = "image",
|
||||
image = "ui_gohome_icon.png",
|
||||
tooltip = S("Go home"),
|
||||
hide_lite=true,
|
||||
action = function(player)
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.check_player_privs(player_name, {home=true}) then
|
||||
if ui.go_home(player) then
|
||||
minetest.sound_play("teleport", {to_player = player_name})
|
||||
end
|
||||
else
|
||||
minetest.chat_send_player(player_name,
|
||||
S("You don't have the \"home\" privilege!"))
|
||||
ui.set_inventory_formspec(player, ui.current_page[player_name])
|
||||
end
|
||||
end,
|
||||
condition = function(player)
|
||||
return minetest.check_player_privs(player:get_player_name(), {home=true})
|
||||
end,
|
||||
})
|
||||
|
||||
ui.register_button("misc_set_day", {
|
||||
type = "image",
|
||||
image = "ui_sun_icon.png",
|
||||
@ -143,7 +192,7 @@ ui.register_page("craft", {
|
||||
formspec[n] = ui.single_slot(craftx - 2.5, crafty + 2.5)
|
||||
formspec[n+1] = string.format("label[%f,%f;%s]", craftx - 2.3, crafty + 2.4,F(S("Refill:")))
|
||||
formspec[n+2] = string.format("list[detached:%srefill;main;%f,%f;1,1;]",
|
||||
F(player_name), craftx - 2.5 + ui.list_img_offset, crafty + 2.5 + ui.list_img_offset)
|
||||
F(player_name), craftx - 2.2 - ui.list_img_offset, crafty + 2.5 + ui.list_img_offset)
|
||||
end
|
||||
return {formspec=table.concat(formspec)}
|
||||
end,
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 697 B After Width: | Height: | Size: 1.0 KiB |
Reference in New Issue
Block a user