0
0
Fork 0

Craftguide: Cycle through alternatives when clicking on item again

This commit is contained in:
Wuzzy 2017-02-16 02:16:39 +01:00
parent d10f9cc46c
commit 60287ea05b
1 changed files with 26 additions and 16 deletions

View File

@ -453,33 +453,43 @@ mt.register_on_player_receive_fields(function(player, formname, fields)
data.pagenum = 1 data.pagenum = 1
data.iX = data.iX - (fields.size_dec and 1 or -1) data.iX = data.iX - (fields.size_dec and 1 or -1)
craftguide:get_formspec(player_name) craftguide:get_formspec(player_name)
else for item in pairs(fields) do else
for item in pairs(fields) do
if item:find(":") then if item:find(":") then
if item:sub(-4) == "_inv" or item:sub(-4) == "_out" then if item:sub(-4) == "_inv" or item:sub(-4) == "_out" then
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() if data.recipes_item and #data.recipes_item >= 2 then
local _, has_item = local recipe = data.recipes_item[data.recipe_num + 1]
craftguide:recipe_in_inv(inv, item) 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
end) end)