From b3bfd4574edb0324ccc32cee649006815ecdd957 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Mon, 12 Nov 2012 11:49:54 -0500 Subject: [PATCH] Added junglegrass mod properly this time (forgot to delete old .git* files) --- junglegrass/README | 20 ++ junglegrass/changelog.txt | 24 ++ junglegrass/copyright.txt | 3 + junglegrass/depends.txt | 2 + junglegrass/init.lua | 231 ++++++++++++++++++ junglegrass/license.txt | 3 + junglegrass/textures/junglegrass_medium.png | Bin 0 -> 537 bytes junglegrass/textures/junglegrass_short.png | Bin 0 -> 370 bytes junglegrass/textures/junglegrass_shortest.png | Bin 0 -> 325 bytes 9 files changed, 283 insertions(+) create mode 100644 junglegrass/README create mode 100644 junglegrass/changelog.txt create mode 100644 junglegrass/copyright.txt create mode 100644 junglegrass/depends.txt create mode 100644 junglegrass/init.lua create mode 100644 junglegrass/license.txt create mode 100644 junglegrass/textures/junglegrass_medium.png create mode 100644 junglegrass/textures/junglegrass_short.png create mode 100644 junglegrass/textures/junglegrass_shortest.png diff --git a/junglegrass/README b/junglegrass/README new file mode 100644 index 00000000..967b81d0 --- /dev/null +++ b/junglegrass/README @@ -0,0 +1,20 @@ +Since recent versions of Minetest no longer contain jungle biomes, and +hence no jungle grass, I created this mod to re-add said grass back into +the game, with a twist: There are now four different sizes of grasses, +all of which yield a single junglegrass object when gathered (so all +four sizes may be used where jungle grass is called for). The largest +size uses the game's standard jungle grass node, while the others are +defined by this mod. + +Junglegrass will spawn on dirt, grass, sand, desert sand and the tops of +papyrus and cactus (though rarely), and will do so anywhere in the map. +Grass on the ground will grow and eventually die (or turn into dry +shrubs, in the desert), given enough time. + +Adjusting the overall spawn/growth rate is easily done by tweaking the +MAX_RATIO variable at the top of init.lua. A larger value results in +less frequent events. + +Dependencies: none (just the game's default stuff) + +License: cc-by-sa 3.0 for the textures, WTFPL for everything else. diff --git a/junglegrass/changelog.txt b/junglegrass/changelog.txt new file mode 100644 index 00000000..75f708b0 --- /dev/null +++ b/junglegrass/changelog.txt @@ -0,0 +1,24 @@ +Changelog +--------- + +2012-08-03: Mild rewrite to adapt the mod to use perlin noise while spawning. +Also got rid of the random-numbers-inside-abm stuff, now using the abm's own +'chance' parameter instead. Tuned various settings to try to retain the same +overall density and growth rates as in the previous version. Moved this +changelog into a separate file. + +2012-07-12: moved project to github. + +2012-07-09 (a bit later): tuned the spawn/grow rates a bit more, made the +numbers more sane. Added a radius check to limit the density of the spawned +grasses (they won't grow near each other or near dry shrubs or cactus, though +they still grow on the top of said cacti). + +2012-07-09: Added cactus, sand, and desert sand as spawning surfaces. Reduced +and tuned the spawn rates a bit to try to balance things out. Made that which +spawns on grass, dirt, or sand start out at any size, grow over time, and +eventually die off. Limited desert sand to only the first two sizes (the +smallest size will grow one step, eventually), which will eventually die and +turn into dry shrubs. Only the two smallest sizes can spawn on cactus or +papyrus (and they don't grow or die). Fixed slightly off-center smallest size. +Fixed selection boxes. diff --git a/junglegrass/copyright.txt b/junglegrass/copyright.txt new file mode 100644 index 00000000..98d299ff --- /dev/null +++ b/junglegrass/copyright.txt @@ -0,0 +1,3 @@ +Based on flowers mod by ironzorg. +Converted to create junglegrass by Vanessa Ezekowitz +Adapted jungle grass textures by VanessaE, based on the original one. diff --git a/junglegrass/depends.txt b/junglegrass/depends.txt new file mode 100644 index 00000000..3a7daa1d --- /dev/null +++ b/junglegrass/depends.txt @@ -0,0 +1,2 @@ +default + diff --git a/junglegrass/init.lua b/junglegrass/init.lua new file mode 100644 index 00000000..b8e03d67 --- /dev/null +++ b/junglegrass/init.lua @@ -0,0 +1,231 @@ +-- Junglegrass mod by VanessaE (using ironzorg's flowers mod as a basis) +-- 2012-08-03 +-- +-- Now featuring perlin noise for better growth control! :-) +-- +-- License: WTFPL for the code, cc-by-sa for the textures + +math.randomseed(os.time()) + +local DEBUG = 0 + +local SEED = 52453235636 -- chosen by mashing the keyboard ;-) map seed + this = perlin noise seed +local ABUNDANCE = 0.6 -- lower = more abundant +local GROWING_DELAY = 500 -- higher = run the ABM less often +local RADIUS = 7 -- higher = less dense within the biome area + +local GRASSES = { + "junglegrass:shortest", + "junglegrass:short", + "junglegrass:medium", + "default:junglegrass", + "default:dry_shrub", + "default:cactus", +} + +local dbg = function(s) + if DEBUG == 1 then + print('[JUNGLEGRASS] ' .. s) + end +end + +local is_node_loaded = function(nodenames, node_pos) + n = minetest.env:get_node_or_nil(node_pos) + if (n == nil) or (n.name == 'ignore') then + return false + end + return true +end + +junglegrass_spawn_on_surfaces = function(growdelay, grownames, surfaces) + for _, surface in ipairs(surfaces) do + minetest.register_abm({ + nodenames = { surface.name }, + interval = growdelay, + chance = surface.chance, + action = function(pos, node, active_object_count, active_object_count_wider) + local p_top = { x = pos.x, y = pos.y + 1, z = pos.z } + local n_top = minetest.env:get_node(p_top) + local perlin = minetest.env:get_perlin(SEED, 3, 0.5, 150 ) -- using numbers suggested by Splizard + local noise = perlin:get2d({x=p_top.x, y=p_top.z}) + if ( noise > ABUNDANCE ) + and (n_top.name == "air") + and (is_node_loaded(grownames, p_top) == true) + and ((minetest.env:find_node_near(p_top, RADIUS, GRASSES) == nil ) or (surface.name == "default:cactus")) + then + local nnode = grownames[math.random(1, #grownames)] + dbg("Perlin noise value: "..noise) + dbg('Spawning ' + .. nnode .. ' at (' + .. p_top.x .. ', ' + .. p_top.y .. ', ' + .. p_top.z .. ') on ' + .. surface.name) + minetest.env:add_node(p_top, { name = nnode }) + end + end + }) + end +end + +grow_on_surfaces = function(growdelay, grownames, surfaces) + for _, surface in ipairs(surfaces) do + minetest.register_abm({ + nodenames = { surface.name }, + interval = growdelay, + chance = surface.chance, + action = function(pos, node, active_object_count, active_object_count_wider) + local p_top = { x = pos.x, y = pos.y + 1, z = pos.z } + local n_top = minetest.env:get_node(p_top) + local nnode = grownames[math.random(1, #grownames)] + + if (is_node_loaded(grownames, p_top) == true) then + if (n_top.name == "junglegrass:shortest") then + dbg('Growing shortest into short at (' + .. p_top.x .. ', ' + .. p_top.y .. ', ' + .. p_top.z .. ') on ' + .. surface.name) + minetest.env:add_node(p_top, { name = "junglegrass:short" }) + end + + if (surface.name == "default:desert_sand") then + if (n_top.name == "junglegrass:short") or (n_top.name == "junglegrass:medium") or (n_top.name == "default:junglegrass") then + dbg(nnode .. ' in desert turns to dry shrub at (' + .. p_top.x .. ', ' + .. p_top.y .. ', ' + .. p_top.z .. ') on ' + .. surface.name) + minetest.env:add_node(p_top, { name = "default:dry_shrub" }) + end + else + if (n_top.name == "junglegrass:short") then + dbg('Growing short into medium at (' + .. p_top.x .. ', ' + .. p_top.y .. ', ' + .. p_top.z .. ') on ' + .. surface.name) + minetest.env:add_node(p_top, { name = "junglegrass:medium" }) + end + + if (n_top.name == "junglegrass:medium") then + dbg('Growing medium into full size at (' + .. p_top.x .. ', ' + .. p_top.y .. ', ' + .. p_top.z .. ') on ' + .. surface.name) + minetest.env:add_node(p_top, { name = "default:junglegrass" }) + end + + if (n_top.name == "default:junglegrass") then + dbg(nnode .. ' dies at (' + .. p_top.x .. ', ' + .. p_top.y .. ', ' + .. p_top.z .. ') on ' + .. surface.name) + minetest.env:remove_node(p_top) + end + end + end + end + }) + end +end + +-- On regular fertile ground, any size can spawn + +junglegrass_spawn_on_surfaces(GROWING_DELAY, { + "junglegrass:shortest", + "junglegrass:short", + "junglegrass:medium", + "default:junglegrass", + }, { + {name = "default:dirt_with_grass", chance = 2}, + {name = "default:dirt", chance = 2}, + {name = "default:sand", chance = 5}, +}) + +-- On cactus, papyrus, and desert sand, only the two smallest sizes can spawn + +junglegrass_spawn_on_surfaces(GROWING_DELAY, { + "junglegrass:shortest", + "junglegrass:short", + }, { + {name = "default:papyrus", chance = 1.5}, + {name = "default:cactus", chance = 3}, + {name = "default:desert_sand", chance = 10}, +}) + +-- make the grasses grow and die + +grow_on_surfaces(GROWING_DELAY, { + "junglegrass:shortest", + "junglegrass:short", + "junglegrass:medium", + "default:junglegrass", + }, { + {name = "default:dirt_with_grass", chance = 5}, + {name = "default:dirt", chance = 5}, + {name = "default:sand", chance = 5}, + {name = "default:desert_sand", chance = 20} +}) + +-- The actual node definitions + +minetest.register_node('junglegrass:medium', { + description = "Jungle Grass (medium height)", + drawtype = 'plantlike', + tile_images = { 'junglegrass_medium.png' }, + inventory_image = 'junglegrass_medium.png', + wield_image = 'junglegrass_medium.png', + sunlight_propagates = true, + paramtype = 'light', + walkable = false, + groups = { snappy = 3,flammable=2 }, + sounds = default.node_sound_leaves_defaults(), + drop = 'default:junglegrass', + + selection_box = { + type = "fixed", + fixed = {-0.4, -0.5, -0.4, 0.4, 0.5, 0.4}, + }, +}) + +minetest.register_node('junglegrass:short', { + description = "Jungle Grass (short)", + drawtype = 'plantlike', + tile_images = { 'junglegrass_short.png' }, + inventory_image = 'junglegrass_short.png', + wield_image = 'junglegrass_short.png', + sunlight_propagates = true, + paramtype = 'light', + walkable = false, + groups = { snappy = 3,flammable=2 }, + sounds = default.node_sound_leaves_defaults(), + drop = 'default:junglegrass', + selection_box = { + type = "fixed", + fixed = {-0.4, -0.5, -0.4, 0.4, 0.3, 0.4}, + }, +}) + +minetest.register_node('junglegrass:shortest', { + description = "Jungle Grass (very short)", + drawtype = 'plantlike', + tile_images = { 'junglegrass_shortest.png' }, + inventory_image = 'junglegrass_shortest.png', + wield_image = 'junglegrass_shortest.png', + sunlight_propagates = true, + paramtype = 'light', + walkable = false, + groups = { snappy = 3,flammable=2 }, + sounds = default.node_sound_leaves_defaults(), + drop = 'default:junglegrass', + selection_box = { + type = "fixed", + fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}, + }, +}) + + +print("[Junglegrass] Loaded!") diff --git a/junglegrass/license.txt b/junglegrass/license.txt new file mode 100644 index 00000000..2dc8cbf7 --- /dev/null +++ b/junglegrass/license.txt @@ -0,0 +1,3 @@ +All code is WTFPL. +All textures are cc-by-sa 3.0. + diff --git a/junglegrass/textures/junglegrass_medium.png b/junglegrass/textures/junglegrass_medium.png new file mode 100644 index 0000000000000000000000000000000000000000..040452a680e428b4fb0e2ed18b779d7ec8bc78b2 GIT binary patch literal 537 zcmV+!0_OdRP)d0OIyjfp{-(LWL z?dr&Qpi5#yH3|oaqbqBB()oc0x}sfXHR9;XCd;98#wHG%0wQggH|tB=wLnr78qp#q zWmdx(n~J{eTDY8VxQizYt|>oy0FdlYic+zAuw;Mg_;D9c1p=5Jmq=3u*)c zfnhA6ZV6VmO2`EgeT~=Zpe1L2< z%*-49{8`}t-ThP*u`eIo15X#@9z0)7yu(0RvJY~Bp_1UQ29vMfK5Xr){qgT-nn_Dm zRm83W(vnU7<_fNS0}NxIAA!&5m_o!9!o)88{_-hY6~Zm<>N5bKZ91W2SgR z^;?*pyi5Q9>*ZGT1`LNhJdUud&xk2RR;0+w1jo%4d6`%k0HiBtz1#}Yl4A;SI$Y2; zogfX)XMXtRCERO}mONigc)A$(%rt&k6V0BgitM?vBE{3Qvj3oMIx#%sFXn)Pe4Y8Z QT>t<807*qoM6N<$g3$w*xc~qF literal 0 HcmV?d00001 diff --git a/junglegrass/textures/junglegrass_shortest.png b/junglegrass/textures/junglegrass_shortest.png new file mode 100644 index 0000000000000000000000000000000000000000..5f94d3840f5e8686128664b1292d70efd8b1949a GIT binary patch literal 325 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4$}ele^Fu3V@O6yYrJ zh%9Dc;1&j9Muu5)B!GhKC7!;n?048Xc?`MjrXDf?3SIJaaSX9I{dR&a*P#G`mi@~c zO_~%q0yhdYWlUFFn;^WWsdujU2Zgu;=ZFVdQ&MBb@0KQs&@&Et; literal 0 HcmV?d00001