From d260c46fb437dff4fe35d3a181662ed376eff551 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 2 Aug 2016 16:28:03 +0200 Subject: Register Minetest Game factoids --- init.lua | 76 ++++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 28 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index c24ef4d..7395be2 100644 --- a/init.lua +++ b/init.lua @@ -57,37 +57,57 @@ doc.sub.items.add_damage_group_names(damagegroups) doc.sub.items.add_forced_node_entries(forced_nodes) doc.sub.items.add_item_name_overrides(item_name_overrides) ---[[ - -- minetest_game factoids - - -- Fire - if data.def.groups.flammable == 1 then - formstring = formstring .. "This block is flammable and burns slowly.\n" - elseif data.def.groups.flammable == 2 then - formstring = formstring .. "This block is flammable and burns at medium speed.\n" - elseif data.def.groups.flammable == 3 then - formstring = formstring .. "This block is highly flammable and burns very quickly.\n" - elseif data.def.groups.flammable == 4 then - formstring = formstring .. "This block is very easily set on fire and burns extremely quickly.\n" - elseif data.def.groups.flammable ~= nil then - formstring = formstring .. "This block is flammable.\n" - end - if data.def.groups.puts_out_fire ~= nil then - formstring = formstring .. "This block will extinguish nearby fire.\n" - end +-- Minetest Game Factoids - -- Other noteworthy groups - if data.def.groups.flora == 1 then - formstring = formstring .. "This block belongs to the Flora group. It a living organism which likes to grow and spread on dirt with grass or dirt with dry grass when it is in light. On desert sand, it will wither and die and turn into a dry shrub.\n" - end +-- Groups flammable, puts_out_fire +local function f_fire(itemstring, def) + local s = "" + -- Fire + if def.groups.flammable == 1 then + s = s .. "This block is flammable and burns slowly." + elseif def.groups.flammable == 2 then + s = s .. "This block is flammable and burns at medium speed." + elseif def.groups.flammable == 3 then + s = s .. "This block is highly flammable and burns very quickly." + elseif def.groups.flammable == 4 then + s = s .. "This block is very easily set on fire and burns extremely quickly." + elseif def.groups.flammable ~= nil then + s = s .. "This block is flammable." + end - if data.def.groups.soil == 1 then - formstring = formstring .. "This block is natural soil. It supports the spreading of blocks belonging to the Flora group and the growth of blocks belonging to the Saplings group.\n" - elseif data.def.groups.soil == 2 or data.def.groups.soil == 3 then - formstring = formstring .. "This block serves as a soil for wild plants (Flora, Saplings) as well as plants grown from seeds. It supports their growth and spreading.\n" - end -]] + if def.groups.puts_out_fire ~= nil then + if def.groups.flammable ~= nil then + s = s .. "\n" + end + s = s .. "This block will extinguish nearby fire." + end + return s +end + +-- flora group +local function f_flora(itemstring, def) + if def.groups.flora == 1 then + return "This block belongs to the Flora group. It a living organism which likes to grow and spread on dirt with grass or dirt with dry grass when it is in light. On desert sand, it will wither and die and turn into a dry shrub." + else + return "" + end +end + +-- soil group +local function f_soil(itemstring, def) + if def.groups.soil == 1 then + return "This block is natural soil. It supports the spreading of blocks belonging to the Flora group and the growth of blocks belonging to the Saplings group." + elseif def.groups.soil == 2 or def.groups.soil == 3 then + return "This block serves as a soil for wild plants (Flora, Saplings) as well as plants grown from seeds. It supports their growth and spreading." + else + return "" + end +end + +doc.sub.items.register_factoid("nodes", "groups", f_fire) +doc.sub.items.register_factoid("nodes", "groups", f_flora) +doc.sub.items.register_factoid("nodes", "groups", f_soil) -- Add node aliases for i=2,5 do -- cgit v1.2.3