From 20d8a291878bf9f2b5cdbcaf6ceb40e12455d9a9 Mon Sep 17 00:00:00 2001 From: wsor <24964441+wsor4035@users.noreply.github.com> Date: Mon, 9 Aug 2021 23:52:38 -0400 Subject: [PATCH] add grass, cactus, enable in mapgen --- mods/fl_mapgen/decorations.lua | 56 ++++++++++++++++++ mods/fl_mapgen/init.lua | 7 ++- mods/fl_mapgen/mod.conf | 2 +- mods/fl_mapgen/other.lua | 22 +++++++ mods/fl_mapgen/trees.lua | 4 +- mods/fl_plantlife/cactus.lua | 42 +++++++++++++ mods/fl_plantlife/init.lua | 1 + .../fl_plantlife/textures/farlands_cactus.png | Bin 0 -> 1626 bytes 8 files changed, 129 insertions(+), 5 deletions(-) create mode 100644 mods/fl_mapgen/decorations.lua create mode 100644 mods/fl_plantlife/cactus.lua create mode 100644 mods/fl_plantlife/textures/farlands_cactus.png diff --git a/mods/fl_mapgen/decorations.lua b/mods/fl_mapgen/decorations.lua new file mode 100644 index 0000000..bb01d14 --- /dev/null +++ b/mods/fl_mapgen/decorations.lua @@ -0,0 +1,56 @@ +for i = 1, 5 do + minetest.register_decoration({ + name = "fl_plantlife:savannah_grass_" .. i, + deco_type = "simple", + place_on = {"fl_topsoil:savannah_dirt_with_grass"}, + sidelen = 16, + --higher seems to cause mapgen light bugs + fill_ratio = 0.001, + biomes = {"savannah"}, + y_max = 300, + y_min = 4, + param2 = 1, + param2_max = 255, + decoration = "fl_plantlife:savannah_grass_" .. i + }) +end + +for i = 1, 5 do + minetest.register_decoration({ + name = "fl_plantlife:grass_" .. i, + deco_type = "simple", + place_on = {"fl_topsoil:dirt_with_grass"}, + sidelen = 16, + fill_ratio = 0.08, + biomes = {"grassland", "deciduousforest"}, + y_max = 300, + y_min = 4, + param2 = 1, + param2_max = 255, + decoration = "fl_plantlife:grass_" .. i + }) +end + +minetest.register_decoration({ + name = "fl_plantlife:cactus", + deco_type = "schematic", + place_on = {"fl_stone:sand"}, + sidelen = 16, + fill_ratio = 0.0001, + biomes = {"sand"}, + y_max = 300, + y_min = 4, + schematic = { + --for some reason first one never exists? + size = {x=1, y=4, z=1}, + data = { + {name = "fl_plantlife:cactus"}, + {name = "fl_plantlife:cactus"}, + {name = "fl_plantlife:cactus"}, + {name = "fl_plantlife:cactus"}, + }, + yslice_prob = { + {ypos = 3, prob = 160} + } + } +}) \ No newline at end of file diff --git a/mods/fl_mapgen/init.lua b/mods/fl_mapgen/init.lua index f396d44..1f62837 100644 --- a/mods/fl_mapgen/init.lua +++ b/mods/fl_mapgen/init.lua @@ -1,7 +1,6 @@ local modpath = minetest.get_modpath("fl_mapgen") dofile(modpath .. "/aliases.lua") -dofile(modpath .. "/other.lua") dofile(modpath .. "/abm.lua") dofile(modpath .. "/biomes.lua") @@ -9,4 +8,8 @@ dofile(modpath .. "/biomes.lua") dofile(modpath .. "/biome_sky.lua") dofile(modpath .. "/ores.lua") dofile(modpath .. "/trees.lua") -dofile(modpath .. "/dungeon/init.lua") \ No newline at end of file +dofile(modpath .. "/decorations.lua") +dofile(modpath .. "/dungeon/init.lua") + +--at the end as this contains register_on_generateds +dofile(modpath .. "/other.lua") \ No newline at end of file diff --git a/mods/fl_mapgen/mod.conf b/mods/fl_mapgen/mod.conf index 763c775..9e191e4 100644 --- a/mods/fl_mapgen/mod.conf +++ b/mods/fl_mapgen/mod.conf @@ -1 +1 @@ -depends = fl_liquids, fl_stone, fl_ores, fl_topsoil, fl_storage, fl_stairs, fl_trees \ No newline at end of file +depends = fl_liquids, fl_stone, fl_ores, fl_topsoil, fl_storage, fl_stairs, fl_trees, fl_plantlife \ No newline at end of file diff --git a/mods/fl_mapgen/other.lua b/mods/fl_mapgen/other.lua index a15353a..1ca1546 100644 --- a/mods/fl_mapgen/other.lua +++ b/mods/fl_mapgen/other.lua @@ -3,6 +3,7 @@ local bedrock_depth = -300 local bedrock_height = 1 +--create bedrock layers minetest.register_on_generated(function(minp, maxp) if minp.y > bedrock_depth + bedrock_height or maxp.y < bedrock_depth then return @@ -32,6 +33,7 @@ minetest.register_on_generated(function(minp, maxp) vm:write_to_map() end) +--vary snow layers minetest.register_on_generated(function(minp, maxp) local vm, mine, maxe = minetest.get_mapgen_object("voxelmanip") local area = VoxelArea:new({MinEdge=mine, MaxEdge=maxe}) @@ -54,4 +56,24 @@ minetest.register_on_generated(function(minp, maxp) vm:set_param2_data(p2_data) vm:write_to_map() +end) + +--start cactus timers +local cactus_did = minetest.get_decoration_id("fl_plantlife:cactus") +minetest.set_gen_notify("decoration", {cactus_did}) + +minetest.register_on_generated(function(minp, maxp, blockseed) + local g = minetest.get_mapgen_object("gennotify") + local locations = g["decoration#" .. cactus_did] or {} + if #locations == 0 then return end + for _, pos in ipairs(locations) do + for i=1, 3 do + local node = minetest.get_node_or_nil({x=pos.x, y=pos.y+i, z=pos.z}) + if not node then return end + if node.name == "fl_plantlife:cactus" then + local timer = minetest.get_node_timer({x=pos.x, y=pos.y+i, z=pos.z}) + timer:start(math.random(600, 1200)) + end + end + end end) \ No newline at end of file diff --git a/mods/fl_mapgen/trees.lua b/mods/fl_mapgen/trees.lua index 63fc1f5..03fa367 100644 --- a/mods/fl_mapgen/trees.lua +++ b/mods/fl_mapgen/trees.lua @@ -46,7 +46,7 @@ minetest.register_decoration({ place_on = "fl_topsoil:dirt_with_grass", sidelen = 16, fill_ratio = 0.03, - biomes = {"deciduous_forest"}, + biomes = {"deciduousforest"}, y_max = 300, y_min = 4, place_offset_y = 1, @@ -62,7 +62,7 @@ minetest.register_decoration({ place_on = "fl_topsoil:dirt_with_grass", sidelen = 16, fill_ratio = 0.03, - biomes = {"deciduous_forest"}, + biomes = {"deciduousforest"}, y_max = 300, y_min = 4, place_offset_y = 1, diff --git a/mods/fl_plantlife/cactus.lua b/mods/fl_plantlife/cactus.lua new file mode 100644 index 0000000..4f1fe7d --- /dev/null +++ b/mods/fl_plantlife/cactus.lua @@ -0,0 +1,42 @@ +minetest.register_node("fl_plantlife:cactus", { + description = "cactus", + paramtype = "light", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = {-7/16, -0.5, -7/16, 7/16, 0.5, 7/16} + }, + tiles = { + "[combine:16x16:0,-16=farlands_cactus.png", + "[combine:16x16:0,-16=farlands_cactus.png", + "[combine:16x16:0,0=farlands_cactus.png", + }, + on_construct = function(pos) + minetest.get_node_timer(pos):start(math.random(600, 1200)) + end, + on_timer = function(pos, elapsed) + --minetest.chat_send_all("triggered") + local above = minetest.get_node_or_nil({x=pos.x, y=pos.y-1, z=pos.z}) + if not above then return end + if not minetest.registered_nodes[above.name] or minetest.registered_nodes[above.name].drawtype == "airlike" then + return + end + local under = minetest.get_node_or_nil({x=pos.x, y=pos.y-1, z=pos.z}) + --minetest.chat_send_all(under.name) + if not under then return end + if under.name == "fl_stone:sand" then + minetest.set_node({x=pos.x, y=pos.y+1, z=pos.z}, {name = "fl_plantlife:cactus"}) + minetest.get_node_timer(pos):start(math.random(600, 1200)) + return + elseif under.name == "fl_plantlife:cactus" then + --minetest.chat_send_all("triggered") + local base = minetest.get_node_or_nil({x=pos.x, y=pos.y-2, z=pos.z}) + if not base then return end + if base.name ~= "fl_stone:sand" then return end + minetest.set_node({x=pos.x, y=pos.y+1, z=pos.z}, {name = "fl_plantlife:cactus"}) + minetest.get_node_timer(pos):start(math.random(600, 1200)) + end + minetest.get_node_timer(pos):start(math.random(600, 1200)) + end, + groups = {oddly_breakable_by_hand = 3} +}) \ No newline at end of file diff --git a/mods/fl_plantlife/init.lua b/mods/fl_plantlife/init.lua index 19f9396..049130e 100644 --- a/mods/fl_plantlife/init.lua +++ b/mods/fl_plantlife/init.lua @@ -1,5 +1,6 @@ local modpath = minetest.get_modpath("fl_plantlife") dofile(modpath .. "/grass.lua") +dofile(modpath .. "/cactus.lua") dofile(modpath .. "/flowers.lua") dofile(modpath .. "/flowerpot.lua") \ No newline at end of file diff --git a/mods/fl_plantlife/textures/farlands_cactus.png b/mods/fl_plantlife/textures/farlands_cactus.png new file mode 100644 index 0000000000000000000000000000000000000000..c9776a764ab7de987b5dc6b7651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