From 6688ddf6d4668dc7668e1b7d2c4ebf67e4b47857 Mon Sep 17 00:00:00 2001 From: Paramat Date: Wed, 2 Jan 2019 02:18:50 +0000 Subject: [PATCH] Add large cactus seedling Alter 'large cactus' schematic to place another force-placed cactus node, to replace the cactus seedling on growth. Make schematic 5x7x5 to solve rotation, placement and protection check issues. Add a y-slice probability for height variation. Growth time is tuned to not make this a faster way to obtain cactus nodes compared to normal cactus farming. Seedling texture by Extex101. Use sapling/seedling description in protection intersection message in 'sapling_on_place' function. --- mods/default/README.txt | 3 + mods/default/crafting.lua | 15 ++++ mods/default/license.txt | 1 + mods/default/mapgen.lua | 2 +- mods/default/nodes.lua | 73 ++++++++++++++++++ mods/default/schematics/large_cactus.mts | Bin 94 -> 98 bytes .../default_large_cactus_seedling.png | Bin 0 -> 256 bytes mods/default/trees.lua | 14 +++- schematic_tables.txt | 39 +++++++++- 9 files changed, 143 insertions(+), 4 deletions(-) create mode 100644 mods/default/textures/default_large_cactus_seedling.png diff --git a/mods/default/README.txt b/mods/default/README.txt index a5346976..f40ac540 100644 --- a/mods/default/README.txt +++ b/mods/default/README.txt @@ -244,6 +244,9 @@ Topywo (CC BY-SA 3.0) default_coral_green.png default_coral_pink.png +Extex101 (CC BY-SA 3.0) + default_large_cactus_seedling.png + Sounds ------ diff --git a/mods/default/crafting.lua b/mods/default/crafting.lua index b8651c0c..b49dc487 100644 --- a/mods/default/crafting.lua +++ b/mods/default/crafting.lua @@ -779,6 +779,15 @@ minetest.register_craft({ } }) +minetest.register_craft({ + output = "default:large_cactus_seedling", + recipe = { + {"", "default:cactus", ""}, + {"default:cactus", "default:cactus", "default:cactus"}, + {"", "default:cactus", ""}, + } +}) + -- -- Crafting (tool repair) @@ -1095,6 +1104,12 @@ minetest.register_craft({ burntime = 15, }) +minetest.register_craft({ + type = "fuel", + recipe = "default:large_cactus_seedling", + burntime = 5, +}) + minetest.register_craft({ type = "fuel", recipe = "default:papyrus", diff --git a/mods/default/license.txt b/mods/default/license.txt index a5ea24b5..fecb1eb8 100644 --- a/mods/default/license.txt +++ b/mods/default/license.txt @@ -50,6 +50,7 @@ Copyright (C) 2010-2018: TumeniNodes Mossmanikin random-geek + Extex101 You are free to: Share — copy and redistribute the material in any medium or format. diff --git a/mods/default/mapgen.lua b/mods/default/mapgen.lua index b92e12ef..9c63d1ed 100644 --- a/mods/default/mapgen.lua +++ b/mods/default/mapgen.lua @@ -1893,7 +1893,7 @@ function default.register_decorations() y_max = 31000, y_min = 4, schematic = minetest.get_modpath("default") .. "/schematics/large_cactus.mts", - flags = "place_center_x", + flags = "place_center_x, place_center_z", rotation = "random", }) diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index 5ce0ce19..a2f1a3e5 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -132,6 +132,8 @@ Plantlife --------- default:cactus +default:large_cactus_seedling + default:papyrus default:dry_shrub default:junglegrass @@ -1276,6 +1278,77 @@ minetest.register_node("default:cactus", { on_place = minetest.rotate_node, }) +minetest.register_node("default:large_cactus_seedling", { + description = "Large Cactus Seedling", + drawtype = "plantlike", + tiles = {"default_large_cactus_seedling.png"}, + inventory_image = "default_large_cactus_seedling.png", + wield_image = "default_large_cactus_seedling.png", + paramtype = "light", + sunlight_propagates = true, + walkable = false, + selection_box = { + type = "fixed", + fixed = { + -5 / 16, -0.5, -5 / 16, + 5 / 16, 0.5, 5 / 16 + } + }, + groups = {choppy = 3, dig_immediate = 3, attached_node = 1}, + sounds = default.node_sound_wood_defaults(), + + on_place = function(itemstack, placer, pointed_thing) + itemstack = default.sapling_on_place(itemstack, placer, pointed_thing, + "default:large_cactus_seedling", + {x = -2, y = -1, z = -2}, + {x = 2, y = 5, z = 2}, + 4) + + return itemstack + end, + + on_construct = function(pos) + -- Normal cactus farming adds 1 cactus node by ABM, + -- interval 12s, chance 83. + -- Consider starting with 5 cactus nodes. We make sure that growing a + -- large cactus is not a faster way to produce new cactus nodes. + -- Confirmed by experiment, when farming 5 cacti, on average 1 new + -- cactus node is added on average every + -- 83 / 5 = 16.6 intervals = 16.6 * 12 = 199.2s. + -- Large cactus contains on average 14 cactus nodes. + -- 14 * 199.2 = 2788.8s. + -- Set random range to average to 2789s. + minetest.get_node_timer(pos):start(math.random(1859, 3719)) + end, + + on_timer = function(pos) + local node_under = minetest.get_node_or_nil( + {x = pos.x, y = pos.y - 1, z = pos.z}) + if not node_under then + -- Node under not yet loaded, try later + minetest.get_node_timer(pos):start(300) + return + end + + if minetest.get_item_group(node_under.name, "sand") == 0 then + -- Seedling dies + minetest.remove_node(pos) + return + end + + local light_level = minetest.get_node_light(pos) + if not light_level or light_level < 13 then + -- Too dark for growth, try later in case it's night + minetest.get_node_timer(pos):start(300) + return + end + + minetest.log("action", "A large cactus seedling grows into a large" .. + "cactus at ".. minetest.pos_to_string(pos)) + default.grow_large_cactus(pos) + end, +}) + minetest.register_node("default:papyrus", { description = "Papyrus", drawtype = "plantlike", diff --git a/mods/default/schematics/large_cactus.mts b/mods/default/schematics/large_cactus.mts index b71077b3c5a0f397aade8d76cbe2f0a081d80b9f..e453573fb20ff33be7ca6f706c1e3370f2718f25 100644 GIT binary patch delta 74 zcmV-Q0JZ;KVh>GJQ%wK_00jUC00n=4Kamd~G#F%n5hsfg2{J%2f`zJMn1TOrq8^CA g0LZGh2NL#RvB3pIkO>hm0J0ziRDv1+0I|3UEf`l92mk;8 delta 70 zcmYd_}# diff --git a/mods/default/textures/default_large_cactus_seedling.png b/mods/default/textures/default_large_cactus_seedling.png new file mode 100644 index 0000000000000000000000000000000000000000..378351adb81d8f8ba61e504ccb901dbe10652c94 GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!S%6Q7E0E@MU=VO)5cOja31Scp zXON0ukc(wdNMcaVU{K3pP%mWAEN0LyWzeZ$(5Yn5t6@04XPr*;^ou~9j3q&S!3+-1 zZlnP@6`n4RArhBE`xv>78gMwze*bFD>bdv+Z+d;}W1*vpjgyC__tt6st6sN