mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-23 03:13:44 +01:00
Don't look up for progressive mode stuff in normal mode
This commit is contained in:
parent
01a846d2a3
commit
d06f2c8cef
24
init.lua
24
init.lua
@ -7,7 +7,7 @@ local remove, maxn, sort = table.remove, table.maxn, table.sort
|
|||||||
local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil
|
local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil
|
||||||
|
|
||||||
local iX, iY = (minetest.setting_get("craftguide_size") or "8x3"):match(
|
local iX, iY = (minetest.setting_get("craftguide_size") or "8x3"):match(
|
||||||
"([%d]+)[.%d+]*[^%d]*x[^%d]*([%d]+)[.%d+]*")
|
"([%d]+)[.%d+]*x([%d]+)[.%d+]*")
|
||||||
iX, iY = max(8, iX or 8), max(1, iY or 3)
|
iX, iY = max(8, iX or 8), max(1, iY or 3)
|
||||||
local ipp = iX * iY
|
local ipp = iX * iY
|
||||||
local xoffset = iX / 2 + (iX % 2 == 0 and 0.5 or 0)
|
local xoffset = iX / 2 + (iX % 2 == 0 and 0.5 or 0)
|
||||||
@ -209,10 +209,11 @@ local function player_has_item(T)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function group_to_items(group)
|
local function group_to_items(group)
|
||||||
local items_with_group = {}
|
local items_with_group, counter = {}, 0
|
||||||
for name, def in pairs(minetest.registered_items) do
|
for name, def in pairs(minetest.registered_items) do
|
||||||
if def.groups[group:sub(7)] then
|
if def.groups[group:sub(7)] then
|
||||||
items_with_group[#items_with_group+1] = name
|
counter = counter + 1
|
||||||
|
items_with_group[counter] = name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return items_with_group
|
return items_with_group
|
||||||
@ -274,6 +275,7 @@ end
|
|||||||
|
|
||||||
function craftguide:get_filter_items(player_name)
|
function craftguide:get_filter_items(player_name)
|
||||||
local data = datas[player_name]
|
local data = datas[player_name]
|
||||||
|
local filter = data.filter
|
||||||
local items_list = progressive_mode and data.items or data.init_items
|
local items_list = progressive_mode and data.items or data.init_items
|
||||||
local player = minetest.get_player_by_name(player_name)
|
local player = minetest.get_player_by_name(player_name)
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
@ -281,14 +283,22 @@ function craftguide:get_filter_items(player_name)
|
|||||||
|
|
||||||
for i=1, #items_list do
|
for i=1, #items_list do
|
||||||
local item = items_list[i]
|
local item = items_list[i]
|
||||||
local _, has_item = self:recipe_in_inv(inv, item)
|
local item_desc =
|
||||||
|
minetest.registered_items[item].description:lower()
|
||||||
|
|
||||||
if (data.filter ~= "" and item:find(data.filter, 1, true)) or
|
if filter ~= "" then
|
||||||
(data.filter == "" and progressive_mode and
|
if item:find(filter, 1, true) or
|
||||||
has_item) then
|
item_desc:find(filter, 1, true) then
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
filtered_list[counter] = item
|
filtered_list[counter] = item
|
||||||
end
|
end
|
||||||
|
elseif progressive_mode then
|
||||||
|
local _, has_item = self:recipe_in_inv(inv, item)
|
||||||
|
if has_item then
|
||||||
|
counter = counter + 1
|
||||||
|
filtered_list[counter] = item
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
data.items = filtered_list
|
data.items = filtered_list
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user