mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-26 12:33:43 +01:00
Cycle through alternative receipes when re-clicking on same item
This commit is contained in:
parent
4ba015e39a
commit
9510ed7daa
36
init.lua
36
init.lua
@ -361,24 +361,34 @@ 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 progressive_mode then
|
if item == data.item then
|
||||||
local inv = player:get_inventory()
|
-- Cycle through alternatives when clicking same item again
|
||||||
local _, has_item =
|
if data.recipes_item and #data.recipes_item >= 2 then
|
||||||
craftguide:recipe_in_inv(inv, item)
|
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
|
if progressive_mode then
|
||||||
recipes = craftguide:recipe_in_inv(
|
local inv = player:get_inventory()
|
||||||
inv, item, recipes)
|
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
|
||||||
|
|
||||||
|
data.item = item
|
||||||
|
data.recipe_num = 1
|
||||||
|
data.recipes_item = recipes
|
||||||
|
craftguide:get_formspec(player_name, is_fuel)
|
||||||
end
|
end
|
||||||
|
|
||||||
data.item = item
|
|
||||||
data.recipe_num = 1
|
|
||||||
data.recipes_item = recipes
|
|
||||||
craftguide:get_formspec(player_name, is_fuel)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user