summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJP Guerrero <jeanpatrick.guerrero@gmail.com>2016-12-04 00:30:56 +0100
committerJP Guerrero <jeanpatrick.guerrero@gmail.com>2016-12-04 00:45:48 +0100
commit0c3287a41554244003a7ddf99a7c62a7ca072e60 (patch)
tree7bd8d15013b793f79f9b029b3a9ea3aabcf4bdca
parentebcedb44b9329335574ff6066743de8782262905 (diff)
Fix crash in some specific conditions
-rw-r--r--init.lua15
1 files changed, 8 insertions, 7 deletions
diff --git a/init.lua b/init.lua
index 6141ea4..7491dc4 100644
--- a/init.lua
+++ b/init.lua
@@ -32,22 +32,22 @@ function craftguide:extract_groups(itemstr)
end
function craftguide:get_tooltip(item, recipe_type, cooktime, groups)
- local item_desc = minetest.registered_items[item].description
- local tooltip = "tooltip["..item..";"..((groups and "") or item_desc)
-
+ local tooltip = ""
if groups then
local groupstr = "Any item belonging to the "
for i=1, #groups do
groupstr = groupstr..minetest.colorize("#FFFF00", groups[i])..
((groups[i+1] and " and ") or "")
end
- tooltip = tooltip..groupstr.." group(s)"
+ tooltip = "tooltip["..item..";"..groupstr.." group(s)"..
+ ((recipe_type ~= "cooking" and "]") or "")
end
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
-
- return tooltip.."]"
+ return tooltip
end
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
if minetest.get_craft_recipe(item).items then
data.item = item
+ data.recipe_num = 1
craftguide:get_formspec(player_name)
end
end