Merge pull request #12 from VanessaE/master
Update to work with Unified Inventory since formspec v4 update
This commit is contained in:
commit
74d9135e58
@ -1,7 +1,7 @@
|
||||
local S = minetest.get_translator("unified_inventory")
|
||||
local F = minetest.formspec_escape
|
||||
|
||||
local has_stamina = minetest.global_exists("stamina")
|
||||
local ui = unified_inventory
|
||||
|
||||
-- Backup to inject code
|
||||
unified_inventory_plus.craft_all = unified_inventory.pages["craft"].get_formspec
|
||||
@ -9,9 +9,14 @@ unified_inventory_plus.craft_all = unified_inventory.pages["craft"].get_formspec
|
||||
local function onload()
|
||||
unified_inventory.pages["craft"] = {
|
||||
get_formspec = function(player, perplayer_formspec)
|
||||
local formspecy = perplayer_formspec.formspec_y
|
||||
local formspec = unified_inventory_plus.craft_all(player, perplayer_formspec).formspec
|
||||
formspec = formspec.."button[5.15, "..(formspecy + 1.18)..";0.8,0.6;craft_craftall;"..F(S("All")).."]"
|
||||
formspec = formspec..string.format("image[%f,%f;%f,%f;ui_crafting_long_arrow.png]",
|
||||
perplayer_formspec.craft_arrow_x, perplayer_formspec.craft_y,
|
||||
ui.imgscale, ui.imgscale * 3)..
|
||||
string.format("button[%f,%f;%f,%f;craft_craftall;%s]",
|
||||
perplayer_formspec.craft_arrow_x + 0.23, perplayer_formspec.craft_y + 1.50,
|
||||
perplayer_formspec.btn_size, perplayer_formspec.btn_size,
|
||||
F(S("All")))
|
||||
return {formspec=formspec}
|
||||
end,
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- Clear items in the craft inventory
|
||||
|
||||
local ui = unified_inventory
|
||||
|
||||
-- Backup to inject code
|
||||
unified_inventory_plus.craft_clear = unified_inventory.pages["craft"].get_formspec
|
||||
@ -9,7 +9,10 @@ local function onload()
|
||||
get_formspec = function(player, perplayer_formspec)
|
||||
local formspecy = perplayer_formspec.formspec_y + 1
|
||||
local formspec = unified_inventory_plus.craft_clear(player, perplayer_formspec).formspec
|
||||
formspec = formspec.."image_button[1.25,"..(formspecy)..";0.75,0.75;pattern_clear.png;craft_clear;]"
|
||||
formspec = formspec..string.format("image_button[%f,%f;%f,%f;pattern_clear.png;craft_clear;]",
|
||||
perplayer_formspec.craft_x - perplayer_formspec.btn_spc,
|
||||
perplayer_formspec.craft_y + ui.imgscale,
|
||||
perplayer_formspec.btn_size, perplayer_formspec.btn_size)
|
||||
return {formspec=formspec}
|
||||
end,
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- Organize items in the craft inventory following a pattern:
|
||||
|
||||
local ui = unified_inventory
|
||||
|
||||
-- Backup to inject code
|
||||
unified_inventory_plus.craft_organize = unified_inventory.pages["craft"].get_formspec
|
||||
@ -7,10 +7,24 @@ unified_inventory_plus.craft_organize = unified_inventory.pages["craft"].get_for
|
||||
local function onload()
|
||||
unified_inventory.pages["craft"] = {
|
||||
get_formspec = function(player, perplayer_formspec)
|
||||
local formspecy = perplayer_formspec.formspec_y
|
||||
local formspec = unified_inventory_plus.craft_organize(player, perplayer_formspec).formspec
|
||||
for i,v in ipairs(unified_inventory_plus.craft_patterns) do
|
||||
formspec = formspec.."image_button["..(2.0 + 0.5 * ((i-1)%6))..","..(formspecy - 0.5 * math.ceil(i/6))..";0.5,0.5;"..v.ico..";craft_organize_"..i..";]"
|
||||
local btnsz = ui.imgscale/3
|
||||
local btnspc = ui.imgscale/2
|
||||
|
||||
if perplayer_formspec.pagecols == 4 then -- UI is in lite mode.
|
||||
for i,v in ipairs(unified_inventory_plus.craft_patterns) do
|
||||
formspec = formspec..string.format("image_button[%f,%f;%f,%f;%s;craft_organize_%i;]",
|
||||
perplayer_formspec.craft_x + btnspc * (i-1),
|
||||
perplayer_formspec.craft_y + 0.1 - btnspc,
|
||||
btnsz, btnsz, v.ico, i)
|
||||
end
|
||||
else
|
||||
for i,v in ipairs(unified_inventory_plus.craft_patterns) do
|
||||
formspec = formspec..string.format("image_button[%f,%f;%f,%f;%s;craft_organize_%i;]",
|
||||
perplayer_formspec.craft_x + btnspc * ((i-1)%6) + 0.1,
|
||||
perplayer_formspec.craft_y + 0.22 - (math.ceil(i/6)) * btnspc,
|
||||
btnsz, btnsz, v.ico, i)
|
||||
end
|
||||
end
|
||||
return {formspec=formspec}
|
||||
end,
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- Rotate items in the craft inventory
|
||||
|
||||
local ui = unified_inventory
|
||||
|
||||
-- Backup to inject code
|
||||
unified_inventory_plus.craft_rotate = unified_inventory.pages["craft"].get_formspec
|
||||
@ -9,7 +9,10 @@ local function onload()
|
||||
get_formspec = function(player, perplayer_formspec)
|
||||
local formspecy = perplayer_formspec.formspec_y
|
||||
local formspec = unified_inventory_plus.craft_rotate(player, perplayer_formspec).formspec
|
||||
formspec = formspec.."image_button[1.25,"..(formspecy)..";0.75,0.75;pattern_rotate.png;craft_rotate;]"
|
||||
formspec = formspec..string.format("image_button[%f,%f;%f,%f;pattern_rotate.png;craft_rotate;]",
|
||||
perplayer_formspec.craft_x - perplayer_formspec.btn_spc,
|
||||
perplayer_formspec.craft_y,
|
||||
perplayer_formspec.btn_size, perplayer_formspec.btn_size)
|
||||
return {formspec=formspec}
|
||||
end,
|
||||
}
|
||||
|
1
mod.conf
1
mod.conf
@ -1,3 +1,4 @@
|
||||
name = unified_inventory_plus
|
||||
depends = unified_inventory
|
||||
optional_depends = stamina
|
||||
min_minetest_version = 5.4.0
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 3.4 KiB |
BIN
textures/ui_crafting_long_arrow.png
Normal file
BIN
textures/ui_crafting_long_arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Loading…
x
Reference in New Issue
Block a user