Optimization of inventory list handling
This commit is contained in:
parent
b03e048710
commit
17a53a0101
@ -178,7 +178,7 @@ armor.update_armor = function(self, player)
|
||||
state = state + stack:get_wear()
|
||||
count = count + 1
|
||||
if stack:get_count() == 0 then
|
||||
local desc = minetest.registered_items[item].description
|
||||
local desc = minetest.registered_tools[item].description
|
||||
if name and desc then
|
||||
minetest.chat_send_player(name, Sl("Your @1 got destroyed!", desc))
|
||||
end
|
||||
|
@ -21,7 +21,7 @@ minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local armor_inv = minetest.create_detached_inventory(name .. "_armor", {
|
||||
allow_put = function(_, _, index, stack)
|
||||
local item = minetest.registered_items[stack:get_name()]
|
||||
local item = minetest.registered_tools[stack:get_name()]
|
||||
if not item or not item.groups then
|
||||
return 0
|
||||
end
|
||||
|
@ -12,7 +12,7 @@ function default.register_torch(name, def)
|
||||
oldnode.name = name or name .. "_wall" or name .. "_celling"
|
||||
minetest.add_item(pos, ItemStack(oldnode))
|
||||
-- Play flame-extinguish sound if liquid is not an 'igniter'
|
||||
local nodedef = minetest.registered_items[newnode.name]
|
||||
local nodedef = minetest.registered_nodes[newnode.name]
|
||||
if not (nodedef and nodedef.groups and
|
||||
nodedef.groups.igniter and nodedef.groups.igniter > 0) then
|
||||
minetest.sound_play(
|
||||
|
@ -7,7 +7,7 @@ fire = {}
|
||||
-- Flood flame function
|
||||
local function flood_flame(pos, _, newnode)
|
||||
-- Play flame extinguish sound if liquid is not an 'igniter'
|
||||
local nodedef = minetest.registered_items[newnode.name]
|
||||
local nodedef = minetest.registered_nodes[newnode.name]
|
||||
if not (nodedef and nodedef.groups and
|
||||
nodedef.groups.igniter and nodedef.groups.igniter > 0) then
|
||||
minetest.sound_play("fire_extinguish_flame",
|
||||
|
@ -130,11 +130,10 @@ minetest.register_on_dieplayer(function(player)
|
||||
local inv = player:get_inventory()
|
||||
|
||||
-- Drop inventory items
|
||||
for i = 1, inv:get_size("main") do
|
||||
local stack = inv:get_stack("main", i)
|
||||
for _, stack in pairs(inv:get_list("main")) do
|
||||
minetest.item_drop(stack, nil, pos)
|
||||
inv:set_stack("main", i, nil)
|
||||
end
|
||||
inv:set_list("main", {})
|
||||
|
||||
-- Display death coordinates
|
||||
minetest.chat_send_player(player:get_player_name(), Sl("Your last coordinates:") .. " "
|
||||
|
Loading…
x
Reference in New Issue
Block a user