Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
Cycle through alternative receipes when re-clicking on same item
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuzzy authored and kilbith committed Feb 17, 2017
1 parent 4ba015e commit 9510ed7
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9510ed7

Please sign in to comment.