From c7507e1a59cf447f8cafa3d22f1d9abcfc0af205 Mon Sep 17 00:00:00 2001 From: Bas Date: Thu, 12 Jul 2012 00:23:19 +0200 Subject: [PATCH] first commit --- depends.txt | 2 + init.lua | 258 +++++++++++++++++++++++++++++++++ textures/vines_rope.png | Bin 0 -> 244 bytes textures/vines_rope_block.png | Bin 0 -> 625 bytes textures/vines_rope_wield.png | Bin 0 -> 673 bytes textures/vines_vine.png | Bin 0 -> 447 bytes textures/vines_vine_rotten.png | Bin 0 -> 463 bytes 7 files changed, 260 insertions(+) create mode 100644 depends.txt create mode 100644 init.lua create mode 100644 textures/vines_rope.png create mode 100644 textures/vines_rope_block.png create mode 100644 textures/vines_rope_wield.png create mode 100644 textures/vines_vine.png create mode 100644 textures/vines_vine_rotten.png diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..abb01ae --- /dev/null +++ b/depends.txt @@ -0,0 +1,2 @@ +default +flowers diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..f235ad2 --- /dev/null +++ b/init.lua @@ -0,0 +1,258 @@ +print("[Vines] v1.0") + +-- Nodes +minetest.register_node("vines:rope_block", { + description = "Rope", + sunlight_propagates = true, + paramtype = "light", + drops = "", + tile_images = { + "vines_rope_block.png", + "vines_rope_block.png", + "default_wood.png", + "default_wood.png", + "vines_rope_block.png", + "vines_rope_block.png" + }, + drawtype = "cube", + groups = { snappy = 3}, + sounds = default.node_sound_leaves_defaults(), + after_place_node = function(pos) + + local p = {x=pos.x, y=pos.y-1, z=pos.z} + local n = minetest.env:get_node(p) + if n.name == "air" then + minetest.env:add_node(p, {name="vines:rope_end"}) + end + end, +}) + +minetest.register_node("vines:rope", { + description = "Rope", + walkable = false, + climbable = true, + sunlight_propagates = true, + paramtype = "light", + tile_images = { "vines_rope.png" }, + drawtype = "plantlike", + groups = {}, + sounds = default.node_sound_leaves_defaults(), + selection_box = { + type = "fixed", + fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, + }, + +}) + +minetest.register_node("vines:rope_end", { + description = "Rope", + walkable = false, + climbable = true, + sunlight_propagates = true, + paramtype = "light", + drops = "", + tile_images = { "vines_rope.png" }, + drawtype = "plantlike", + groups = {}, + sounds = default.node_sound_leaves_defaults(), + after_place_node = function(pos) + yesh = {x = pos.x, y= pos.y-1, z=pos.z} + minetest.env:add_node(yesh, "vines:rope") + end, + selection_box = { + type = "fixed", + fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, + }, +}) + + +minetest.register_node("vines:vine", { + description = "Vine", + walkable = false, + climbable = true, + drop = 'vines:vines', + sunlight_propagates = true, + paramtype = "light", + tile_images = { "vines_vine.png" }, + drawtype = "plantlike", + inventory_image = "vines_vine.png", + groups = { snappy = 3 }, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("vines:vine_rotten", { + description = "Rotten vine", + walkable = false, + climbable = true, + drop = 'vines:vines', + sunlight_propagates = true, + paramtype = "light", + tile_images = { "vines_vine_rotten.png" }, + drawtype = "plantlike", + inventory_image = "vines_vine_rotten.png", + groups = { snappy = 3 }, + sounds = default.node_sound_leaves_defaults(), +}) + +--ABM +minetest.register_abm({ + nodenames = {"default:leaves", "growing_trees:leaves", "default:dirt_with_grass", }, + interval = 10, + chance = 1000, + action = function(pos, node) + + local p = {x=pos.x, y=pos.y-1, z=pos.z} + local n = minetest.env:get_node(p) + + if n.name =="air" then + minetest.env:add_node(p, {name="vines:vine"}) + end + end +}) + + + +minetest.register_abm({ + nodenames = {"vines:vine"}, + interval = 5, + chance = 4, + action = function(pos, node, active_object_count, active_object_count_wider) + + local p = {x=pos.x, y=pos.y-1, z=pos.z} + local n = minetest.env:get_node(p) + + --remove if top node is removed + if minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z}).name == "air" then + minetest.env:remove_node(pos) + end + + --the second argument in the random function represents the average height + if math.random(0,3)<1 then + minetest.env:add_node(pos, {name="vines:vine_rotten"}) + else + if n.name =="air" then + minetest.env:add_node(p, {name="vines:vine"}) + end + end + end +}) + +minetest.register_abm({ + nodenames = {"vines:vine_rotten"}, + interval = 60, + chance = 4, + action = function(pos, node, active_object_count, active_object_count_wider) + + local p = {x=pos.x, y=pos.y-1, z=pos.z} + local n = minetest.env:get_node(p) + + -- only remove if nothing is hangin on the bottom of it. + if n.name ~="vines:vine" and n.name ~="vines:vine_rotten" then + minetest.env:remove_node(pos) + end + + if minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z}).name == "air" then + minetest.env:remove_node({x=pos.x, y=pos.y+1, z=pos.z}) + end + + end +}) + +minetest.register_abm({ + nodenames = {"default:dirt", "default:dirt_with_grass"}, + interval = 36000, + chance = 10, + action = function(pos, node, active_object_count, active_object_count_wider) + + local p = {x=pos.x, y=pos.y-1, z=pos.z} + local n = minetest.env:get_node(p) + + --remove if top node is removed + if n.name == "air" + and is_node_in_cube ({"vines:vine"}, pos, 3) then + minetest.env:add_node(p, {name="vines:vine"}) + end + end +}) + +minetest.register_abm({ + nodenames = {"vines:rope_end"}, + interval = 1, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + + local p = {x=pos.x, y=pos.y-1, z=pos.z} + local n = minetest.env:get_node(p) + + --remove if top node is removed + if n.name == "air" then + minetest.env:remove_node(pos) + minetest.env:add_node(pos, {name="vines:rope"}) + minetest.env:add_node(p, {name="vines:rope_end"}) + end + end +}) + +is_node_in_cube = function(nodenames, node_pos, radius) + for x = node_pos.x - radius, node_pos.x + radius do + for y = node_pos.y - radius, node_pos.y + radius do + for z = node_pos.z - radius, node_pos.z + radius do + n = minetest.env:get_node_or_nil({x = x, y = y, z = z}) + if (n == nil) + or (n.name == 'ignore') + or (table_contains(nodenames, n.name) == true) then + return true + end + end + end + end + + return false +end + +table_contains = function(t, v) + for _, i in ipairs(t) do + if (i == v) then + return true + end + end + + return false +end + +-- craft rope +minetest.register_craft({ + output = 'vines:rope_block', + recipe = { + {'', 'default:wood', ''}, + {'', 'vines:vines', ''}, + {'', 'vines:vines', ''}, + } +}) + +minetest.register_craftitem("vines:vines", { + description = "Vines", + inventory_image = "vines_vine.png", +}) + +minetest.register_on_dignode(function (pos, node, player) + + + if ( node.name == 'vines:rope_block' ) then + print("bala") + local p = {x=pos.x, y=pos.y, z=pos.z} + local n = minetest.env:get_node(p) + + + repeat + + p = {x=p.x, y=p.y-1, z=p.z} + n = minetest.env:get_node(p) + + minetest.env:remove_node(p) + + until n.name == "vines:ropes" or n.name == "vines:rope_end" + + end + +end) diff --git a/textures/vines_rope.png b/textures/vines_rope.png new file mode 100644 index 0000000000000000000000000000000000000000..961692bda02c4b5575b54bd0cc9a232722739915 GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgfaiAi9PZ!4!i_^&|2YCNkM@SlQeE4i+00cQV z>SiNRGke6T-oS!|i)az>vYbIu<)a6sTeX7_cmV;2o1c$+U8B!B<| Z!wp9Jmq*f1UjrJ=;OXk;vd$@?2>@taP7?qC literal 0 HcmV?d00001 diff --git a/textures/vines_rope_block.png b/textures/vines_rope_block.png new file mode 100644 index 0000000000000000000000000000000000000000..ece6d37f1af70ad23388beef13fea812384f20fe GIT binary patch literal 625 zcmV-%0*?KOP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyk> z6)-hl5x%Yf000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0005ZNklQs&n^>-2^x${SsbI{+FbmBJr=7a!bqZ& zGEHoKBS%B(OBLj3$RLRUXf*@V$HU7;J4c*j#UzoDhP7F4p=lWAL*3h|To|ax^q2j3lv#*fUL9&47bHGU~O3NgsrfWcsY# zy_sXM+X)Ee4^ybw*;;#+>`5Hu7?g{1tSnzaDTP;Zjd!f>_G+3WW25QxY;Ylit&IlN zt0luqbFhy0cG77Ey^mjc{<@cIvfBw*S@sc`O%#+;gpuUv{TGw0&X+Ir!HsM4X8-!1 zu!Rt2w|^aJbPrqHtz@2pn&xiO`*D&}6fF}J23fu<-00000 LNkvXXu0mjfZ8i|% literal 0 HcmV?d00001 diff --git a/textures/vines_rope_wield.png b/textures/vines_rope_wield.png new file mode 100644 index 0000000000000000000000000000000000000000..c22f5168a77fa616d65f81ea5516b371e7d43fd5 GIT binary patch literal 673 zcmV;S0$%-zP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyk> z6*D^IgYf(S000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0005}Nklowie<-99l@1016%iT)>5#!e910F`&E!;^Tr+9^ zfQ}u4P;RLZILOo?VxghxP>&Andzywz&X+84DEBtWIp_licgOQS&pn@ejQ#D+zUxT_ z<9FBK^}CO(<+4m(PXbW29p1lr#?sA{&T~D<7=V>ZlTIW#JoZQ@lJt5#0BZFH7j2)a z?eMCYWo{;c>q(SSy2w~~BRf8sr4+K`(+au(Y!vd;>J0$yEzS`(6GG?$MydFqA3nt6 zG0uK=*xCCM`TXMJ+oY!^7|aDQ{>R|O(-odSS17 zdV@-Nods(e+3~MBb$m=KmDaNazQ(`OgMsA$Nz-5MrF2y@oEbQOL7vJ5u->fJHz`Vm3U(=(l%wzR=uk%Q(bu54?o(81W>-t3PW zIG?}r_Jb3F+$!Z+UABfcaZD+N>q+eTk$yQdITbOel-Id+V-nf%wSiI!QwX8|?bSva z5rbCHWx*Qm4qO_9am^g3d2;?&gYQ2sIF|wLnU6J-)CPY5hbs#=b=Px#24YJ`L;xWGHUJ*q3mJ+4000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyk= z0uMVuqH6^J00BQqL_t(I%cYZ{Zo@DThX1ollF*R>C#nWaf+nq~8ZF-xuxA*k)IG<- z`V0e6@(|TfM@s^xE-@$>O+qGlpmCbGj#g{uvzo5R}ui+&ed6g@^CySI^YEks-m&Fl!p_OY}LRE902vupg#=&)V5${ z(iZ~&|GN9OUT)hMu(*Gg$fXOG#73cm&ji!Cn9W002ovPDHLkV1n8ivDE+o literal 0 HcmV?d00001 diff --git a/textures/vines_vine_rotten.png b/textures/vines_vine_rotten.png new file mode 100644 index 0000000000000000000000000000000000000000..11b5474c659acc3f7fa0a40bce3a4c8ee97d7b11 GIT binary patch literal 463 zcmV;=0WkiFP)Px#24YJ`L;xEABLEq&6HS!>000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyk= z0ucZt=)L{`00B=)L_t(I%bilOO2beTJ@-LEGG|HyfoFy;U0m`3`G-PQ3I0I3`2lY2 zyRDREspR$qQT-X=2kMXDz9&8dhHwhn$fnHVK7{x@v|z0)RNOXnB36<%wa341MT~ zU9FE=l>z`JvbTV{`!zRX7&8Ef#nmem52&u1{y&(G!FAQpL=tWuKF}t?-xMrwbJhJm zGS#qrw}%(F-1#!e=a`pDuh&1y