From 0e5ee2baa137f5c06a93af235ffabc77a79b0010 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 13 Jun 2014 03:41:50 +0200 Subject: [PATCH] Clean up the turf mess + extend additional_groups --- init.lua | 51 ++++++++++++++++++++------------------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/init.lua b/init.lua index 069e03e..75a2b27 100644 --- a/init.lua +++ b/init.lua @@ -333,12 +333,19 @@ end melttable: Table of melting_point values for each wetness level dropcount: How many lumps nodes of this group drop. If 0, the nodes simply drop themselves (not recommended!) sounds: Sound specification for all nodes - additional_groups: table of additional groups of all the nodes. May be empty or nil (meaning no additional groups). + additional_groups: Either a table of tables of strings, a table of strings or nil. If it is nil, no additional groups will be added to all nodes. If it is a table, the strings are interpreted as group names which will be added to each node. If it is a table of tables strings, you can specify the groups tables for each wetness level (start with index number 0 for dry). ]] function pedology.register_sucky_group(basename, basedescription, lumpbasedescription, maxwet, maxlump, oozeinterval, oozechance, melttable, dropcount, sounds, additional_groups) local oozing, dripinterval local m -- melting_point local lumpdescription + local groups + local nestedgroups = false + if(type(additional_groups) == "table") then + if(type(additional_groups[0]) == "table") then + nestedgroups = true + end + end for w=0, maxwet do if(w==0) then oozing=0 else oozing=1 end @@ -366,7 +373,12 @@ function pedology.register_sucky_group(basename, basedescription, lumpbasedescri } minetest.register_craftitem("pedology:"..basename.."_lump_"..tostring(w), itemdef) end - pedology.register_sucky(basename, (pedology.wetnames[w]).." "..basedescription, lumpdescription, w, oozing, sucky, m, drop, sounds, additional_groups) + if(nestedgroups) then + groups = additional_groups[w] + else + groups = additional_groups + end + pedology.register_sucky(basename, (pedology.wetnames[w]).." "..basedescription, lumpdescription, w, oozing, sucky, m, drop, sounds, groups) -- register dripping if(w>0 and pedology.USE_DRIPS == true) then minetest.register_abm({ @@ -434,35 +446,12 @@ pedology.register_liquid("clay_5", "slurry clay", 128, 2, 5, 0, {a=128, r=146, g ]] --[[ turf ]] ---[[pedology.register_sucky_group("turf_fibric", "fibric turf", - 2, 120, 1.25, {1000, 1100, 1200}, sound_silt_coarse, { crumbly = 3, flammable = 1 } ) -pedology.register_sucky_group("turf_hemic", "hemic turf", - 2, 180, 1.225, {1100, 1200, 1300}, sound_silt_coarse, { crumbly = 3, flammable = 1 } ) -pedology.register_sucky_group("turf_sapric", "sapric turf", - 2, 240, 1.2, {1200, 1300, 1400}, sound_silt_coarse, { crumbly = 3, flammable = 1 } )]] - ---[[ TODO (v5.0): Write registration function for turf to condense redundant code. It’s a mess! ]] -pedology.register_sucky("turf_fibric", "dry fibric turf", "dry fibric turf cutting", 0, 0, 1, 1000, 4, sound_silt_coarse, { crumbly = 3, flammable = 1 } ) -pedology.register_sucky("turf_fibric", "wet fibric turf", "wet fibric turf cutting", 1, 1, 1, 1100, 4, sound_silt_coarse, { crumbly = 3 } ) -pedology.register_sucky("turf_fibric", "watery fibric turf", "watery fibric turf cutting", 2, 1, 0, 1200, 4, sound_silt_coarse, { crumbly = 3 } ) - -pedology.register_sucky("turf_hemic", "dry hemic turf", "dry hemic turf cutting", 0, 0, 1, 1100, 3, sound_silt_coarse, { crumbly = 3, flammable = 1 } ) -pedology.register_sucky("turf_hemic", "wet hemic turf", "wet hemic turf cutting", 1, 1, 1, 1200, 3, sound_silt_coarse, { crumbly = 3 } ) -pedology.register_sucky("turf_hemic", "watery hemic turf", "watery hemic turf cutting", 2, 1, 0, 1300, 3, sound_silt_coarse, { crumbly = 3 } ) - -pedology.register_sucky("turf_sapric", "dry sapric turf", "dry sapric turf cutting", 0, 0, 1, 1200, 2, sound_silt_coarse, { crumbly = 3, flammable = 1 } ) -pedology.register_sucky("turf_sapric", "wet sapric turf", "wet sapric turf cutting", 1, 1, 1, 1300, 2, sound_silt_coarse, { crumbly = 3 } ) -pedology.register_sucky("turf_sapric", "watery sapric turf", "watery sapric turf cutting", 2, 1, 0, 1400, 2, sound_silt_coarse, { crumbly = 3 } ) - -minetest.register_abm({ -nodenames = {"group:turf_fibric"}, neighbors = {"group:sucky"}, interval = 120, chance = 1.25, action = pedology.ooze -}) -minetest.register_abm({ -nodenames = {"group:turf_hemic"}, neighbors = {"group:sucky"}, interval = 180, chance = 1.225, action = pedology.ooze -}) -minetest.register_abm({ -nodenames = {"group:turf_sapric"}, neighbors = {"group:sucky"}, interval = 240, chance = 1.5, action = pedology.ooze -}) +pedology.register_sucky_group("turf_fibric", "fibric turf", "fibric turf cutting", + 2, 2, 120, 1.25, {1000, 1100, 1200}, 4, sound_silt_coarse, { [0] = { crumbly = 3, flammable = 1 }, { crumbly = 3 }, {crumbly = 3} } ) +pedology.register_sucky_group("turf_hemic", "hemic turf", "hemic turf cutting", + 2, 2, 180, 1.225, {1100, 1200, 1300}, 3, sound_silt_coarse, { [0] = { crumbly = 3, flammable = 1 }, { crumbly = 3 }, { crumbly = 3 } } ) +pedology.register_sucky_group("turf_sapric", "sapric turf", "sapric turf cutting", + 2, 2, 240, 1.2, {1200, 1300, 1400}, 2, sound_silt_coarse, { [0] = { crumbly = 3, flammable = 1 }, { crumbly = 3 }, { crumbly = 3 } } ) minetest.register_craft({ type = "fuel",