Cycle through alternative receipes when re-clicking on same item

This commit is contained in:
Wuzzy 2017-02-17 21:21:46 +01:00 committed by JPG
parent 4ba015e39a
commit 9510ed7daa

@ -361,10 +361,19 @@ mt.register_on_player_receive_fields(function(player, formname, fields)
item = item:sub(1,-5) item = item:sub(1,-5)
end end
local recipes = get_recipes(item)
local is_fuel = get_fueltime(item) > 0 local is_fuel = get_fueltime(item) > 0
local recipes = get_recipes(item)
if not recipes and not is_fuel then return end if not recipes and not is_fuel then return end
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 progressive_mode then if progressive_mode then
local inv = player:get_inventory() local inv = player:get_inventory()
local _, has_item = local _, has_item =
@ -382,6 +391,7 @@ mt.register_on_player_receive_fields(function(player, formname, fields)
end end
end end
end end
end
end) end)
function craftguide:on_use(itemstack, user) function craftguide:on_use(itemstack, user)