From abc4cbce4c643ca908899d3b3fe5d9678ef5ad15 Mon Sep 17 00:00:00 2001 From: sys4-fr Date: Sat, 25 Nov 2017 18:30:30 +0100 Subject: [PATCH] - Initial commit - Use of LBM and schematics for trees and logs --- .gitignore | 4 + depends.txt | 1 + init.lua | 316 +++++++++++++++++++++ schematics/cherry_log.mts | Bin 0 -> 101 bytes schematics/cherry_tree.mts | Bin 0 -> 193 bytes schematics/cherry_tree_from_sapling.mts | Bin 0 -> 197 bytes textures/default_cherry_blossom_leaves.png | Bin 0 -> 571 bytes textures/default_cherry_sapling.png | Bin 0 -> 167 bytes textures/default_cherry_top.png | Bin 0 -> 627 bytes textures/default_cherry_tree.png | Bin 0 -> 632 bytes textures/default_wood_cherry_planks.png | Bin 0 -> 555 bytes 11 files changed, 321 insertions(+) create mode 100755 .gitignore create mode 100644 depends.txt create mode 100644 init.lua create mode 100644 schematics/cherry_log.mts create mode 100644 schematics/cherry_tree.mts create mode 100644 schematics/cherry_tree_from_sapling.mts create mode 100755 textures/default_cherry_blossom_leaves.png create mode 100755 textures/default_cherry_sapling.png create mode 100755 textures/default_cherry_top.png create mode 100755 textures/default_cherry_tree.png create mode 100755 textures/default_wood_cherry_planks.png diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..0d1e071 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*~ +*.autosave +#* +.dir-locals.el diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +default diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..81e03ca --- /dev/null +++ b/init.lua @@ -0,0 +1,316 @@ +--[[ + cherry_tree:cherry_tree + cherry_tree:cherry_plank + cherry_tree:cherry_blossom_leaves + cherry_tree:cherry_sapling +--]] + +local random = math.random + +-- Cherry tree growing +-- Sapling ABM + +-- Cherry tree generation +local function grow_cherry_tree(pos) + local path = minetest.get_modpath("cherry_tree") .. + "/schematics/cherry_tree_from_sapling.mts" + minetest.place_schematic({x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}, + path, "random", nil, false) +end + +local function grow_sapling(pos) + if not default.can_grow(pos) then + minetest.get_node_timer(pos):start(random(240, 600)) + return + end + + local node = minetest.get_node(pos) + + if node.name == "cherry_tree:cherry_sapling" then + minetest.log("action", "A cherry sapling grows into a tree at ".. + minetest.pos_to_string(pos)) + grow_cherry_tree(pos) + end +end + +minetest.register_lbm( + { + name = "cherry_tree:convert_saplings_to_node_timer", + nodenames = {"cherry_tree:cherry_sapling"}, + action = function(pos) + minetest.get_node_timer(pos):start(random(1200, 2400)) + end + }) + +-- From BFD, cherry tree +minetest.register_node( + "cherry_tree:cherry_tree", + { + description = "Cherry Tree", + tiles = { + "default_cherry_top.png", + "default_cherry_top.png", + "default_cherry_tree.png" + }, + paramtype2 = "facedir", + is_ground_content = false, + groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2}, + sounds = default.node_sound_wood_defaults(), + on_place = minetest.rotate_node + }) + +minetest.register_node( + "cherry_tree:cherry_plank", + { + description = "Cherry Planks", + paramtype2 = "facedir", + place_param2 = 0, + tiles = {"default_wood_cherry_planks.png"}, + is_ground_content = false, + sounds = default.node_sound_wood_defaults(), + groups = {oddly_breakable_by_hand=1, flammable=1, choppy=3, wood=1}, + }) + +minetest.register_node( + "cherry_tree:cherry_blossom_leaves", + { + description = "Cherry Blossom Leaves", + drawtype = "allfaces_optional", + visual_scale = 1.3, + tiles = {"default_cherry_blossom_leaves.png"}, + paramtype = "light", + waving = 1, + is_ground_content = false, + groups = {snappy=3, leafdecay=3, flammable=2, leaves=1}, + drop = { + max_items = 1, + items = { + { + items = {'cherry_tree:cherry_sapling'}, + rarity = 32, + }, + { + items = {'cherry_tree:cherry_blossom_leaves'}, + } + } + }, + sounds = default.node_sound_leaves_defaults(), + after_place_node = default.after_place_leaves, + }) + +--[[minetest.register_node("cherry_tree:cherry_leaves_deco", { + description = "Cherry Leaves", + drawtype = "allfaces_optional", + visual_scale = 1.3, + tiles = {"default_cherry_blossom_leaves.png"}, + paramtype = "light", + waving=1, + is_ground_content = false, + groups = {snappy=3, flammable=2, leaves=1}, + sounds = default.node_sound_leaves_defaults(), + drop = {'cherry_tree:cherry_blossom_leaves'}, + }) +--]] + +minetest.register_node( + "cherry_tree:cherry_sapling", + { + description = "Cherry Sapling", + waving = 1, + visual_scale = 1.0, + inventory_image = "default_cherry_sapling.png", + wield_image = "default_cherry_sapling.png", + drawtype = "plantlike", + paramtype = "light", + sunlight_propagates = true, + tiles = {"default_cherry_sapling.png"}, + walkable = false, + on_timer = grow_sapling, + selection_box = { + type = "fixed", + fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3} + }, + groups = {snappy = 2, dig_immediate = 3, flammable = 2, + attached_node = 1, sapling = 1}, + sounds = default.node_sound_leaves_defaults(), + on_construct = function(pos) + minetest.get_node_timer(pos):start(random(2400,4800)) + end, + + on_place = function(itemstack, placer, pointed_thing) + itemstack = default.sapling_on_place( + itemstack, placer, pointed_thing, + "cherry_tree:cherry_sapling", + -- minp, maxp to be checked, relative to sapling pos + -- minp_relative.y = 1 because sapling pos has been checked + {x = -2, y = 1, z = -2}, + {x = 2, y = 6, z = 2}, + -- maximum interval of interior volume check + 4) + return itemstack + end, + }) + +default.register_leafdecay( + { + trunks = {"cherry_tree:cherry_tree"}, + leaves = {"default:apple", "cherry_tree:cherry_blossom_leaves"}, + radius = 3, + }) + +-- Aliases +minetest.register_alias("default:cherry_tree", "cherry_tree:cherry_tree") +minetest.register_alias("default:cherry_log", "cherry_tree:cherry_tree") +minetest.register_alias("default:cherry_plank", "cherry_tree:cherry_plank") +minetest.register_alias("default:cherry_blossom_leaves", "cherry_tree:cherry_blossom_leaves") +minetest.register_alias("default:cherry_leaves_deco", "cherry_tree:cherry_blossom_leaves") +minetest.register_alias("default:cherry_leaves", "cherry_tree:cherry_blossom_leaves") +minetest.register_alias("default:cherry_sapling", "cherry_tree:cherry_sapling") +minetest.register_alias("default:mg_cherry_sapling", "cherry_tree:cherry_sapling") + +-- Crafting +minetest.register_craft( + { + output = 'cherry_tree:cherry_plank 4', + recipe = { + {'cherry_tree:cherry_tree'}, + } + }) + +-- Mapgen +minetest.register_biome( + { + name = "cherry_blossom_forest", + --node_shore_filler = "default:sand", + node_top = "default:dirt_with_grass", + depth_top = 1, + node_filler = "default:dirt", + depth_filler = 3, + --node_dust = "air", + --node_underwater = "default:gravel", + node_riverbed = "default:sand", + depth_riverbed = 2, + y_min = 1, + y_max = 40, + heat_point = 50, + humidity_point = 55, + }) + +minetest.register_biome( + { + name = "cherry_blossom_forest_floral", + --node_shore_filler = "default:sand", + node_top = "default:dirt_with_grass", + depth_top = 1, + node_filler = "default:dirt", + depth_filler = 3, + --node_dust = "air", + --node_underwater = "default:gravel", + node_riverbed = "default:sand", + depth_riverbed = 2, + y_min = 1, + y_max = 40, + heat_point = 47, + humidity_point = 50, + }) + +minetest.register_biome( + { + name = "cherry_blossom_forest_grassy", + --node_shore_filler = "default:sand", + node_top = "default:dirt_with_grass", + depth_top = 1, + node_filler = "default:dirt", + depth_filler = 3, + --node_dust = "air", + --node_underwater = "default:gravel", + node_riverbed = "default:sand", + depth_riverbed = 2, + y_min = 1, + y_max = 42, + heat_point = 55, + humidity_point = 55, + }) + +-- Decoration +-- Cherry tree and log + +minetest.register_decoration( + { + deco_type = "schematic", + place_on = {"default:dirt_with_grass"}, + sidelen = 16, + noise_params = { + offset = 0.036, + scale = 0.022, + spread = {x = 250, y = 250, z = 250}, + seed = 2, + octaves = 3, + persist = 0.66 + }, + biomes = { + "cherry_blossom_forest", + "cherry_blossom_forest_floral", + "cherry_blossom_forest_grassy" + }, + y_min = 1, + y_max = 31000, + schematic = minetest.get_modpath("cherry_tree") .. + "/schematics/cherry_tree.mts", + flags = "place_center_x, place_center_z", + rotation = "random", + }) + +minetest.register_decoration( + { + deco_type = "schematic", + place_on = {"default:dirt_with_grass"}, + sidelen = 16, + noise_params = { + offset = 0.0009, + scale = 0.0006, + spread = {x = 250, y = 250, z = 250}, + seed = 2, + octaves = 3, + persist = 0.66 + }, + biomes = { + "deciduous_forest", + "cherry_blossom_forest", + "cherry_blossom_forest_floral", + "cherry_blossom_forest_grassy" + }, + y_min = 1, + y_max = 31000, + schematic = minetest.get_modpath("cherry_tree") .. + "/schematics/cherry_tree.mts", + flags = "place_center_x, place_center_z", + rotation = "random", + }) + +minetest.register_decoration( + { + deco_type = "schematic", + place_on = {"default:dirt_with_grass"}, + sidelen = 16, + noise_params = { + offset = 0.0018, + scale = 0.0011, + spread = {x = 250, y = 250, z = 250}, + seed = 2, + octaves = 3, + persist = 0.66 + }, + biomes = { + "deciduous_forest", + "cherry_blossom_forest", + "cherry_blossom_forest_floral", + "cherry_blossom_forest_grassy" + }, + y_min = 1, + y_max = 31000, + schematic = minetest.get_modpath("cherry_tree") .. + "/schematics/cherry_log.mts", + flags = "place_center_x", + rotation = "random", + }) diff --git a/schematics/cherry_log.mts b/schematics/cherry_log.mts new file mode 100644 index 0000000000000000000000000000000000000000..7a0342f2a5347ff4204d7bfbd0d5eaf218ef9c0d GIT binary patch literal 101 zcmeYb3HD`RVPFPA#`^kt5F;_Oh(SC#BekfgGQOlJHPs4<%^;SRlV6@%RBV-7TAWdo spPw6_RFq$yS1~6!fq~i0ASEGz>GPx4ZzZ2N^2o`_DR43f#WAJ<01piyuK)l5 literal 0 HcmV?d00001 diff --git a/schematics/cherry_tree.mts b/schematics/cherry_tree.mts new file mode 100644 index 0000000000000000000000000000000000000000..84f8d850c92d580e72f09265a704f4ddac57f9a2 GIT binary patch literal 193 zcmeYb3HD`RVPIw8U|_AUx333bAfGugvxq@4IU}{Gs4~8!C^gjz%1+A3FD}l{jn7F< zEK4nB5XYhfq?~~_B{eOvG^fNWv7jI)wPH?kf`X92qt+$NZft67X$r?ui~DTv(> z+2e3oVaA5aD`oP9&nC*&ef;_J=SL2v<-7j;{`CFx=hv@aE3z;L7zTW?XSSNCAFtoP VXr0}Bmd_{3?+36jlugjQ2mnaZPQ?HK literal 0 HcmV?d00001 diff --git a/schematics/cherry_tree_from_sapling.mts b/schematics/cherry_tree_from_sapling.mts new file mode 100644 index 0000000000000000000000000000000000000000..022a23c20327630ca27707bb4bec83b17b64fc4a GIT binary patch literal 197 zcmeYb3HD`RVPIw8U|_AUx333bAfGugvxq@4IU}{Gs4~8!C^gjz%1+A3FD}l{jn7F< zEK4nB5XYhfq?~~_B{eOvG^fNWv7jI)wPH?kf`X92qt+$NZft67X$r?ui~DTv(> z+2e3oVaA5aD`oP9&nC*&ef;_J=SL2v<-7h=R4!=x^{a~GAVUa`$Xa&Kzv&Gd8(j9) Y?6v9I^{YncjPm_jXF&#rz$u4^P)y`aj?T_t;2G$#B{R6bhE}=p~iN#$a%NPVW!G_ zy31s!%YC}ce!R_StIley&uy>Ie!b9yz|nBA(Sg6wi^0-yveI+2(sQ)Zg22*;!_#xL z({!}cgu&B@#ME}S)RD#2cemAexYdZn)_J(rdb!q?$k%(i*L=Fye7o3uyV!lZ*nPa% ze!SS3%GjF9*?zs*f4$k8%i4gx+MUhYgTULL&D)^P+n~?fgu&dP&)lKU+@jFkhQr;X z(cPrc-lfvsrqbVw#^0yY->B2ysnp=9)ZvcF;jGr;t=HnN*W<6)yy z22Wdg-~zP)lRndJSz1dau;HvRm#f$w$-mi8C+_r54dq^?)p)8B=fPagLou#ZY3*I% zxcmYggX8F~lVba$qZhKIU9{{4W@Z!5>zBm?GFj&-#?D*!^INe8ymu~*1!_Xy=m4%u z#Y|f@=n5Tt#LWQr2~a;9Gs+Js4)gQ%i!kk?uz0f+{hh}6{SUL19+S@|lg0o5002ov JPDHLkV1g^PLe>BP literal 0 HcmV?d00001 diff --git a/textures/default_cherry_sapling.png b/textures/default_cherry_sapling.png new file mode 100755 index 0000000000000000000000000000000000000000..0371b46111b023bfafbe24d79385b5dec4ef269f GIT binary patch literal 167 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJe}GSjE0Fd#bw27o_n6Q8)3GbM zb&vG}g&0eM{DK)Ap4~_Ta@;&!978H@^>#CIF(~jbZT|V++`Qd{t7)5P#j79k_oSXI zWEOs7vT&|irl(T;4!ID=`o=ZdfzMl(ZuLCCD*W4b+x?U|pV_#JXE9t4JaObA&_o7L LS3j3^P6XzaIYlixPc=hTH%C@DNLV;ZT0Bf$IZa+ZP+&e#V?R@9Kvru*S#CyLa7JEnO<{6G zU3EoZc0gZtL|~0sb&pMPkWzGzQgxbEdz({woK$(C+>W^2 zeX-t#w%?Ds;f1&5i@fH9x#)nn>5stbjKAxV!t0a6?3Tssn8od#$nKuW?x4!hzuWY{-1NfU z^v2)y$>H_O;`Yqr_Ri(@(B=2h=J(U)_tWS1)#&%v==j*__}c3D-0S$-7BY_W%9<|NsA|d!7aW007%bL_t&-R|UZdPQx$|1<>#D*iK2J zw3H&Th-+|i?t>^GRh3E`WpQlJg!fFlxV0$314%&}Q@@_xujj71fM(S$IXdT+UCv7T4qtSOe1A5uaABV=9fQ5EC*PGV&I z<|f^&BcyuQ43%Y(ruaa1(|PlAoEUV@jjO4Mtka2Lx>+kEB@aXpHvhDReP`n(5yb!i N002ovPDHLkV1mqySr-5R literal 0 HcmV?d00001 diff --git a/textures/default_cherry_tree.png b/textures/default_cherry_tree.png new file mode 100755 index 0000000000000000000000000000000000000000..8301e5d512c833450cb462ab1229e9c46b1f6712 GIT binary patch literal 632 zcmV-;0*C#HP)d{k zsD72IfS0U$4lWf@x9 zSzu=H`v#Snh%fh6>5n>{&wk%w*9noj2Eba7 zpQh(dHF$yW8E*Q0yz@e~D#O5|Q#D++&PY!M-C*NLc2e~9Y1Aamx}Y$z$N4ic79d=? z_*;@RsI(Y-u0w4z?zcHP*t|bV9?3{BX&5327Fs&fj~t?$2ZpbtEca>__FcEkrvc+Q z5uV_ocQ3pth}yzcb;u?j1C6wvGR(zTOZ^XVGJmQ? SdP)rd0000?$NW|vv<1}5cTc!>EG!KL=$%T0nw!0{*!hG zOxhDTc~8)kJ;^in1y9|VI%{A0?EM))G-rS2oC83VHTOU^5Y0c314IiBQVm4QkCrVvTCw~nkWm9fD~{H# zI9j*zSmlaiRV$AH8TCN4>R7|76OC(5Gy&1t6U}Q+w5&VP3PkHq0a4rf(;XX5cWpe~ zwYl{x|3r}YJzX3_BqUi6b~`m0h%j7`{>hYW-r1w05%EY(w8O$Q+BMfkW$pj}v(7R4 zo;qvxWlPxBTNU4BM9yugnS7`FPr_fFr~~J|THfM|I()jb)W}TnQI@^GOWRk)ij)#Y zd;Kp9E%ateUy3PSt8jHGM`f&3so+t&#|`C2oW#}6ojst`_q5^PDx-Nv51OoPQMfG; z;q)@`yVkAHN&4(tTUOmL&v|FN)%x$cj%f})mnD+7C*L@-PePDIPW|7*u8%gKxo^ri ze~7pp@MQlc&zKDji9exu|d| cRPjG!fRUzNZsIm4p!XR(UHx3vIVCg!06N_i2LJ#7 literal 0 HcmV?d00001