From 3fb97d6471544d46e5ea96af16fb9fae0724a49b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 13 Jun 2014 02:09:30 +0200 Subject: [PATCH] New lumps are now coded in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … except sand! --- init.lua | 86 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/init.lua b/init.lua index 97c47da..02d6dc6 100644 --- a/init.lua +++ b/init.lua @@ -289,7 +289,7 @@ pedology.register_liquid("lava_4", "cold lava", 230, 5, 7, 6, {a=230, r=255, g ]] --[[ register a sucky/oozing node to this mod ]] -function pedology.register_sucky(basename, description, wetness, oozing, sucky, melting_point, dropcount, sounds, additional_groups) +function pedology.register_sucky(basename, description, lumpdescription, wetness, oozing, sucky, melting_point, drop, sounds, additional_groups) local wetname = basename.."_"..tostring(wetness) local noncreative local groups = { sucky=sucky, oozing=oozing, wet=wetness, melting_point=melting_point, not_in_creative_inventory = noncreative, [basename]=1 } @@ -301,12 +301,6 @@ function pedology.register_sucky(basename, description, wetness, oozing, sucky, local name = "pedology:"..wetname local itemname - if(dropcount > 0) then - itemname = "pedology:"..basename.."_lump" - drop = itemname .. " " .. tostring(dropcount) - else - drop = nil - end -- If the node is not dry, do not add it into the creative inventory if wetness == 0 then noncreative = 0 else noncreative = 1 end @@ -320,6 +314,7 @@ function pedology.register_sucky(basename, description, wetness, oozing, sucky, sounds = sounds, } minetest.register_node(name, nodedef) + end @@ -332,6 +327,7 @@ end basedescription. The description of the nodes. A proper wetness adjective (“dry”, “wet”, …) will be prepended. lumpdescription. The description component of the “lump” of the node. If nil, no lump is used maxwet: The maximum wetness level of this node group (minimum: 0, maximum: 5) + maxlump: The maximum wetness level of lumps of this node group (minimum: 0, recommended maximum: 3) oozeinterval: The interval in seconds in which it the node may ooze. the Minimal value: 1 oozechance: The inverted chance (1/x) to ooze melttable: Table of melting_point values for each wetness level @@ -339,24 +335,38 @@ end 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). ]] -function pedology.register_sucky_group(basename, basedescription, lumpdescription, maxwet, oozeinterval, oozechance, melttable, dropcount, sounds, additional_groups) +function pedology.register_sucky_group(basename, basedescription, lumpbasedescription, maxwet, maxlump, oozeinterval, oozechance, melttable, dropcount, sounds, additional_groups) local oozing, dripinterval local m -- melting_point - - -- Register drops (if available) - if(dropcount > 0) then - local itemdef = { - description = lumpdescription, - inventory_image = "pedology_lump_"..basename..".png" - } - minetest.register_craftitem("pedology:"..basename.."_lump", itemdef) - end + local lumpdescription for w=0, maxwet do if(w==0) then oozing=0 else oozing=1 end if (w==maxwet and w ~= 5) then sucky=0 else sucky=1 end if melttable == nil then m = 0 else m = melttable[w] end - pedology.register_sucky(basename, (pedology.wetnames[w]).." "..basedescription, w, oozing, sucky, m, dropcount, sounds, additional_groups) + if( lumpbasedescription ~= nil) then + lumpdescription = (pedology.wetnames[w]).." "..lumpbasedescription + else + lumpdescription = nil + end + + local itemname, drop, itemdef + if( maxlump == -1) then + drop = nil + elseif( w > maxlump) then + itemname = "pedology:"..basename.."_lump_"..tostring(maxlump) + drop = itemname .. " " .. tostring(dropcount) + else + itemname = "pedology:"..basename.."_lump_"..tostring(w) + drop = itemname .. " " .. tostring(dropcount) + itemdef = { + description = lumpdescription, + inventory_image = "pedology_lump_inv_"..basename.."_"..tostring(w)..".png", + wield_image = "pedology_lump_"..basename.."_"..tostring(w)..".png" + } + 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) -- register dripping if(w>0 and pedology.USE_DRIPS == true) then minetest.register_abm({ @@ -396,25 +406,25 @@ local sound_gravel_coarse = {footstep = {name="pedology_gravel_footstep", gain=1 --[[ register sucky and oozing nodes ]] --[[ ground nodes ]] pedology.register_sucky_group("clay", "clay", "clay lump", - 5, 60, 1.25, {3000, 3100, 3200, 3500, 3550, 3600}, 4, sound_clay, { crumbly = 3, sun_dry = 1}) + 5, 3, 60, 1.25, {3000, 3100, 3200, 3500, 3550, 3600}, 4, sound_clay, { crumbly = 3, sun_dry = 1}) pedology.register_sucky_group("silt_fine", "fine silt", "fine silt lump", - 5, 45, 1.25, {2800, 2900, 3000, 3100, 3200, 3300}, 4, sound_silt_fine, { crumbly = 3, sun_dry = 1 }) + 5, 3, 45, 1.25, {2800, 2900, 3000, 3100, 3200, 3300}, 4, sound_silt_fine, { crumbly = 3, sun_dry = 1 }) pedology.register_sucky_group("silt_medium", "medium silt", "medium silt lump", - 4, 30, 1.25, {2600, 2800, 3200, 3800, 4200}, 4, sound_silt_medium, { crumbly = 3, sun_dry = 1 }) + 4, 3, 30, 1.25, {2600, 2800, 3200, 3800, 4200}, 4, sound_silt_medium, { crumbly = 3, sun_dry = 1 }) pedology.register_sucky_group("silt_coarse", "coarse silt", "coarse silt lump", - 3, 20, 1.25, {2000, 2200, 2400, 2800}, 4, sound_silt_coarse, { crumbly = 3, sun_dry = 1 }) + 3, 3, 20, 1.25, {2000, 2200, 2400, 2800}, 4, sound_silt_coarse, { crumbly = 3, sun_dry = 1 }) pedology.register_sucky_group("sand_fine", "fine sand", nil, - 2, 10, 1.111111, {1100, 1200, 1300}, 0, sound_sand_fine, { crumbly = 3, sand = 1, sun_dry = 1 }) + 2, -1, 10, 1.111111, {1100, 1200, 1300}, 0, sound_sand_fine, { crumbly = 3, sand = 1, sun_dry = 1 }) pedology.register_sucky_group("sand_medium", "medium sand", nil, - 1, 5, 1.111111, {990, 1100}, 0, sound_sand_medium, { crumbly = 3, sand = 1, sun_dry = 1 }) + 1, -1, 5, 1.111111, {990, 1100}, 0, sound_sand_medium, { crumbly = 3, sand = 1, sun_dry = 1 }) pedology.register_sucky_group("sand_coarse", "coarse sand", nil, - 0, nil, nil, {900}, 0, sound_sand_coarse, { crumbly = 3, sand = 1, sun_dry = 1 }) + 0, -1, nil, nil, {900}, 0, sound_sand_coarse, { crumbly = 3, sand = 1, sun_dry = 1 }) pedology.register_sucky_group("gravel_fine", "fine gravel", "pebble", - 1, 2, 1, {670, 770}, 9, sound_gravel_fine, { crumbly = 2, sun_dry = 1 }) + 1, 0, 2, 1, {670, 770}, 9, sound_gravel_fine, { crumbly = 2, sun_dry = 1 }) pedology.register_sucky_group("gravel_medium", "medium gravel", "medium stone", - 2, 1.5, 1, {600, 800, 1250}, 3, sound_gravel_medium, { crumbly = 2, sun_dry = 1}) + 2, 0, 1.5, 1, {600, 800, 1250}, 3, sound_gravel_medium, { crumbly = 2, sun_dry = 1}) pedology.register_sucky_group("gravel_coarse", "coarse gravel", "big stone", - 2, 1, 1, {500, 750, 1000}, 1, sound_gravel_coarse, { crumbly = 1, sun_dry = 1 }) + 2, 0, 1, 1, {500, 750, 1000}, 1, sound_gravel_coarse, { crumbly = 1, sun_dry = 1 }) --[[ TODO: clay mud @@ -432,17 +442,17 @@ 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", 0, 0, 1, 1000, 4, sound_silt_coarse, { crumbly = 3, flammable = 1 } ) -pedology.register_sucky("turf_fibric", "wet fibric turf", 1, 1, 1, 1100, 4, sound_silt_coarse, { crumbly = 3 } ) -pedology.register_sucky("turf_fibric", "watery fibric turf", 2, 1, 0, 1200, 4, sound_silt_coarse, { crumbly = 3 } ) +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", 0, 0, 1, 1100, 3, sound_silt_coarse, { crumbly = 3, flammable = 1 } ) -pedology.register_sucky("turf_hemic", "wet hemic turf", 1, 1, 1, 1200, 3, sound_silt_coarse, { crumbly = 3 } ) -pedology.register_sucky("turf_hemic", "watery hemic turf", 2, 1, 0, 1300, 3, 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", 0, 0, 1, 1200, 2, sound_silt_coarse, { crumbly = 3, flammable = 1 } ) -pedology.register_sucky("turf_sapric", "wet sapric turf", 1, 1, 1, 1300, 2, sound_silt_coarse, { crumbly = 3 } ) -pedology.register_sucky("turf_sapric", "watery sapric turf", 2, 1, 0, 1400, 2, 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 @@ -454,6 +464,7 @@ minetest.register_abm({ nodenames = {"group:turf_sapric"}, neighbors = {"group:sucky"}, interval = 240, chance = 1.5, action = pedology.ooze }) +--[[ minetest.register_craftitem("pedology:turf_fibric_lump", { description = "fibric turf lump", inventory_image = "pedology_lump_turf_fibric.png" @@ -466,6 +477,7 @@ minetest.register_craftitem("pedology:turf_sapric_lump", { description = "sapric turf lump", inventory_image = "pedology_lump_turf_sapric.png" }) +]] end