mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-26 12:33:43 +01:00
Minor cleanup
This commit is contained in:
parent
eb7292da7a
commit
b6181ebd7a
52
init.lua
52
init.lua
@ -758,31 +758,6 @@ local function search(data)
|
|||||||
data.items = filtered_list
|
data.items = filtered_list
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_inv_items(player)
|
|
||||||
local inv = player:get_inventory()
|
|
||||||
local stacks = {}
|
|
||||||
|
|
||||||
for i = 1, #item_lists do
|
|
||||||
local list = inv:get_list(item_lists[i])
|
|
||||||
table_merge(stacks, list)
|
|
||||||
end
|
|
||||||
|
|
||||||
local inv_items, c = {}, 0
|
|
||||||
|
|
||||||
for i = 1, #stacks do
|
|
||||||
local stack = stacks[i]
|
|
||||||
if not stack:is_empty() then
|
|
||||||
local name = stack:get_name()
|
|
||||||
if reg_items[name] then
|
|
||||||
c = c + 1
|
|
||||||
inv_items[c] = name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return inv_items
|
|
||||||
end
|
|
||||||
|
|
||||||
local function init_data(name)
|
local function init_data(name)
|
||||||
player_data[name] = {
|
player_data[name] = {
|
||||||
filter = "",
|
filter = "",
|
||||||
@ -1102,6 +1077,31 @@ if progressive_mode then
|
|||||||
return filtered
|
return filtered
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function get_inv_items(player)
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
local stacks = {}
|
||||||
|
|
||||||
|
for i = 1, #item_lists do
|
||||||
|
local list = inv:get_list(item_lists[i])
|
||||||
|
table_merge(stacks, list)
|
||||||
|
end
|
||||||
|
|
||||||
|
local inv_items, c = {}, 0
|
||||||
|
|
||||||
|
for i = 1, #stacks do
|
||||||
|
local stack = stacks[i]
|
||||||
|
if not stack:is_empty() then
|
||||||
|
local name = stack:get_name()
|
||||||
|
if reg_items[name] then
|
||||||
|
c = c + 1
|
||||||
|
inv_items[c] = name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return inv_items
|
||||||
|
end
|
||||||
|
|
||||||
-- Workaround. Need an engine call to detect when the contents
|
-- Workaround. Need an engine call to detect when the contents
|
||||||
-- of the player inventory changed, instead.
|
-- of the player inventory changed, instead.
|
||||||
local function poll_new_items()
|
local function poll_new_items()
|
||||||
@ -1212,7 +1212,7 @@ M.register_chatcommand("craft", {
|
|||||||
|
|
||||||
function craftguide.show(name, item, show_usages)
|
function craftguide.show(name, item, show_usages)
|
||||||
local func = "craftguide." .. __func() .. "(): "
|
local func = "craftguide." .. __func() .. "(): "
|
||||||
assert(name, func .. "player name missing")
|
assert(is_str(name), func .. "player name missing")
|
||||||
|
|
||||||
local data = player_data[name]
|
local data = player_data[name]
|
||||||
local player = get_player_by_name(name)
|
local player = get_player_by_name(name)
|
||||||
|
Loading…
Reference in New Issue
Block a user