mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Improve inventory callbacks a bit
This commit is contained in:
parent
0a18dda158
commit
983e45ae92
6 changed files with 65 additions and 46 deletions
|
@ -1223,7 +1223,7 @@ minetest.register_node("default:chest_locked", {
|
|||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, count, player)
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if not has_locked_chest_privilege(meta, player) then
|
||||
minetest.log("action", player:get_player_name()..
|
||||
|
@ -1232,7 +1232,7 @@ minetest.register_node("default:chest_locked", {
|
|||
minetest.pos_to_string(pos))
|
||||
return 0
|
||||
end
|
||||
return count
|
||||
return stack:get_count()
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
|
@ -1242,7 +1242,7 @@ minetest.register_node("default:chest_locked", {
|
|||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff to locked chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, count, player)
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" takes stuff from locked chest at "..minetest.pos_to_string(pos))
|
||||
end,
|
||||
|
|
|
@ -534,7 +534,7 @@ local inv = minetest.create_detached_inventory("test_inventory", {
|
|||
experimental.print_to_everything("allow put asked")
|
||||
return 1 -- Allow only 1
|
||||
end,
|
||||
allow_take = function(inv, listname, index, count, player)
|
||||
allow_take = function(inv, listname, index, stack, player)
|
||||
experimental.print_to_everything("allow take asked")
|
||||
return 4 -- Allow 4 at max
|
||||
end,
|
||||
|
@ -544,7 +544,7 @@ local inv = minetest.create_detached_inventory("test_inventory", {
|
|||
on_put = function(inv, listname, index, stack, player)
|
||||
experimental.print_to_everything(player:get_player_name().." put items")
|
||||
end,
|
||||
on_take = function(inv, listname, index, count, player)
|
||||
on_take = function(inv, listname, index, stack, player)
|
||||
experimental.print_to_everything(player:get_player_name().." took items")
|
||||
end,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue