forked from thunderdog1138/star_wars
Do not show item overlay if slot is occupied by item (bookshelf, vessels shelf)
This commit is contained in:
parent
f8bc1e1714
commit
7fbf25d6ca
|
@ -1815,16 +1815,23 @@ local bookshelf_formspec =
|
||||||
"listring[current_player;main]" ..
|
"listring[current_player;main]" ..
|
||||||
default.get_hotbar_bg(0,2.85)
|
default.get_hotbar_bg(0,2.85)
|
||||||
|
|
||||||
-- Inventory slots overlay
|
local function get_bookshelf_formspec(inv)
|
||||||
local bx, by = 0, 0.3
|
local formspec = bookshelf_formspec
|
||||||
for i = 1, 16 do
|
local invlist = inv and inv:get_list("books")
|
||||||
if i == 9 then
|
-- Inventory slots overlay
|
||||||
bx = 0
|
local bx, by = 0, 0.3
|
||||||
by = by + 1
|
for i = 1, 16 do
|
||||||
|
if i == 9 then
|
||||||
|
bx = 0
|
||||||
|
by = by + 1
|
||||||
|
end
|
||||||
|
if not invlist or invlist[i]:is_empty() then
|
||||||
|
formspec = formspec ..
|
||||||
|
"image[" .. bx .. "," .. by .. ";1,1;default_bookshelf_slot.png]"
|
||||||
|
end
|
||||||
|
bx = bx + 1
|
||||||
end
|
end
|
||||||
bookshelf_formspec = bookshelf_formspec ..
|
return formspec
|
||||||
"image[" .. bx .. "," .. by .. ";1,1;default_bookshelf_slot.png]"
|
|
||||||
bx = bx + 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("default:bookshelf", {
|
minetest.register_node("default:bookshelf", {
|
||||||
|
@ -1838,7 +1845,7 @@ minetest.register_node("default:bookshelf", {
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", bookshelf_formspec)
|
meta:set_string("formspec", get_bookshelf_formspec(nil))
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("books", 8 * 2)
|
inv:set_size("books", 8 * 2)
|
||||||
end,
|
end,
|
||||||
|
@ -1855,14 +1862,20 @@ minetest.register_node("default:bookshelf", {
|
||||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name() ..
|
||||||
" moves stuff in bookshelf at " .. minetest.pos_to_string(pos))
|
" moves stuff in bookshelf at " .. minetest.pos_to_string(pos))
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", get_bookshelf_formspec(meta:get_inventory()))
|
||||||
end,
|
end,
|
||||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name() ..
|
||||||
" moves stuff to bookshelf at " .. minetest.pos_to_string(pos))
|
" moves stuff to bookshelf at " .. minetest.pos_to_string(pos))
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", get_bookshelf_formspec(meta:get_inventory()))
|
||||||
end,
|
end,
|
||||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name() ..
|
||||||
" takes stuff from bookshelf at " .. minetest.pos_to_string(pos))
|
" takes stuff from bookshelf at " .. minetest.pos_to_string(pos))
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", get_bookshelf_formspec(meta:get_inventory()))
|
||||||
end,
|
end,
|
||||||
on_blast = function(pos)
|
on_blast = function(pos)
|
||||||
local drops = {}
|
local drops = {}
|
||||||
|
|
|
@ -13,16 +13,23 @@ local vessels_shelf_formspec =
|
||||||
"listring[current_player;main]" ..
|
"listring[current_player;main]" ..
|
||||||
default.get_hotbar_bg(0, 2.85)
|
default.get_hotbar_bg(0, 2.85)
|
||||||
|
|
||||||
-- Inventory slots overlay
|
local function get_vessels_shelf_formspec(inv)
|
||||||
local vx, vy = 0, 0.3
|
local formspec = vessels_shelf_formspec
|
||||||
for i = 1, 16 do
|
local invlist = inv and inv:get_list("vessels")
|
||||||
if i == 9 then
|
-- Inventory slots overlay
|
||||||
vx = 0
|
local vx, vy = 0, 0.3
|
||||||
vy = vy + 1
|
for i = 1, 16 do
|
||||||
|
if i == 9 then
|
||||||
|
vx = 0
|
||||||
|
vy = vy + 1
|
||||||
|
end
|
||||||
|
if not invlist or invlist[i]:is_empty() then
|
||||||
|
formspec = formspec ..
|
||||||
|
"image[" .. vx .. "," .. vy .. ";1,1;vessels_shelf_slot.png]"
|
||||||
|
end
|
||||||
|
vx = vx + 1
|
||||||
end
|
end
|
||||||
vessels_shelf_formspec = vessels_shelf_formspec ..
|
return formspec
|
||||||
"image[" .. vx .. "," .. vy .. ";1,1;vessels_shelf_slot.png]"
|
|
||||||
vx = vx + 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("vessels:shelf", {
|
minetest.register_node("vessels:shelf", {
|
||||||
|
@ -36,7 +43,7 @@ minetest.register_node("vessels:shelf", {
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", vessels_shelf_formspec)
|
meta:set_string("formspec", get_vessels_shelf_formspec(nil))
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("vessels", 8 * 2)
|
inv:set_size("vessels", 8 * 2)
|
||||||
end,
|
end,
|
||||||
|
@ -53,14 +60,20 @@ minetest.register_node("vessels:shelf", {
|
||||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name() ..
|
||||||
" moves stuff in vessels shelf at ".. minetest.pos_to_string(pos))
|
" moves stuff in vessels shelf at ".. minetest.pos_to_string(pos))
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", get_vessels_shelf_formspec(meta:get_inventory()))
|
||||||
end,
|
end,
|
||||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name() ..
|
||||||
" moves stuff to vessels shelf at ".. minetest.pos_to_string(pos))
|
" moves stuff to vessels shelf at ".. minetest.pos_to_string(pos))
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", get_vessels_shelf_formspec(meta:get_inventory()))
|
||||||
end,
|
end,
|
||||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
minetest.log("action", player:get_player_name() ..
|
minetest.log("action", player:get_player_name() ..
|
||||||
" takes stuff from vessels shelf at ".. minetest.pos_to_string(pos))
|
" takes stuff from vessels shelf at ".. minetest.pos_to_string(pos))
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", get_vessels_shelf_formspec(meta:get_inventory()))
|
||||||
end,
|
end,
|
||||||
on_blast = function(pos)
|
on_blast = function(pos)
|
||||||
local drops = {}
|
local drops = {}
|
||||||
|
|
Loading…
Reference in New Issue