Can search using button or hitting enter

Small change to allow searches using the ? button or hitting enter.
This commit is contained in:
tenplus1 2016-02-22 15:30:06 +00:00
parent 3285ea6ec0
commit d948759858

View File

@ -116,24 +116,27 @@ minetest.register_on_player_receive_fields(function(player, listname, fields)
if fields.clear then
craftguide:get_items(nil, player_name)
craftguide:get_formspec(stack, 1, nil, 1, "", player_name)
return
elseif fields.alternate then
local item = formspec:match("item_image_button%[.*;([%w_:]+);") or 1
local recipe_num = tonumber(formspec:match("Recipe%s(%d+)")) or 1
recipe_num = recipe_num + 1
craftguide:get_formspec(stack, pagenum, item, recipe_num, filter, player_name)
elseif fields.search then
local lowstr = fields.filter:lower()
craftguide:get_items(lowstr, player_name)
craftguide:get_formspec(stack, 1, nil, 1, lowstr, player_name)
return
elseif fields.prev or fields.next then
if fields.prev then pagenum = pagenum - 1
else pagenum = pagenum + 1 end
craftguide:get_formspec(stack, pagenum, nil, 1, filter, player_name)
else for item in pairs(fields) do
if minetest.get_craft_recipe(item).items then
return
elseif fields.search or fields.filter then
local lowstr = fields.filter:lower()
craftguide:get_items(lowstr, player_name)
craftguide:get_formspec(stack, 1, nil, 1, lowstr, player_name)
end
for item in pairs(fields) do
if minetest.get_craft_recipe(item).items then
craftguide:get_formspec(stack, pagenum, item, 1, filter, player_name)
end
end
end
end
end)