mirror of
https://github.com/mt-mods/pipeworks.git
synced 2024-11-04 17:40:20 +01:00
add i3 inv support + i3 styled trash can
This commit is contained in:
parent
3092ce771f
commit
26db573e80
|
@ -19,6 +19,7 @@ read_globals = {
|
||||||
|
|
||||||
-- mods
|
-- mods
|
||||||
"default", "mesecon", "digiline",
|
"default", "mesecon", "digiline",
|
||||||
"screwdriver", "unified_inventory"
|
"screwdriver", "unified_inventory",
|
||||||
|
"i3",
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
26
common.lua
26
common.lua
|
@ -143,6 +143,32 @@ function fs_helpers.cycling_button(meta, base, meta_name, values)
|
||||||
return base..";"..(texture_name and texture_name..";" or "")..field..";"..minetest.formspec_escape(text)..(addopts and ";"..addopts or "").."]"
|
return base..";"..(texture_name and texture_name..";" or "")..field..";"..minetest.formspec_escape(text)..(addopts and ";"..addopts or "").."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function fs_helpers.get_inv(y)
|
||||||
|
local fs = {}
|
||||||
|
if minetest.get_modpath("i3") then
|
||||||
|
local inv_x = i3.settings.legacy_inventory and 0.75 or 0.22
|
||||||
|
local inv_y = (y + 0.4) or 6.9
|
||||||
|
local size, spacing = 1, 0.1
|
||||||
|
local hotbar_len = i3.settings.hotbar_len
|
||||||
|
|
||||||
|
table.insert(fs, "style_type[box;colors=#77777710,#77777710,#777,#777]")
|
||||||
|
|
||||||
|
for i = 0, hotbar_len - 1 do
|
||||||
|
table.insert(fs, "box["..(i * size + inv_x + (i * spacing))..","..inv_y..";"..size..","..size..";]")
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]")
|
||||||
|
table.insert(fs, "list[current_player;main;"..inv_x..","..inv_y..";"..hotbar_len..",1;]")
|
||||||
|
|
||||||
|
table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]")
|
||||||
|
table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(i3.settings.inv_size / hotbar_len)..";"..hotbar_len.."]")
|
||||||
|
else
|
||||||
|
table.insert(fs, "list[current_player;main;0.22,"..y..";8,4;]")
|
||||||
|
end
|
||||||
|
|
||||||
|
return table.concat(fs, "")
|
||||||
|
end
|
||||||
|
|
||||||
---------
|
---------
|
||||||
-- Env --
|
-- Env --
|
||||||
---------
|
---------
|
||||||
|
|
2
mod.conf
2
mod.conf
|
@ -1,5 +1,5 @@
|
||||||
name = pipeworks
|
name = pipeworks
|
||||||
description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them.
|
description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them.
|
||||||
depends = basic_materials
|
depends = basic_materials
|
||||||
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api
|
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3
|
||||||
min_minetest_version = 5.2.0
|
min_minetest_version = 5.2.0
|
||||||
|
|
21
trashcan.lua
21
trashcan.lua
|
@ -20,13 +20,22 @@ minetest.register_node("pipeworks:trashcan", {
|
||||||
},
|
},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
local prepend = ""
|
||||||
|
if minetest.get_modpath("i3") then
|
||||||
|
prepend = "no_prepend[]bgcolor[black;neither]background9[0,0;10.2,9;i3_bg_full.png;false;10]"
|
||||||
|
end
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec",
|
||||||
"size[8,7]"..
|
"formspec_version[2]" ..
|
||||||
"item_image[0,0;1,1;pipeworks:trashcan]"..
|
"size[10.2,9]"..
|
||||||
"label[1,0;"..S("Trash Can").."]"..
|
prepend ..
|
||||||
"list[context;trash;3.5,1;1,1;]"..
|
"item_image[0.5,0.5;1,1;pipeworks:trashcan]"..
|
||||||
"list[current_player;main;0,3;8,4;]" ..
|
"label[1.5,1;"..S("Trash Can").."]"..
|
||||||
"listring[]")
|
"list[context;trash;4.5,2;1,1;]"..
|
||||||
|
--"list[current_player;main;0,3;8,4;]" ..
|
||||||
|
pipeworks.fs_helpers.get_inv(4)..
|
||||||
|
"listring[context;trash]"..
|
||||||
|
"listring[current_player;main]"
|
||||||
|
)
|
||||||
meta:set_string("infotext", S("Trash Can"))
|
meta:set_string("infotext", S("Trash Can"))
|
||||||
meta:get_inventory():set_size("trash", 1)
|
meta:get_inventory():set_size("trash", 1)
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user