Add large cactus seedling
authorParamat <paramat@users.noreply.github.com>
Wed, 2 Jan 2019 02:18:50 +0000 (02:18 +0000)
committerGitHub <noreply@github.com>
Wed, 2 Jan 2019 02:18:50 +0000 (02:18 +0000)
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
mods/default/crafting.lua
mods/default/license.txt
mods/default/mapgen.lua
mods/default/nodes.lua
mods/default/schematics/large_cactus.mts
mods/default/textures/default_large_cactus_seedling.png [new file with mode: 0644]
mods/default/trees.lua
schematic_tables.txt

index a5346976c367acca12b3c868d81d17ed3be0c63e..f40ac540ddff2657dc779efbea0836be52ffa99b 100644 (file)
@@ -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
 ------
index b8651c0cbe66e5eda1f3c45058871ac37de09df8..b49dc487893a30faf75678ab98767def8df9bd14 100644 (file)
@@ -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",
index a5ea24b5d595d2544886ba25d7979466a73c8885..fecb1eb8c5de25472cef4ea1577eb70904ddcd24 100644 (file)
@@ -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.
index b92e12ef2e3df98e8aa255750806a4c31d254752..9c63d1ed8507d00f00e1af47d4d6905258443d27 100644 (file)
@@ -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",
        })
 
index 5ce0ce19ca7e1234c515e68c063777ec0d8b6fff..a2f1a3e58dd5a74b7ca808fc12436265e0a1ce11 100644 (file)
@@ -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",
index b71077b3c5a0f397aade8d76cbe2f0a081d80b9f..e453573fb20ff33be7ca6f706c1e3370f2718f25 100644 (file)
Binary files a/mods/default/schematics/large_cactus.mts and b/mods/default/schematics/large_cactus.mts differ
diff --git a/mods/default/textures/default_large_cactus_seedling.png b/mods/default/textures/default_large_cactus_seedling.png
new file mode 100644 (file)
index 0000000..378351a
Binary files /dev/null and b/mods/default/textures/default_large_cactus_seedling.png differ
index c9eabaa83ec44759b7240009fd6f30e0b70abdc1..564b714121784f7fea2ea8452440b945fc848971 100644 (file)
@@ -510,6 +510,16 @@ function default.grow_pine_bush(pos)
 end
 
 
+-- Large cactus
+
+function default.grow_large_cactus(pos)
+       local path = minetest.get_modpath("default") ..
+               "/schematics/large_cactus.mts"
+       minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
+               path, "random", nil, false)
+end
+
+
 --
 -- Sapling 'on place' function to check protection of node and resulting tree volume
 --
@@ -550,7 +560,9 @@ function default.sapling_on_place(itemstack, placer, pointed_thing,
                        interval) then
                minetest.record_protection_violation(pos, player_name)
                -- Print extra information to explain
-               minetest.chat_send_player(player_name, "Tree will intersect protection")
+               minetest.chat_send_player(player_name,
+                       itemstack:get_definition().description .. " will intersect protection " ..
+                       "on growth")
                return itemstack
        end
 
index bd101e71b99e94b83afd2d0107ab934daba4bf34..26f31d2a230ac55860d6c9de2a3288b22f2b243d 100644 (file)
@@ -2050,15 +2050,50 @@ local R = {name = "default:cactus", prob = 255, param2 = 20, force_place = true}
 local E = {name = "default:cactus", prob = 127, param2 = 20}
 
 mts_save("large_cactus", {
-       size = {x = 5, y = 7, z = 1},
+       size = {x = 5, y = 7, z = 5},
        data = {
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+
+               _, _, R, _, _,
                _, _, R, _, _,
-               _, _, C, _, _,
                _, _, C, _, _,
                C, C, C, C, C,
                C, _, C, _, C,
                E, _, C, _, E,
                _, _, C, _, _,
+
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+               _, _, _, _, _,
+       },
+       yslice_prob = {
+               {ypos = 2, prob = 127},
        },
 })