Skip to content

Commit 6688ddf

Browse files
authoredJan 2, 2019
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.
1 parent da10af9 commit 6688ddf

File tree

9 files changed

+143
-4
lines changed

9 files changed

+143
-4
lines changed
 

Diff for: ‎mods/default/README.txt

+3
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ Topywo (CC BY-SA 3.0)
244244
default_coral_green.png
245245
default_coral_pink.png
246246

247+
Extex101 (CC BY-SA 3.0)
248+
default_large_cactus_seedling.png
249+
247250

248251
Sounds
249252
------

Diff for: ‎mods/default/crafting.lua

+15
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,15 @@ minetest.register_craft({
779779
}
780780
})
781781

782+
minetest.register_craft({
783+
output = "default:large_cactus_seedling",
784+
recipe = {
785+
{"", "default:cactus", ""},
786+
{"default:cactus", "default:cactus", "default:cactus"},
787+
{"", "default:cactus", ""},
788+
}
789+
})
790+
782791

783792
--
784793
-- Crafting (tool repair)
@@ -1095,6 +1104,12 @@ minetest.register_craft({
10951104
burntime = 15,
10961105
})
10971106

1107+
minetest.register_craft({
1108+
type = "fuel",
1109+
recipe = "default:large_cactus_seedling",
1110+
burntime = 5,
1111+
})
1112+
10981113
minetest.register_craft({
10991114
type = "fuel",
11001115
recipe = "default:papyrus",

Diff for: ‎mods/default/license.txt

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Copyright (C) 2010-2018:
5050
TumeniNodes
5151
Mossmanikin
5252
random-geek
53+
Extex101
5354

5455
You are free to:
5556
Share — copy and redistribute the material in any medium or format.

Diff for: ‎mods/default/mapgen.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,7 @@ function default.register_decorations()
18931893
y_max = 31000,
18941894
y_min = 4,
18951895
schematic = minetest.get_modpath("default") .. "/schematics/large_cactus.mts",
1896-
flags = "place_center_x",
1896+
flags = "place_center_x, place_center_z",
18971897
rotation = "random",
18981898
})
18991899

Diff for: ‎mods/default/nodes.lua

+73
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ Plantlife
132132
---------
133133
134134
default:cactus
135+
default:large_cactus_seedling
136+
135137
default:papyrus
136138
default:dry_shrub
137139
default:junglegrass
@@ -1276,6 +1278,77 @@ minetest.register_node("default:cactus", {
12761278
on_place = minetest.rotate_node,
12771279
})
12781280

1281+
minetest.register_node("default:large_cactus_seedling", {
1282+
description = "Large Cactus Seedling",
1283+
drawtype = "plantlike",
1284+
tiles = {"default_large_cactus_seedling.png"},
1285+
inventory_image = "default_large_cactus_seedling.png",
1286+
wield_image = "default_large_cactus_seedling.png",
1287+
paramtype = "light",
1288+
sunlight_propagates = true,
1289+
walkable = false,
1290+
selection_box = {
1291+
type = "fixed",
1292+
fixed = {
1293+
-5 / 16, -0.5, -5 / 16,
1294+
5 / 16, 0.5, 5 / 16
1295+
}
1296+
},
1297+
groups = {choppy = 3, dig_immediate = 3, attached_node = 1},
1298+
sounds = default.node_sound_wood_defaults(),
1299+
1300+
on_place = function(itemstack, placer, pointed_thing)
1301+
itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
1302+
"default:large_cactus_seedling",
1303+
{x = -2, y = -1, z = -2},
1304+
{x = 2, y = 5, z = 2},
1305+
4)
1306+
1307+
return itemstack
1308+
end,
1309+
1310+
on_construct = function(pos)
1311+
-- Normal cactus farming adds 1 cactus node by ABM,
1312+
-- interval 12s, chance 83.
1313+
-- Consider starting with 5 cactus nodes. We make sure that growing a
1314+
-- large cactus is not a faster way to produce new cactus nodes.
1315+
-- Confirmed by experiment, when farming 5 cacti, on average 1 new
1316+
-- cactus node is added on average every
1317+
-- 83 / 5 = 16.6 intervals = 16.6 * 12 = 199.2s.
1318+
-- Large cactus contains on average 14 cactus nodes.
1319+
-- 14 * 199.2 = 2788.8s.
1320+
-- Set random range to average to 2789s.
1321+
minetest.get_node_timer(pos):start(math.random(1859, 3719))
1322+
end,
1323+
1324+
on_timer = function(pos)
1325+
local node_under = minetest.get_node_or_nil(
1326+
{x = pos.x, y = pos.y - 1, z = pos.z})
1327+
if not node_under then
1328+
-- Node under not yet loaded, try later
1329+
minetest.get_node_timer(pos):start(300)
1330+
return
1331+
end
1332+
1333+
if minetest.get_item_group(node_under.name, "sand") == 0 then
1334+
-- Seedling dies
1335+
minetest.remove_node(pos)
1336+
return
1337+
end
1338+
1339+
local light_level = minetest.get_node_light(pos)
1340+
if not light_level or light_level < 13 then
1341+
-- Too dark for growth, try later in case it's night
1342+
minetest.get_node_timer(pos):start(300)
1343+
return
1344+
end
1345+
1346+
minetest.log("action", "A large cactus seedling grows into a large" ..
1347+
"cactus at ".. minetest.pos_to_string(pos))
1348+
default.grow_large_cactus(pos)
1349+
end,
1350+
})
1351+
12791352
minetest.register_node("default:papyrus", {
12801353
description = "Papyrus",
12811354
drawtype = "plantlike",

Diff for: ‎mods/default/schematics/large_cactus.mts

4 Bytes
Binary file not shown.
256 Bytes
Loading

Diff for: ‎mods/default/trees.lua

+13-1
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,16 @@ function default.grow_pine_bush(pos)
510510
end
511511

512512

513+
-- Large cactus
514+
515+
function default.grow_large_cactus(pos)
516+
local path = minetest.get_modpath("default") ..
517+
"/schematics/large_cactus.mts"
518+
minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2},
519+
path, "random", nil, false)
520+
end
521+
522+
513523
--
514524
-- Sapling 'on place' function to check protection of node and resulting tree volume
515525
--
@@ -550,7 +560,9 @@ function default.sapling_on_place(itemstack, placer, pointed_thing,
550560
interval) then
551561
minetest.record_protection_violation(pos, player_name)
552562
-- Print extra information to explain
553-
minetest.chat_send_player(player_name, "Tree will intersect protection")
563+
minetest.chat_send_player(player_name,
564+
itemstack:get_definition().description .. " will intersect protection " ..
565+
"on growth")
554566
return itemstack
555567
end
556568

Diff for: ‎schematic_tables.txt

+37-2
Original file line numberDiff line numberDiff line change
@@ -2050,15 +2050,50 @@ local R = {name = "default:cactus", prob = 255, param2 = 20, force_place = true}
20502050
local E = {name = "default:cactus", prob = 127, param2 = 20}
20512051

20522052
mts_save("large_cactus", {
2053-
size = {x = 5, y = 7, z = 1},
2053+
size = {x = 5, y = 7, z = 5},
20542054
data = {
2055+
_, _, _, _, _,
2056+
_, _, _, _, _,
2057+
_, _, _, _, _,
2058+
_, _, _, _, _,
2059+
_, _, _, _, _,
2060+
_, _, _, _, _,
2061+
_, _, _, _, _,
2062+
2063+
_, _, _, _, _,
2064+
_, _, _, _, _,
2065+
_, _, _, _, _,
2066+
_, _, _, _, _,
2067+
_, _, _, _, _,
2068+
_, _, _, _, _,
2069+
_, _, _, _, _,
2070+
2071+
_, _, R, _, _,
20552072
_, _, R, _, _,
2056-
_, _, C, _, _,
20572073
_, _, C, _, _,
20582074
C, C, C, C, C,
20592075
C, _, C, _, C,
20602076
E, _, C, _, E,
20612077
_, _, C, _, _,
2078+
2079+
_, _, _, _, _,
2080+
_, _, _, _, _,
2081+
_, _, _, _, _,
2082+
_, _, _, _, _,
2083+
_, _, _, _, _,
2084+
_, _, _, _, _,
2085+
_, _, _, _, _,
2086+
2087+
_, _, _, _, _,
2088+
_, _, _, _, _,
2089+
_, _, _, _, _,
2090+
_, _, _, _, _,
2091+
_, _, _, _, _,
2092+
_, _, _, _, _,
2093+
_, _, _, _, _,
2094+
},
2095+
yslice_prob = {
2096+
{ypos = 2, prob = 127},
20622097
},
20632098
})
20642099

0 commit comments

Comments
 (0)
Please sign in to comment.