From f87ed72eb2367eb1aa91c199bbf32d37fd2ef25a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 19 Jul 2016 17:45:46 +0200 Subject: Add fuel burning time --- init.lua | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 76b1074..63a2295 100644 --- a/init.lua +++ b/init.lua @@ -28,6 +28,16 @@ local groups_to_string = function(grouptable) return gstring end +local burntime_to_text = function(burntime) + if burntime == nil then + return "unknown" + elseif burntime == 1 then + return "1 second" + else + return string.format("%d seconds", burntime) + end +end + doc.new_category("nodes", { name = "Blocks", build_formspec = function(data) @@ -233,10 +243,17 @@ doc.new_category("nodes", { -- Show other “exposable” groups local gstring = groups_to_string(data.def.groups) if gstring ~= nil then - formstring = formstring .. "This block is member of the following additional groups: "..groups_to_string(data.def.groups).."\n" + formstring = formstring .. "This block is member of the following additional groups: "..groups_to_string(data.def.groups).."\n\n" + end + + + -- Show fuel recipe + local result = minetest.get_craft_result({method = "fuel", items = {data.itemstring}}) + if result ~= nil and result.time > 0 then + formstring = formstring .. "This block can serve as a fuel with a burning time of "..burntime_to_text(result.time)..".\n" end - + formstring = formstring .. ";]" return formstring @@ -291,6 +308,12 @@ doc.new_category("tools", { formstring = formstring .. "This item will point to liquids rather than ignore them.\n" end + -- Show fuel recipe + local result = minetest.get_craft_result({method = "fuel", items = {data.itemstring}}) + if result ~= nil and result.time > 0 then + formstring = formstring .. "This tool can serve as a fuel with a burning time of "..burntime_to_text(result.time)..".\n" + end + formstring = formstring .. ";]" return formstring @@ -346,6 +369,12 @@ doc.new_category("craftitems", { formstring = formstring .. "This tool will point to liquids rather than ignore them.\n" end + -- Show fuel recipe + local result = minetest.get_craft_result({method = "fuel", items = {data.itemstring}}) + if result ~= nil and result.time > 0 then + formstring = formstring .. "This item can serve as a fuel with a burning time of "..burntime_to_text(result.time)..".\n" + end + formstring = formstring .. ";]" return formstring -- cgit v1.2.3