From 7502427be841b3f13df8561f070b98492901cbc4 Mon Sep 17 00:00:00 2001 From: Ginger Pollard Date: Tue, 2 Dec 2014 03:17:31 -0500 Subject: [PATCH] first commit --- README.txt | 55 ++++++++ crafts.lua | 57 +++++++++ depends.txt | 4 + init.lua | 22 ++++ nodes.lua | 226 +++++++++++++++++++++++++++++++++ textures/love_mod_glass.png | Bin 0 -> 417 bytes textures/love_mod_heart.png | Bin 0 -> 495 bytes textures/love_mod_hearts.png | Bin 0 -> 633 bytes textures/love_mod_sapling.png | Bin 0 -> 386 bytes textures/love_mod_tree.png | Bin 0 -> 711 bytes textures/love_mod_tree_top.png | Bin 0 -> 776 bytes textures/love_mod_wand.png | Bin 0 -> 650 bytes textures/love_mod_wood.png | Bin 0 -> 323 bytes tools.lua | 10 ++ trees.lua | 106 ++++++++++++++++ 15 files changed, 480 insertions(+) create mode 100644 README.txt create mode 100644 crafts.lua create mode 100644 depends.txt create mode 100644 init.lua create mode 100644 nodes.lua create mode 100644 textures/love_mod_glass.png create mode 100644 textures/love_mod_heart.png create mode 100644 textures/love_mod_hearts.png create mode 100644 textures/love_mod_sapling.png create mode 100644 textures/love_mod_tree.png create mode 100644 textures/love_mod_tree_top.png create mode 100644 textures/love_mod_wand.png create mode 100644 textures/love_mod_wood.png create mode 100644 tools.lua create mode 100644 trees.lua diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..2c83ab4 --- /dev/null +++ b/README.txt @@ -0,0 +1,55 @@ + .:::. .:::. love_mod +:::::::.::::::: by: crazyginger72 (Ginger Pollard) +::::::::::::::: ver: 1.0 2014 +':::::::::::::' + ':::::::::' This mod was made for someone very special + ':::::' to me, my truest friend in the world and + ':' the nicest person I ever have meet! + *****shadowzone***** + + + +Wealcome to the love_mod. This mod adds romantic, loved themed +nodes and tools to you inventory to help spread something special. + +dependiencies: +*default +*stairs +*wool +*dye? + +########WARNING######### +If you are yousing a version of the "3d_armor" mod that includes +"admin armor", DO NOT use the wand on anyone wearing admin armor +as it will KILL them instantly 99% of the time!!!!!!! + + + + + + + + + + + + + + + +license: + +Custom license: The contents of this mod may be used, modified, +or distruibuted for personal use only. The contents of this mod +may not be used in any comercial software or other comerical +content or in any way that derives profit from said content, +The contents of this mod also may not be packaged with any +software or other content that is not free. Any re-distrubitions +or moddified code and or files from this mod must include a copy +of the original license and be acredited to the original + author/creator along with a copy of the un-modified code or file(s). + +non-profit server clause: The contents of this mod MAY be used +on any server or in such settings as provided that the use of +said server or other setting does not change a fee or demand +any other forms of financial restitutions or exchanges. \ No newline at end of file diff --git a/crafts.lua b/crafts.lua new file mode 100644 index 0000000..aaebb6d --- /dev/null +++ b/crafts.lua @@ -0,0 +1,57 @@ + +minetest.register_craft({ + output = 'love_mod:heart 7', + recipe = { + {"wool:red", "","wool:red"}, + {"wool:red","wool:red","wool:red"}, + {"" ,"wool:red","" }, + } +}) + +minetest.register_craft({ + output = 'love_mod:wand', + recipe = { + {"wool:red" ,"default:mese_crystal","wool:red" }, + {"" ,"default:stick" ,"" }, + {"love_mod:heart","default:diamond" ,"love_mod:heart"}, + } +}) + +minetest.register_craft({ + output = 'love_mod:sapling 8', + recipe = { + {"default:sapling","default:sapling","default:sapling"}, + {"default:sapling","love_mod:heart" ,"default:sapling"}, + {"default:sapling","default:sapling","default:sapling"}, + } +}) + +minetest.register_craft({ + output = 'love_mod:wood 4', + recipe = { + {'love_mod:tree'}, + } +}) + +minetest.register_craft({ + output = 'love_mod:wood_heart 4', + recipe = { + {'love_mod:tree_heart'}, + } +}) + +minetest.register_craft({ + output = 'love_mod:glass 8', + recipe = { + {"default:glass","default:glass" ,"default:glass"}, + {"default:glass","love_mod:heart","default:glass"}, + {"default:glass","default:glass" ,"default:glass"}, + } +}) + +minetest.register_craft({ + output = 'love_mod:heart_wall 14', + recipe = { + {'love_mod:heart'}, + } +}) \ No newline at end of file diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..039b7f2 --- /dev/null +++ b/depends.txt @@ -0,0 +1,4 @@ +default +stairs +wool +dye? diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..b6a4194 --- /dev/null +++ b/init.lua @@ -0,0 +1,22 @@ +--[[ + + .:::. .:::. love_mod +:::::::.::::::: by: crazyginger72 (Ginger Pollard) +::::::::::::::: ver: 1.0 2014 +':::::::::::::' + ':::::::::' This mod was made for someone very special + ':::::' to me, my truest friend in the world and + ':' the nicest person I ever have meet! + *****shadowzone***** + + +see README.txt for instruction, description, warnings and license. +]]-- + + +love_mod = {} + +dofile(minetest.get_modpath("love_mod").."/crafts.lua") +dofile(minetest.get_modpath("love_mod").."/nodes.lua") +dofile(minetest.get_modpath("love_mod").."/tools.lua") +dofile(minetest.get_modpath("love_mod").."/trees.lua") diff --git a/nodes.lua b/nodes.lua new file mode 100644 index 0000000..870cc5d --- /dev/null +++ b/nodes.lua @@ -0,0 +1,226 @@ +-- GENERATED CODE +-- Node Box Editor, version 0.6.4 - Stone +-- Namespace: test + +minetest.register_node("love_mod:heart", { + description = "Heart", + tiles = {"love_mod_heart.png"}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + light_source = 1, + sunlight_propagates = true, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3,tree=1}, + sounds = default.node_sound_wood_defaults(), + node_box = { + type = "fixed", + fixed = { + {-0.0625, -0.5, -0.4375, 0.0625, 0.3125, 0.4375}, -- NodeBox1 + {-0.1875, -0.4375, -0.4375, 0.1875, 0.25, 0.4375}, -- NodeBox2 + {-0.25, -0.375, -0.4375, 0.25, 0.25, 0.4375}, -- NodeBox3 + {-0.3125, -0.3125, -0.4375, 0.3125, 0.25, 0.4375}, -- NodeBox4 + {-0.375, -0.25, -0.4375, 0.375, 0.25, 0.4375}, -- NodeBox5 + {-0.4375, -0.1875, -0.4375, 0.4375, 0.25, 0.4375}, -- NodeBox6 + {-0.5, -0.0625, -0.4375, 0.5, 0.25, 0.4375}, -- NodeBox7 + {-0.4375, 0.25, -0.4375, -0.0625, 0.375, 0.4375}, -- NodeBox8 + {0.0625, 0.25, -0.4375, 0.4375, 0.375, 0.4375}, -- NodeBox9 + {-0.375, 0.375, -0.4375, -0.125, 0.4375, 0.4375}, -- NodeBox10 + {0.125, 0.375, -0.4375, 0.375, 0.4375, 0.4375}, -- NodeBox11 + } + }, + selection_box = { + type = "fixed", + fixed = {0.5,0.4375,0.4375,-0.5,-0.5,-0.4375}, + }, +}) + +minetest.register_node("love_mod:heart_wall", { + description = "Wall Heart", + tiles = {"love_mod_heart.png"}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + light_source = 1, + sunlight_propagates = true, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3,tree=1}, + sounds = default.node_sound_wood_defaults(), + node_box = { + type = "fixed", + fixed = { + {-0.0625, -0.5, 0.4375, 0.0625, 0.3125, 0.5}, -- NodeBox1 + {-0.1875, -0.4375, 0.4375, 0.1875, 0.25, 0.5}, -- NodeBox2 + {-0.25, -0.375, 0.4375, 0.25, 0.25, 0.5}, -- NodeBox3 + {-0.3125, -0.3125, 0.4375, 0.3125, 0.25, 0.5}, -- NodeBox4 + {-0.375, -0.25, 0.4375, 0.375, 0.25, 0.5}, -- NodeBox5 + {-0.4375, -0.1875, 0.4375, 0.4375, 0.25, 0.5}, -- NodeBox6 + {-0.5, -0.0625, 0.4375, 0.5, 0.25, 0.5}, -- NodeBox7 + {-0.4375, 0.25, 0.4375, -0.0625, 0.375, 0.5}, -- NodeBox8 + {0.0625, 0.25, 0.4375, 0.4375, 0.375, 0.5}, -- NodeBox9 + {-0.375, 0.375, 0.4375, -0.125, 0.4375, 0.5}, -- NodeBox10 + {0.125, 0.375, 0.4375, 0.375, 0.4375, 0.5}, -- NodeBox11 + } + }, + selection_box = { + type = "fixed", + fixed = {0.5,0.5,0.4375,-0.5,-0.5,0.5}, + }, +}) + +minetest.register_node("love_mod:sapling", { + description = "Love Tree Sapling", + drawtype = "plantlike", + visual_scale = 1.5, + tiles = {"love_mod_sapling.png"}, + inventory_image = "love_mod_hearts.png^love_mod_sapling.png", + wield_image = "love_mod_sapling.png", + paramtype = "light", + walkable = false, + is_ground_content = true, + selection_box = { + type = "fixed", + fixed = {-0.45, -0.75, -0.45, 0.45, 0.525, 0.45} + }, + groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1}, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("love_mod:heart_food", { + description = "Yummy Heart", + drawtype = "plantlike", + visual_scale = 1.0, + tiles = {"love_mod_hearts.png"}, + inventory_image = "love_mod_hearts.png", + paramtype = "light", + sunlight_propagates = true, + walkable = false, + is_ground_content = true, + selection_box = { + type = "fixed", + fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2} + }, + groups = {fleshy=3,dig_immediate=3,flammable=2,leafdecay=3,leafdecay_drop=1}, + on_use = minetest.item_eat(3), + sounds = default.node_sound_leaves_defaults(), + after_place_node = function(pos, placer, itemstack) + if placer:is_player() then + minetest.set_node(pos, {name="love_mod:sapling", param2=1}) + else + minetest.set_node(pos, {name="love_mod:heart_food", param2=1}) + end + end, +}) + +minetest.register_node("love_mod:leaves", { + description = "Leaves", + drawtype = "allfaces_optional", + visual_scale = 1.3, + tiles = {"default_leaves.png"}, + paramtype = "light", + waving = 1, + is_ground_content = false, + groups = {snappy=3, leafdecay=3, flammable=2, leaves=1, not_in_creative_inventory=1}, + drop = { + max_items = 1, + items = { + { + -- player will get sapling with 1/20 chance + items = {'love_mod:sapling'}, + rarity = 30, + }, + { + -- player will get leaves only if he get no saplings, + -- this is because max_items is 1 + items = {'default:leaves'}, + } + } + }, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("love_mod:jungleleaves", { + description = "Leaves", + drawtype = "allfaces_optional", + visual_scale = 1.3, + tiles = {"default_jungleleaves.png"}, + paramtype = "light", + waving = 1, + is_ground_content = false, + groups = {snappy=3, leafdecay=3, flammable=2, leaves=1, not_in_creative_inventory=1}, + drop = { + max_items = 1, + items = { + { + -- player will get sapling with 1/20 chance + items = {'love_mod:sapling'}, + rarity = 30, + }, + { + -- player will get leaves only if he get no saplings, + -- this is because max_items is 1 + items = {'default:leaves'}, + } + } + }, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("love_mod:glass", { + description = "Love Glass", + drawtype = "glasslike_framed", + tiles = {"default_obsidian_glass.png", "love_mod_glass.png"}, + paramtype = "light", + light_source = 1, + sunlight_propagates = true, + is_ground_content = false, + groups = {cracky=3,oddly_breakable_by_hand=3}, + sounds = default.node_sound_glass_defaults(), +}) + +minetest.register_node("love_mod:tree_heart", { + description = "Tree With Heart", + tiles = {"love_mod_tree_top.png", "love_mod_tree_top.png", "love_mod_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(), + stack_max = 99, + on_place = minetest.rotate_node + +}) + +minetest.register_node("love_mod:tree", { + description = "Tree", + tiles = {"love_mod_tree_top.png", "love_mod_tree_top.png", "default_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(), + stack_max = 99, + on_place = minetest.rotate_node + +}) + +minetest.register_node("love_mod:wood", { + description = "Wooden Planks", + tiles = {"love_mod_wood.png"}, + paramtype = "light", + paramtype2 ="facedir", + groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("love_mod:wood_heart", { + description = "Wooden Heart Planks", + tiles = {"love_mod_wood.png^love_mod_hearts.png"}, + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1}, + sounds = default.node_sound_wood_defaults(), +}) + +stairs.register_stair_and_slab("love_wood", "love_mod:wood", + {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}, + {"love_mod_wood.png"}, + "Love Mod Wooden Stair", + "Love Mod Wooden Slab", + default.node_sound_wood_defaults()) \ No newline at end of file diff --git a/textures/love_mod_glass.png b/textures/love_mod_glass.png new file mode 100644 index 0000000000000000000000000000000000000000..613c847c41d83975084ebacc8aa0b47c29589177 GIT binary patch literal 417 zcmV;S0bc%zP)7zu%> zC{PH9g2I=eizrg(8XU!UNRc83NQwl(Nf3&VFkm?nmds+zq=*AH5R-_lR40=K;$r}B=(-@#rWVG`910s>$LY(x+dd=Uh=U#)g|F@s7vaWMFx)42hVN7Ez% z@^O`iJ$%kP`w2grraYNu(o83TBX~6W%yOb+!vD4M#h*!C`klW3nW3|LH{^JY00000 LNkvXXu0mjfO$V#Z literal 0 HcmV?d00001 diff --git a/textures/love_mod_heart.png b/textures/love_mod_heart.png new file mode 100644 index 0000000000000000000000000000000000000000..3a85f4adf30b298ee4a534d7e9b943b0b0df6922 GIT binary patch literal 495 zcmVrGfwe010qNS#tmY3ljhU3ljkVnw%H_000bhMObu0Z*6U5Zgc=+XE!pEf&K*m z00DPNL_t(I%Wae4lAAybgFky0lJxH0wNIZ*09*Zmm+p1SjE7}Fk}V7S{q>~5~e0I#yTe*;f5o@OM_f$jx(RNW+&0<;1fAm9e2`O4ET`n zOb#<#qJILvhWga@Z6W|j;Hc*&@d5(qpPAew?!XExL){&72MIEfbotQ$m)L;5N>{tR z2->>RmgORdoH+-pTYY$@WX z6$bDEHi^Ci-)8g*$_sd3^PQ?=?kMH=AOQMS8E|(zlXc4dKK&Ot$jx|HlwW3NkOD9> lmhyvtIv55gpb_E1`~e~zLSx zj^s<+23Z+sV~Mzq$&`%Xg_(4}zVY>ks_; zI?T;Irc&8L)hLy2(r8SuvhtAK-3qOir(9MV4N!HQo(4g+3P30TaqOtqpARybv5`0~ z&}@#7&wCCJKXQC*EG(#=pNB4rAW1xffdUS|IT7e|LZT=gX*MV6^#V>#gjy|Re_s%B z)M{b4w>RWmECyt=<~KKI0YrdwX(?cQ{E&9LbuF;zNoOe0D3T($QEXgzcx331e}1r;y>aCtBC&# Tk6`p%00000NkvXXu0mjfMji@4 literal 0 HcmV?d00001 diff --git a/textures/love_mod_sapling.png b/textures/love_mod_sapling.png new file mode 100644 index 0000000000000000000000000000000000000000..9fe6b35c9182bdc3d09251c150b4bbb32d41e952 GIT binary patch literal 386 zcmV-|0e$|7P)VwJxG-r^=iUm z9GD6NAq)`RN<+c}bary=1GxAGJ_4hwPr+^z9)O{fLl=#<5-(`{T)YHtE|oO#Oy}Nw zKj-_-2mB|lZq8||#FR0L1E*K=j_Px^T4?|fB`&3mkx(Oe8-q>N`Lb?`E#@Weet4(s zC~-;5oiawgZ8aPK;=rLeaFj|Q0;0sF_WQycHOXQunrgCbi+KsYtZ`-@<8{48mKU06Fx#|)wh{pFZHvaC*V|4d#QdF0>$(H^3VTUc z!M81%PD0vB0RWgs!;`1C3iqQ^qbp|chlm&R&;VdmvSUgc1;(MLSN#2&*B`gTyF#=DRc2lTQAa)M*iij{TE8AWut5yo(aGNIp_Pv6DB8vA8=ait1 z29(y=w#sf0eR!CbLS8qTH2`XDGy@fkQYy!xXK$5#+X>z=FB@gcJe^0b*9j-WoL8DP zf^)370-$Ebx>ZDkeXkS~=0CsS|M|u;XNE4|zg)O{{6wBJry()tjaCa7ctq))BYMy4 z_0IQG#ekqn{p*EX9@>DXuM72kWyzUNJt_?^W~f(|d8M^VQU$dSKoB9R;s60u1P2Vx5mlL&jq}q;v5N9GqB-OBc4s^cd_KS!0x5W$ z2vLO5djRCOAK7wYJoa>5|43j6ijoeI^LU_7iPxXM1A*rdc-M7ARow4CF-J2TtkXhkjl5>|QV|u*j1)W~!m?&k z*Rkz|x>f2M5j8Vn>{xOk4GBy+q@Lg+s>-x%Je>|W6^g--dVJJ30)kgnR0J_2cu(pg t3XG?OIU^#h`-by@QVIakdCVF(;eSudPgTiC=*Iv6002ovPDHLkV1kHsK5GB~ literal 0 HcmV?d00001 diff --git a/textures/love_mod_tree_top.png b/textures/love_mod_tree_top.png new file mode 100644 index 0000000000000000000000000000000000000000..222b561d1ea773bb1d33a901bc720c15077985e5 GIT binary patch literal 776 zcmV+j1NZ!iP)=@Y9 z$cDgBGrf=GlF6l_eP38jLCKLt<9KVn<4x=Md9mQ~^c0~KQfuON%Wn_&{Gs+dOpn}s z+md2L+`QJ+s*$c;@xiQk;~YPooZz&^4+BaFCR$^JKw8WGc;we|&+lLUX8q3|ZH=XA z9B=E4i?-#Lckh@immnqcal~{T${3Im0P*P)A0GmrTZf+?(Z*_~w0u}BIcr;_)@;^m z7FSoK-Hs9hNJ&YF_TmD7@7=7BV`<4WaCJ#6)6f50o#%&rEu;Xx^21ZdyEh) zo#Se;;Qy6EDuss-NU9LyfX+Z5a@+TuPbTD)h&j{e%rQoGDY1!>kE<0mXErf%*Y|jt zu~wr?9-wRZ^RQ=b3`30E%;(fvan`bG8s2x^%b7MC0KTR`Y6=8}t_Z>~vY7?e-ZM9b zwfDTT7N-m|r7+4unLsib9}~OhBa%uf0`cQT zQy-rqu2nQLqZ&spFVUrxG)5u>)GA2B$iaK8HVCD#TJbMwr`b>M>)?#gHWaF4M({=!K!F0#iwmanUj95rbt|f@sM1rVqe^bX z>_7MtV?HVhX3i0Mz5Cw!dL6nzXED8DyJ$E7NLD5xaFgd`H#fMeE99utp-`m-bxts12KYS3XW3F9)-}Kx@cz->-tdk0 z=zBqGo$$wFZI{!Kso=;CeXx1@u?TQktu! z26<-WN`#;yL=kFL#>3%f;7PYErEbOoL_=kD0#vHF8SuTXojW=@0XDQOrH_0yQ+%U&P}S@TSBX~3{@I$9nAg&n2In}oePK{@4H=|*0qj-layK;-cMO3 kJU^L)$)aUx*s}d`TmjD0& literal 0 HcmV?d00001 diff --git a/textures/love_mod_wood.png b/textures/love_mod_wood.png new file mode 100644 index 0000000000000000000000000000000000000000..1e286ae93a006ac6a7efcd1f4e8dec8bd4063b8a GIT binary patch literal 323 zcmV-J0lfZ+P)pF^+`lQR4C7NQoRboFc7}tIf%6A7AT5qP(-@;9xfs-zMhMNZ{g|^ za4JgYN{*621c%cjB=MUrx!>=;%MObb{P23e0HELNi_PF42I}EZ9=e>0eKgmtUIKt= z?%*LiZ+7yiZR`6SQBVZ{P=Xv$;DcfuS3xdgx~@_x@cDfPdCo?**K?m!uz+|6xGpD- zXprYJ6|>}@7#IZAww2IXF-{~f(U5KgSuUF9E+v^(5)y+~`vm)p6%EmK--Kl`^5;3- zOr_MnEJuVqpLDF0N^%t`G09jI^pk7bIwI8NG%4`xcNdrD!B@xvWd3<4;om#}d;tCE VcqWzu#pD10002ovPDHLkV1oE4hZFz+ literal 0 HcmV?d00001 diff --git a/tools.lua b/tools.lua new file mode 100644 index 0000000..684097e --- /dev/null +++ b/tools.lua @@ -0,0 +1,10 @@ +minetest.register_tool("love_mod:wand", { + description = "Love Wand", + inventory_image = "love_mod_wand.png", + tool_capabilities = { + full_punch_interval = 0.5, + max_drop_level=1, + damage_groups = {fleshy= -10}, + groupcaps={}, + } +}) \ No newline at end of file diff --git a/trees.lua b/trees.lua new file mode 100644 index 0000000..b8a6799 --- /dev/null +++ b/trees.lua @@ -0,0 +1,106 @@ +local c_air = minetest.get_content_id("air") +local c_ignore = minetest.get_content_id("ignore") +local c_tree = minetest.get_content_id("love_mod:tree") +local c_ltree = minetest.get_content_id("love_mod:tree_heart") +local c_fruit = minetest.get_content_id("love_mod:heart_food") + +function love_mod.grow_tree(data, a, pos, c_leaves) + + local th = math.random(4, 6) + local x, y, z = pos.x, pos.y, pos.z + for yy = y, y+th-1 do + local vi = a:index(x, yy, z) + if a:contains(x, yy, z) and (data[vi] == c_air or yy == y) then + data[vi] = c_tree + end + end + + local vil = a:index(x, y+1, z) + if a:contains(x, y+1, z) and (data[vil] == c_tree ) then + data[vil] = c_ltree + end + + + y = y+th-1 -- (x, y, z) is now last piece of trunk + local leaves_a = VoxelArea:new{MinEdge={x=-2, y=-1, z=-2}, MaxEdge={x=2, y=2, z=2}} + local leaves_buffer = {} + + -- Force leaves near the trunk + local d = 1 + for xi = -d, d do + for yi = -d, d do + for zi = -d, d do + leaves_buffer[leaves_a:index(xi, yi, zi)] = true + end + end + end + + -- Add leaves randomly + for iii = 1, 12 do + local d = 1 + local xx = math.random(leaves_a.MinEdge.x, leaves_a.MaxEdge.x - d) + local yy = math.random(leaves_a.MinEdge.y, leaves_a.MaxEdge.y - d) + local zz = math.random(leaves_a.MinEdge.z, leaves_a.MaxEdge.z - d) + + for xi = 0, d do + for yi = 0, d do + for zi = 0, d do + leaves_buffer[leaves_a:index(xx+xi, yy+yi, zz+zi)] = true + end + end + end + end + + -- Add the leaves + for xi = leaves_a.MinEdge.x, leaves_a.MaxEdge.x do + for yi = leaves_a.MinEdge.y, leaves_a.MaxEdge.y do + for zi = leaves_a.MinEdge.z, leaves_a.MaxEdge.z do + if a:contains(x+xi, y+yi, z+zi) then + local vi = a:index(x+xi, y+yi, z+zi) + if data[vi] == c_air or data[vi] == c_ignore then + if leaves_buffer[leaves_a:index(xi, yi, zi)] then + if math.random(1, 100) <= 35 then + data[vi] = c_fruit + else + data[vi] = c_leaves + end + end + end + end + end + end + end +end + +minetest.register_abm({ + nodenames = {"love_mod:sapling"}, + interval = 5, + chance = 10, + action = function(pos, node) + local nu = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name + local is_soil = minetest.get_item_group(nu, "soil") + local is_sand = minetest.get_item_group(nu, "sand") + if is_soil ~= 0 then + minetest.log("action", "A Love tree grows @"..minetest.pos_to_string(pos)) + local vm = minetest.get_voxel_manip() + local minp, maxp = vm:read_from_map({x=pos.x-16, y=pos.y, z=pos.z-16}, {x=pos.x+16, y=pos.y+16, z=pos.z+16}) + local a = VoxelArea:new{MinEdge=minp, MaxEdge=maxp} + local data = vm:get_data() + love_mod.grow_tree(data, a, pos, minetest.get_content_id("love_mod:leaves")) + vm:set_data(data) + vm:write_to_map(data) + vm:update_map() + elseif is_sand ~= 0 then + minetest.log("action", "A Love tree grows @"..minetest.pos_to_string(pos)) + local vm = minetest.get_voxel_manip() + local minp, maxp = vm:read_from_map({x=pos.x-16, y=pos.y, z=pos.z-16}, {x=pos.x+16, y=pos.y+16, z=pos.z+16}) + local a = VoxelArea:new{MinEdge=minp, MaxEdge=maxp} + local data = vm:get_data() + love_mod.grow_tree(data, a, pos, minetest.get_content_id("love_mod:jungleleaves")) + vm:set_data(data) + vm:write_to_map(data) + vm:update_map() + end + + end +}) \ No newline at end of file