mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-29 13:53:43 +01:00
Fix crash in some specific conditions
This commit is contained in:
parent
ebcedb44b9
commit
0c3287a415
15
init.lua
15
init.lua
@ -32,22 +32,22 @@ function craftguide:extract_groups(itemstr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function craftguide:get_tooltip(item, recipe_type, cooktime, groups)
|
function craftguide:get_tooltip(item, recipe_type, cooktime, groups)
|
||||||
local item_desc = minetest.registered_items[item].description
|
local tooltip = ""
|
||||||
local tooltip = "tooltip["..item..";"..((groups and "") or item_desc)
|
|
||||||
|
|
||||||
if groups then
|
if groups then
|
||||||
local groupstr = "Any item belonging to the "
|
local groupstr = "Any item belonging to the "
|
||||||
for i=1, #groups do
|
for i=1, #groups do
|
||||||
groupstr = groupstr..minetest.colorize("#FFFF00", groups[i])..
|
groupstr = groupstr..minetest.colorize("#FFFF00", groups[i])..
|
||||||
((groups[i+1] and " and ") or "")
|
((groups[i+1] and " and ") or "")
|
||||||
end
|
end
|
||||||
tooltip = tooltip..groupstr.." group(s)"
|
tooltip = "tooltip["..item..";"..groupstr.." group(s)"..
|
||||||
|
((recipe_type ~= "cooking" and "]") or "")
|
||||||
end
|
end
|
||||||
if recipe_type == "cooking" then
|
if recipe_type == "cooking" then
|
||||||
tooltip = tooltip.."\nCooking time: "..minetest.colorize("#FFFF00", cooktime)
|
tooltip = ((groups and tooltip) or ("tooltip["..item..";"))..
|
||||||
|
((groups and "") or minetest.registered_items[item].description)..
|
||||||
|
"\nCooking time: "..minetest.colorize("#FFFF00", cooktime).."]"
|
||||||
end
|
end
|
||||||
|
return tooltip
|
||||||
return tooltip.."]"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function craftguide:get_formspec(player_name)
|
function craftguide:get_formspec(player_name)
|
||||||
@ -166,6 +166,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
else for item in pairs(fields) do
|
else for item in pairs(fields) do
|
||||||
if minetest.get_craft_recipe(item).items then
|
if minetest.get_craft_recipe(item).items then
|
||||||
data.item = item
|
data.item = item
|
||||||
|
data.recipe_num = 1
|
||||||
craftguide:get_formspec(player_name)
|
craftguide:get_formspec(player_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user