summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJPG <jeanpatrick.guerrero@gmail.com>2016-12-18 16:25:23 +0100
committerJPG <jeanpatrick.guerrero@gmail.com>2016-12-18 16:27:16 +0100
commitd0b3cf2887238275894b067f929f6c00a5d221a1 (patch)
treec32cc4c0010ace67d715ae558738bb042d6d4a2c
parent21dad96162f17a300ffdc9241f01b93dc00c6fa1 (diff)
Attempt to fix #11
-rw-r--r--init.lua45
1 files changed, 20 insertions, 25 deletions
diff --git a/init.lua b/init.lua
index d4f8607..4777e7f 100644
--- a/init.lua
+++ b/init.lua
@@ -335,35 +335,30 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
data.pagenum = data.pagemax
end
craftguide:get_formspec(player_name)
- else
- for item in pairs(fields) do
- if not item:find(":") then break end
- if item:sub(-4) == "_inv" then
- item = item:sub(1,-5)
- end
+ elseif next(fields):find(":") then
+ local item = next(fields)
+ if item:sub(-4) == "_inv" then
+ item = item:sub(1,-5)
+ end
- local recipes = minetest.get_all_craft_recipes(item)
- local is_fuel = minetest.get_craft_result({
- method="fuel", width=1, items={item}}).time > 0
- if not recipes and not is_fuel then return end
+ local recipes = minetest.get_all_craft_recipes(item)
+ local is_fuel = minetest.get_craft_result({
+ method="fuel", width=1, items={item}}).time > 0
+ if not recipes and not is_fuel then return end
- if progressive_mode then
- local who =
- minetest.get_player_by_name(player_name)
- local inv = who:get_inventory()
- local _, has_item =
- craftguide:recipe_in_inv(inv, item)
-
- if not has_item then return end
- recipes = craftguide:recipe_in_inv(
- inv, item, recipes)
- end
+ if progressive_mode then
+ local who = minetest.get_player_by_name(player_name)
+ local inv = who:get_inventory()
+ local _, has_item = craftguide:recipe_in_inv(inv, item)
- data.item = item
- data.recipe_num = 1
- data.recipes_item = recipes
- craftguide:get_formspec(player_name, is_fuel)
+ if not has_item then return end
+ recipes = craftguide:recipe_in_inv(inv, item, recipes)
end
+
+ data.item = item
+ data.recipe_num = 1
+ data.recipes_item = recipes
+ craftguide:get_formspec(player_name, is_fuel)
end
end)