summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2017-02-17 21:21:46 +0100
committerJPG <jeanpatrick.guerrero@gmail.com>2017-02-17 21:21:49 +0100
commit9510ed7daa6075f7f2b3c694ed2f34677f3216fe (patch)
treef42b768196b9ea5714f1e824e154119947d844c2
parent4ba015e39a70725cab0531ee9e4f2fc1095fad00 (diff)
Cycle through alternative receipes when re-clicking on same item1.0
-rw-r--r--init.lua36
1 files changed, 23 insertions, 13 deletions
diff --git a/init.lua b/init.lua
index e1f4e52..a04a8e0 100644
--- a/init.lua
+++ b/init.lua
@@ -361,24 +361,34 @@ mt.register_on_player_receive_fields(function(player, formname, fields)
item = item:sub(1,-5)
end
- local recipes = get_recipes(item)
local is_fuel = get_fueltime(item) > 0
+ local recipes = get_recipes(item)
if not recipes and not is_fuel then return end
- if progressive_mode then
- local inv = player:get_inventory()
- local _, has_item =
- craftguide:recipe_in_inv(inv, item)
+ if item == data.item then
+ -- Cycle through alternatives when clicking same item again
+ if data.recipes_item and #data.recipes_item >= 2 then
+ local recipe = data.recipes_item[data.recipe_num + 1]
+ data.recipe_num = recipe and data.recipe_num + 1 or 1
+ craftguide:get_formspec(player_name)
+ end
+ else
- if not has_item then return end
- recipes = craftguide:recipe_in_inv(
- inv, item, recipes)
- end
+ if progressive_mode then
+ local inv = player: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
end
end