mirror of
https://github.com/minetest/minetest_game.git
synced 2024-11-05 23:33:51 +01:00
Shelves: Fix listring functionality + code cleaning
This commit is contained in:
parent
14334a1d89
commit
12bcfeab4d
@ -1574,43 +1574,16 @@ minetest.register_node("default:bookshelf", {
|
|||||||
inv:set_size("books", 8 * 2)
|
inv:set_size("books", 8 * 2)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.get_meta(pos);
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
local inv = meta:get_inventory()
|
|
||||||
return inv:is_empty("books")
|
return inv:is_empty("books")
|
||||||
end,
|
end,
|
||||||
|
allow_metadata_inventory_put = function(pos, listname, index, stack)
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
if minetest.get_item_group(stack:get_name(), "book") ~= 0 then
|
||||||
local meta = minetest.get_meta(pos)
|
return stack:get_count()
|
||||||
local inv = meta:get_inventory()
|
|
||||||
local to_stack = inv:get_stack(listname, index)
|
|
||||||
if listname == "books" then
|
|
||||||
if minetest.get_item_group(stack:get_name(), "book") ~= 0
|
|
||||||
and to_stack:is_empty() then
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
return 0
|
||||||
end,
|
end,
|
||||||
|
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
allow_metadata_inventory_move = function(pos, from_list, from_index,
|
|
||||||
to_list, to_index, count, player)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
local stack = inv:get_stack(from_list, from_index)
|
|
||||||
local to_stack = inv:get_stack(to_list, to_index)
|
|
||||||
if to_list == "books" then
|
|
||||||
if minetest.get_item_group(stack:get_name(), "book") ~= 0
|
|
||||||
and to_stack:is_empty() then
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
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))
|
||||||
end,
|
end,
|
||||||
|
@ -24,54 +24,29 @@ minetest.register_node("vessels:shelf", {
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", vessels_shelf_formspec)
|
meta:set_string("formspec", vessels_shelf_formspec)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("vessels", 8*2)
|
inv:set_size("vessels", 8 * 2)
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.get_meta(pos);
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
local inv = meta:get_inventory()
|
|
||||||
return inv:is_empty("vessels")
|
return inv:is_empty("vessels")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
local meta = minetest.get_meta(pos)
|
if minetest.get_item_group(stack:get_name(), "vessel") ~= 0 then
|
||||||
local inv = meta:get_inventory()
|
return stack:get_count()
|
||||||
local to_stack = inv:get_stack(listname, index)
|
|
||||||
if listname == "vessels" then
|
|
||||||
if minetest.get_item_group(stack:get_name(), "vessel") ~= 0
|
|
||||||
and to_stack:is_empty() then
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
return 0
|
||||||
end,
|
end,
|
||||||
|
|
||||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
local stack = inv:get_stack(from_list, from_index)
|
|
||||||
local to_stack = inv:get_stack(to_list, to_index)
|
|
||||||
if to_list == "vessels" then
|
|
||||||
if minetest.get_item_group(stack:get_name(), "vessel") ~= 0
|
|
||||||
and to_stack:is_empty() then
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
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))
|
||||||
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))
|
||||||
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))
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user