diff options
| author | Wuzzy <almikes@aol.com> | 2016-07-19 17:45:46 +0200 | 
|---|---|---|
| committer | Wuzzy <almikes@aol.com> | 2016-07-19 17:45:46 +0200 | 
| commit | f87ed72eb2367eb1aa91c199bbf32d37fd2ef25a (patch) | |
| tree | a2004e8650ff0d935e45e8fb38e34653e4d18efd | |
| parent | 20b5bd94fb4e3bfe6fa8cb51f6de07baf8ea032f (diff) | |
Add fuel burning time
| -rw-r--r-- | init.lua | 33 | 
1 files changed, 31 insertions, 2 deletions
| @@ -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 | 
