From 72ab3ec06d7e9e5c3095e8f60f7088747f00e37e Mon Sep 17 00:00:00 2001 From: bas080 Date: Tue, 10 Feb 2015 07:07:34 +0100 Subject: [PATCH 1/5] Texture updates - Removes unused textures - Non-rotten vines look better at the bottom of the vines - Root vine has non-rotten version (ressurect the root vines) --- textures/new/sidevine.png | Bin 233 -> 0 bytes textures/new/vinesdead.png | Bin 196 -> 0 bytes textures/new/vineslive.png | Bin 187 -> 0 bytes textures/old/vines_vine2.png | Bin 225 -> 0 bytes textures/old/vines_vine_rotten2.png | Bin 223 -> 0 bytes textures/vines_root.png | Bin 201 -> 215 bytes .../bottomvine.png => vines_root_rotten.png} | Bin textures/vines_side.png | Bin 233 -> 247 bytes textures/vines_vine.png | Bin 187 -> 364 bytes textures/vines_vine_rotten.png | Bin 196 -> 187 bytes textures/vines_willow.png | Bin 196 -> 226 bytes textures/vines_willow_rotten.png | Bin 190 -> 196 bytes 12 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 textures/new/sidevine.png delete mode 100644 textures/new/vinesdead.png delete mode 100644 textures/new/vineslive.png delete mode 100644 textures/old/vines_vine2.png delete mode 100644 textures/old/vines_vine_rotten2.png rename textures/{new/bottomvine.png => vines_root_rotten.png} (100%) diff --git a/textures/new/sidevine.png b/textures/new/sidevine.png deleted file mode 100644 index fdeaeaebe9e12c0b2d9b27d6eda922dd93de354a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHF4e$wZ1=5m+A~NP;Dy}j*p-N^M zT6UENBI*Ljf<{T|=GodnaRt^p4}cojOM?7@fiwt&ro4&(QYoG;jv*Yf$qDPO#2vBA zoX+T+k@|(np!sIaG-2nbNo;I#ue~Ox-&WT&Ft{I-|0p&_@qj>;_8!JF3ESdc9^R0B z$(W7pbF3QI)$Ycug4u@?Vl$U-sJ&#U^Xx<9`Vy;c*+R^BWEg}@^cJl<-1QV>ucxb@ J%Q~loCID5^M|J=J diff --git a/textures/new/vinesdead.png b/textures/new/vinesdead.png deleted file mode 100644 index 3ac6ea510dba4daa1a523ba119da56c2b2b38734..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`-JULvAr_~T6B?KzYghii_3qVw z$q5W*h63^`eBu{4L)C9H9CnD^p>UF|;Y&l~mQ5-#Op%6@oJ7=>S2w?O4eU9~TF_c? zWs-cyi!RZ#Pc)1fJRX}csI*^a5IFWMKIhekoe%8wm^Z9cyt&^+x*yp@6&!pZEpNQ1#mk3euqyM3^5ux^!w%0cXn56I>JL_N?JsHhqEk1kt1x#-oiL z>m)paa}LzUuq6aHCoymcf717n4NPpvV>nSTiAivF(js1mZ~EK5I2vd^F4FV#l$_7V kGTF$Exx??&5f&wetQ~8n6f|=s16{-5>FVdQ&MBb@0022Y0ssI2 diff --git a/textures/old/vines_vine2.png b/textures/old/vines_vine2.png deleted file mode 100644 index c755da9052f0e65499ed6973de951542be19a848..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 225 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPGa2=EDU1=5OUayp^vrjfG2MY6?5 zpj^AG&doqMwvr&fU?2?ydCS-*0;wWT7sn6|S=X~0xta|`S|8er%nIH3Ksu#NqeM5u zdbPsbz24VbI`-{TkKI*U@a`%5VOJ-26Sap2kFO9`{A9GwI&s1Evu-;stH;FMYP$L~ zO5)q8r{&hgo{RU}?l)GcXOtIiQvEB4iFbwxGE6`rns JF6*2UngB%oPGI-%;tsfxXA zN)T@0g=dC9Iku7@zhEE@1bNHYCjzMgPZ!4!4q4WNdj$^ygTe~ HDWM4f$w^6m diff --git a/textures/vines_root.png b/textures/vines_root.png index 49f88c055ceac9451de44ecaf4d52df45f72091b..4fc3f87ab0a05cd3c41e89ae40d8829b1abbcea7 100644 GIT binary patch delta 187 zcmX@fc%5;AO1)@+Plzi6L!qc4zp|8=wz8bIkDRHVrlXlbpk);&0|NtNNswPKgTu2M zX&_FLx4R2N2dk_Hki%Kv5n0T@z%2~Ij105pNB{-dOFVsD+3z!Pu~_REFPakx6tebo zaSY+Oo}7?SkPw={zt)=`$w<`h1ka4qIDG7`#9$B&aM06gSn= z1PaQPDeePm;4BI93kK2Eal|5uIF+U>&e~1|x^WX_Nc!k{Fo#w(oXQ z(AoW#Nucd*u^dP8+kKn~w@TmIb*M2UUrpm+&f;TcRzD-dcIhl5!_HZr3Ws!nPl&4m1H(i+iTaI>O+^e042&f~e!&b5&u*lFI7!~_E({&4vK~MV zXMsm#F#`j)FbFd;%$g$s6l5>)^mS#w&&0(dXtr?mN^YP~sHcl#2*>s01c9{D1QU+L z1P22N-v$|WHa4@c#I`mE<^>*{iysgij;1EPlzi61B0ZYh>W?IimQxHsFGQRmR+U6L>-BG1=c$cfRgMbL4LtN z8U#X9UPS<@6i*k&5DwYogmqWqj@V^RXLQa;{la9>e6wbnu=CR-Ha5A}UX#;rt7{q< z+z-ls6dR*>K%h!{5967HZE-ITZ^*u6%*OUPR*mawcVkw;?86DMnaelSUNY2q_91e8 hiPg4jA?7hB!32COGiWi{{a60|De66lK=n!32;bRa{vGf6951U69E94oEQKA z00(qQO+^Ra0ty5S6BWY|Pyhe``AI}UR5;6>Qn8MLKop#PwNN7l6JxQ(YKYDK!q!*Z zS6W=nR~VxdTTmH<8f;9A?;16G3+%~FMczCnJM#v3AW36ZT7NPu^v#r(oTTw0R)pWJ_CqO${551A^>W*tdwwr3S$5O N002ovPDHLkV1iQaJ9+>B diff --git a/textures/vines_vine_rotten.png b/textures/vines_vine_rotten.png index 3ac6ea510dba4daa1a523ba119da56c2b2b38734..8afffe890947505c6c2adbb259de026d0adecde0 100644 GIT binary patch delta 159 zcmV;Q0AT;b0lNW^B!7ZQL_t(I%VS`G0!1^q|Av9O{~3?~HZc$%Bn}tQ2~{WC03aJx zkQ4*p;?l~Ja0z6^$O@62jI0i(m!KDr6=H+|#es;f7)VoWz<*o@U{ix)000R)pWJ_CqO${551A^>W*tdwwr3S$5O N002ovPDHLkV1hY#J5c}t delta 168 zcmV;Z09XIJ0mK22B!7!ZL_t(I%VS`G0$F{j|Jv^A{~3?~HZc$%Bn}tQ2~{WC0K-6C zxFE>}fb@WYw6Y{z0$DMVLKG(>tApu9QH;$6aD{l(k{^iZiWSY|C^G;^<1_#yht~iQ z#^zsa>hQVXKQ05XsUg|FL>qu?8@BX8Fe!t=f{+UcCS`mE5Ft#;_zWOADHCu3SR4Qb W_ouIPv7+n%0000UCO=8hyb rRyH<90bV6Vo&_QiY%Wd`EQ}0qSy=5Bd);jZn#bVj>gTe~DWM4fqVzGU delta 168 zcmaFFc!Y6+O1)fwPlzi61H*w03jf}FE0F>ILXQ1ar3jdJa^gr-6QK<)-C0}7t1{53=bc--0ZK; zvvyBVYps2la5%|kwuo`=J=Wtf%*C4(FE0F>ILXQ1ar3jdJa^gr-6QK<)-C0}7t1{53=bc--0ZK; zvvyBVYps2la5%|kwuo`=J=Wtf%*C4(Gynhq delta 138 zcmV;50CoSw0loo{Bq113OjJbx006+SApY)!04)Fo9{?mkBz0>Oj)EBDe*mSCOB-IX z4MH&x1u!R9&?2(HU*e6B{-7W&5+ks`gpEyLgk1PF>!6x%BM)rkgD_T8&8#+8!* Date: Tue, 10 Feb 2015 07:15:16 +0100 Subject: [PATCH 2/5] Complete rewrite A big code update. Some features have changes slightly. The goal of this update is to improve performance on servers. This is achieved by removing ABMs and using on_timers instead. The amount of times that on_timer is used is also minimized. Other features include. - vine register function that allows the registering of side and bottom vines - Removing vines remove all vines beneath it. - New vine named Roots --- crafts.lua | 14 ++ functions.lua | 98 ++++++++++++ init.lua | 404 ++------------------------------------------------ nodes.lua | 83 +++++++++++ recipes.lua | 12 ++ shear.lua | 15 ++ spawning.lua | 47 ++++++ vines.lua | 23 +++ 8 files changed, 303 insertions(+), 393 deletions(-) create mode 100644 crafts.lua create mode 100644 functions.lua create mode 100644 nodes.lua create mode 100644 recipes.lua create mode 100644 shear.lua create mode 100644 spawning.lua create mode 100644 vines.lua diff --git a/crafts.lua b/crafts.lua new file mode 100644 index 0000000..19e658b --- /dev/null +++ b/crafts.lua @@ -0,0 +1,14 @@ +minetest.register_craft({ + output = 'vines:rope_block', + recipe = vines.recipes['rope_block'] +}) + +minetest.register_craft({ + output = 'vines:shears', + recipe = vines.recipes['shears'] +}) + +minetest.register_craftitem("vines:vines", { + description = "Vines", + inventory_image = "vines_item.png", +}) diff --git a/functions.lua b/functions.lua new file mode 100644 index 0000000..219effb --- /dev/null +++ b/functions.lua @@ -0,0 +1,98 @@ +vines.register_vine = function( name, defs ) + --different properties for bottom and side vines. + local drawtype = '' + local selection_box + if ( defs.is_side_vine ) then + selection_box = { + type = "wallmounted", + } + drawtype = 'signlike' + else + selection_box = { + type = "fixed", + fixed = { -0.4, -1/2, -0.4, 0.4, 1/2, 0.4 }, + } + drawtype = 'plantlike' + end + + minetest.register_node("vines:"..name, { + description = defs.description, + walkable = false, + climbable = true, + wield_image = "vines_"..name..".png", + drop = "", + sunlight_propagates = true, + paramtype = "light", + paramtype2 = "wallmounted", + buildable_to = true, + tile_images = { "vines_"..name..".png" }, + drawtype = drawtype, + inventory_image = "vines_"..name..".png", + groups = vines.groups, + sounds = default.node_sound_leaves_defaults(), + selection_box = selection_box, + on_construct = function( pos ) + local timer = minetest.get_node_timer( pos ) + timer:start( math.random(5, 10) ) + end, + on_timer = function( pos ) + local node = minetest.get_node( pos ) + local bottom = {x=pos.x, y=pos.y-1, z=pos.z} + local bottom_node = minetest.get_node( bottom ) + if bottom_node.name == "air" then + if not ( math.random( defs.average_length ) == 1 ) then + minetest.set_node( pos, { name = node.name..'_rotten', param2 = node.param2 } ) + minetest.set_node( bottom, { name = node.name, param2 = node.param2 } ) + local timer = minetest.get_node_timer( bottom_node ) + timer:start( math.random(5, 10) ) + end + end + end, + after_dig_node = function(pos, node, oldmetadata, user) + vines.dig_vine( pos, node, user ) + end + }) + + local name = name..'_rotten' + + minetest.register_node( "vines:"..name, { + description = "Rotten "..defs.description, + walkable = false, + climbable = true, + drop = "", + sunlight_propagates = true, + paramtype = "light", + paramtype2 = "wallmounted", + buildable_to = true, + tile_images = { "vines_"..name..".png" }, + wield_image = "vines_"..name..".png", + drawtype = drawtype, + inventory_image = "vines_"..name..".png", + groups = vines.groups, + sounds = default.node_sound_leaves_defaults(), + selection_box = selection_box, + on_destruct = function( pos ) + local node = minetest.get_node( pos ) + local bottom = {x=pos.x, y=pos.y-1, z=pos.z} + local bottom_node = minetest.get_node( bottom ) + if minetest.get_item_group( bottom_node.name, "vines") then + minetest.remove_node( bottom ) + end + end, + after_dig_node = function(pos, node, oldmetadata, user) + vines.dig_vine( pos, node, user ) + end + }) +end + +vines.dig_vine = function( pos, node, user ) + --only dig give the vine if shears are used + if not user then return false end + local wielded = user:get_wielded_item() + if 'vines:shears' == wielded:get_name() then + local inv = user:get_inventory() + if inv then + inv:add_item("main", ItemStack(node.name)) + end + end +end diff --git a/init.lua b/init.lua index a889037..3876fbb 100644 --- a/init.lua +++ b/init.lua @@ -1,397 +1,15 @@ -vines = {} - -local mod_name = "vines" -local average_height = 12 -local spawn_interval = 90 -local vines_group = {attached_node=1,vines=1,snappy=3,flammable=2,hanging_node=1,vines_cleanup=1} - -vines.growth_interval = 300 -vines.growth_chance = 2 -vines.rot_interval = 300 -vines.rot_chance = 8 - -local jungle_leaves_list = { - "default:jungleleaves", - "moretrees:jungle_leaves_red", - "moretrees:jungle_leaves_yellow", - "moretrees:jungle_leaves_green" +vines = { + name = 'vines', + groups = { vines=1, snappy=3, flammable=2 }, + recipes = {} } --- Nodes -minetest.register_node("vines:rope_block", { - description = "Rope", - sunlight_propagates = true, - paramtype = "light", - tile_images = { - "default_wood.png^vines_rope.png", - "default_wood.png^vines_rope.png", - "default_wood.png", - "default_wood.png", - "default_wood.png^vines_rope.png", - "default_wood.png^vines_rope.png", - }, - drawtype = "cube", - groups = {choppy=2,oddly_breakable_by_hand=1}, - after_place_node = function(pos) - local p = {x=pos.x, y=pos.y-1, z=pos.z} - local n = minetest.get_node(p) - if n.name == "air" then - minetest.add_node(p, {name="vines:rope_end"}) - end - end, - after_dig_node = function(pos, node, digger) - local p = {x=pos.x, y=pos.y-1, z=pos.z} - local n = minetest.get_node(p) - while n.name == 'vines:rope' do - minetest.remove_node(p) - p = {x=p.x, y=p.y-1, z=p.z} - n = minetest.get_node(p) - end - if n.name == 'vines:rope_end' then - minetest.remove_node(p) - end - end -}) - -minetest.register_node("vines:rope", { - description = "Rope", - walkable = false, - climbable = true, - sunlight_propagates = true, - paramtype = "light", - drop = "", - tile_images = { "vines_rope.png" }, - drawtype = "plantlike", - groups = {flammable=2, not_in_creative_inventory=1}, - sounds = default.node_sound_leaves_defaults(), - selection_box = { - type = "fixed", - fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, - }, - on_destruct = function() - - end, -}) - -minetest.register_node("vines:rope_end", { - description = "Rope", - walkable = false, - climbable = true, - sunlight_propagates = true, - paramtype = "light", - drop = "", - tile_images = { "vines_rope_end.png" }, - drawtype = "plantlike", - groups = {flammable=2, not_in_creative_inventory=1}, - sounds = default.node_sound_leaves_defaults(), - after_place_node = function(pos) - yesh = {x = pos.x, y= pos.y-1, z=pos.z} - minetest.add_node(yesh, {name="vines:rope"}) - end, - selection_box = { - type = "fixed", - fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, - }, -}) - -minetest.register_node("vines:side", { - description = "Vine", - walkable = false, - climbable = true, - drop = "", - sunlight_propagates = true, - paramtype = "light", - paramtype2 = "wallmounted", - buildable_to = true, - tile_images = { "vines_side.png" }, - drawtype = "signlike", - inventory_image = "vines_side.png", - groups = vines_group, - sounds = default.node_sound_leaves_defaults(), - selection_box = { - type = "wallmounted", - }, - after_dig_node = function(pos, oldnode, oldmetadata, user) - local wielded if user:get_wielded_item() ~= nil then wielded = user:get_wielded_item() else return end - if 'vines:shears' == wielded:get_name() then - local inv = user:get_inventory() - if inv then - inv:add_item("main", ItemStack(oldnode.name)) - end - end - end -}) - -minetest.register_node("vines:side_rotten", { - description = "Vine", - walkable = false, - climbable = false, - drop = "", - sunlight_propagates = true, - paramtype = "light", - paramtype2 = "wallmounted", - buildable_to = true, - tile_images = { "vines_side_rotten.png" }, - drawtype = "signlike", - inventory_image = "vines_side.png", - groups = {snappy = 3,flammable=2, hanging_node=1,vines_cleanup=1}, - sounds = default.node_sound_leaves_defaults(), - selection_box = { - type = "wallmounted", - }, -}) - -minetest.register_node("vines:willow", { - description = "Vine", - walkable = false, - climbable = true, - drop = "", - sunlight_propagates = true, - paramtype = "light", - paramtype2 = "wallmounted", - buildable_to = true, - tile_images = { "vines_willow.png" }, - drawtype = "signlike", - inventory_image = "vines_willow.png", - groups = vines_group, - sounds = default.node_sound_leaves_defaults(), - selection_box = { - type = "wallmounted", - }, - after_dig_node = function(pos, oldnode, oldmetadata, user) - local wielded if user:get_wielded_item() ~= nil then wielded = user:get_wielded_item() else return end - if 'vines:shears' == wielded:get_name() then - local inv = user:get_inventory() - if inv then - inv:add_item("main", ItemStack(oldnode.name)) - end - end - end -}) - -minetest.register_node("vines:willow_rotten", { - description = "Vine", - walkable = false, - climbable = false, - sunlight_propagates = true, - paramtype = "light", - drop = "", - paramtype2 = "wallmounted", - buildable_to = true, - tile_images = { "vines_willow_rotten.png" }, - drawtype = "signlike", - inventory_image = "vines_willow.png", - groups = {snappy = 3,flammable=2, hanging_node=1,vines_cleanup=1}, - sounds = default.node_sound_leaves_defaults(), - selection_box = { - type = "wallmounted", - }, -}) - -minetest.register_node("vines:root", { - description = "Vine", - walkable = false, - climbable = true, - sunlight_propagates = true, - paramtype = "light", - buildable_to = true, - tile_images = { "vines_root.png" }, - drawtype = "plantlike", - inventory_image = "vines_root.png", - groups = {vines=1,snappy = 3,flammable=2, hanging_node=1,vines_cleanup=1}, - 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:vine", { - description = "Vine", - walkable = false, - climbable = true, - sunlight_propagates = true, - drop = "", - paramtype = "light", - buildable_to = true, - tile_images = { "vines_vine.png" }, - drawtype = "plantlike", - inventory_image = "vines_vine.png", - groups = vines_group, - sounds = default.node_sound_leaves_defaults(), - selection_box = { - type = "fixed", - fixed = {-0.3, -1/2, -0.3, 0.3, 1/2, 0.3}, - }, - after_dig_node = function(pos, oldnode, oldmetadata, user) - local wielded if user:get_wielded_item() ~= nil then wielded = user:get_wielded_item() else return end - if 'vines:shears' == wielded:get_name() then - local inv = user:get_inventory() - if inv then - inv:add_item("main", ItemStack(oldnode.name)) - end - end - end -}) - -minetest.register_node("vines:vine_rotten", { - description = "Rotten vine", - walkable = false, - climbable = true, - drop = "", - sunlight_propagates = true, - paramtype = "light", - buildable_to = true, - tile_images = { "vines_vine_rotten.png" }, - drawtype = "plantlike", - inventory_image = "vines_vine_rotten.png", - groups = {snappy = 3,flammable=2, hanging_node=1,vines_cleanup=1}, - sounds = default.node_sound_leaves_defaults(), - selection_box = { - type = "fixed", - fixed = {-0.3, -1/2, -0.3, 0.3, 1/2, 0.3}, - }, -}) - --- vine rotting - -minetest.register_abm({ - nodenames = {"vines:vine", "vines:side", "vines:willow"}, - interval = vines.rot_interval, - chance = vines.rot_chance, - action = function(pos, node, active_object_count, active_object_count_wider) - if minetest.find_node_near(pos, 5, "group:tree") == nil then - local walldir = node.param2 - minetest.add_node(pos, {name=node.name.."_rotten", param2 = walldir}) - end - end -}) - --- vine growth - -minetest.register_abm({ - nodenames = {"vines:vine", "vines:side", "vines:willow"}, - interval = vines.growth_interval, - chance = vines.growth_chance, - 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.get_node(p) - if n.name == "air" then - local walldir = node.param2 - minetest.add_node(p, {name=node.name, param2 = walldir}) - end - end -}) - --- cleanup if the initial tree is missing entirely (e.g. has been dug away) - -minetest.register_abm({ - nodenames = {"group:vines_cleanup"}, - interval = 10, - chance = 5, - action = function(pos, node, active_object_count, active_object_count_wider) - if not minetest.find_node_near(pos, 1, jungle_leaves_list) then - local p_top = {x=pos.x, y=pos.y+1, z=pos.z} - if minetest.get_item_group(minetest.get_node(p_top).name, "vines_cleanup") == 0 then - minetest.remove_node(pos) - end - end - end -}) - --- rope extension - -minetest.register_abm({ - nodenames = {"vines:rope_end"}, - interval = 1, - chance = 1, - drop = "", - 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.get_node(p) - --remove if top node is removed - if n.name == "air" then - minetest.set_node(pos, {name="vines:rope"}) - minetest.add_node(p, {name="vines:rope_end"}) - end - end -}) ---Craft -minetest.register_craft({ - output = 'vines:rope_block', - recipe = { - {'', 'default:wood', ''}, - {'', 'vines:side', ''}, - {'', 'vines:side', ''}, - } -}) - -minetest.register_craftitem("vines:vines", { - description = "Vines", - inventory_image = "vines_item.png", -}) ---spawning -plantslib:spawn_on_surfaces({ - avoid_nodes = {"vines:vine"}, - avoid_radius = 5, - spawn_delay = spawn_interval, - spawn_plants = {"vines:vine"}, - spawn_chance = 10, - spawn_surfaces = {"default:dirt_with_grass","default:dirt"}, - spawn_on_bottom = true, - plantlife_limit = -0.9, -}) - -plantslib:spawn_on_surfaces({ - avoid_nodes = {"vines:vine", "vines:side"}, - avoid_radius = 3, - spawn_delay = spawn_interval, - spawn_plants = {"vines:side"}, - spawn_chance = 10, - spawn_surfaces = jungle_leaves_list, - spawn_on_side = true, - near_nodes = {"default:jungletree"}, - near_nodes_size = 5, - plantlife_limit = -0.9, -}) - -plantslib:spawn_on_surfaces({ - spawn_plants = {"vines:willow"}, - spawn_delay = spawn_interval, - spawn_chance = 3, - spawn_surfaces = {"moretrees:willow_leaves"}, - spawn_on_side = true, - near_nodes = {"default:water_source"}, - near_nodes_size = 2, - near_nodes_vertical = 5, - near_nodes_count = 1, - plantlife_limit = -0.9, -}) - ---Shears jojoa1997's shears -minetest.register_tool("vines:shears", { - description = "Shears", - inventory_image = "shears.png", - wield_image = "shears.png", - stack_max = 1, - max_drop_level=3, - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=0, - groupcaps={ - snappy={times={[3]=0.2}, maxwear=0.05, maxlevel=3}, - wool={times={[3]=0.2}, maxwear=0.05, maxlevel=3} - } - }, -}) - -minetest.register_craft({ - output = 'vines:shears', - recipe = { - {'', 'default:steel_ingot', ''}, - {'default:stick', 'default:wood', 'default:steel_ingot'}, - {'', '', 'default:stick'}, - } -}) +dofile( minetest.get_modpath( vines.name ) .. "/functions.lua" ) +dofile( minetest.get_modpath( vines.name ) .. "/recipes.lua" ) +dofile( minetest.get_modpath( vines.name ) .. "/crafts.lua" ) +dofile( minetest.get_modpath( vines.name ) .. "/nodes.lua" ) +dofile( minetest.get_modpath( vines.name ) .. "/shear.lua" ) +dofile( minetest.get_modpath( vines.name ) .. "/vines.lua" ) +dofile( minetest.get_modpath( vines.name ) .. "/spawning.lua" ) print("[Vines] Loaded!") diff --git a/nodes.lua b/nodes.lua new file mode 100644 index 0000000..ab14b28 --- /dev/null +++ b/nodes.lua @@ -0,0 +1,83 @@ +minetest.register_node("vines:rope_block", { + description = "Rope", + sunlight_propagates = true, + paramtype = "light", + tile_images = { + "default_wood.png^vines_rope.png", + "default_wood.png^vines_rope.png", + "default_wood.png", + "default_wood.png", + "default_wood.png^vines_rope.png", + "default_wood.png^vines_rope.png", + }, + groups = { flammable=2, choppy=2, oddly_breakable_by_hand=1 }, + after_place_node = function(pos) + local p = {x=pos.x, y=pos.y-1, z=pos.z} + local n = minetest.get_node(p) + if n.name == "air" then + minetest.add_node(p, {name="vines:rope_end"}) + end + end, + after_dig_node = function(pos, node, digger) + local p = {x=pos.x, y=pos.y-1, z=pos.z} + local n = minetest.get_node(p) + while ( n.name == 'vines:rope' or n.name == 'vines:rope_end' ) do + minetest.remove_node(p) + p = {x=p.x, y=p.y-1, z=p.z} + n = minetest.get_node(p) + end + end +}) + +minetest.register_node("vines:rope", { + description = "Rope", + walkable = false, + climbable = true, + sunlight_propagates = true, + paramtype = "light", + drop = "", + tile_images = { "vines_rope.png" }, + drawtype = "plantlike", + groups = {flammable=2, not_in_creative_inventory=1}, + 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", + drop = "", + tile_images = { "vines_rope_end.png" }, + drawtype = "plantlike", + groups = {flammable=2, not_in_creative_inventory=1}, + sounds = default.node_sound_leaves_defaults(), + after_place_node = function(pos) + yesh = {x = pos.x, y= pos.y-1, z=pos.z} + minetest.add_node(yesh, {name="vines:rope"}) + end, + selection_box = { + type = "fixed", + fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7}, + }, + on_construct = function( pos ) + local timer = minetest.get_node_timer( pos ) + timer:start( 1 ) + end, + on_timer = function( pos, elapsed ) + local p = {x=pos.x, y=pos.y-1, z=pos.z} + local n = minetest.get_node(p) + if n.name == "air" then + minetest.set_node(pos, {name="vines:rope"}) + minetest.add_node(p, {name="vines:rope_end"}) + else + local timer = minetest.get_node_timer( pos ) + timer:start( 1 ) + end + end +}) diff --git a/recipes.lua b/recipes.lua new file mode 100644 index 0000000..a7d3b45 --- /dev/null +++ b/recipes.lua @@ -0,0 +1,12 @@ +vines.recipes['rope_block'] = { + {'', 'default:wood', ''}, + {'', 'vines:side', ''}, + {'', 'vines:side', ''} +} + +vines.recipes['shears'] = { + {'', 'default:steel_ingot', ''}, + {'default:stick', 'default:wood', 'default:steel_ingot'}, + {'', '', 'default:stick'} +} + diff --git a/shear.lua b/shear.lua new file mode 100644 index 0000000..5a0ddc4 --- /dev/null +++ b/shear.lua @@ -0,0 +1,15 @@ +minetest.register_tool("vines:shears", { + description = "Shears", + inventory_image = "shears.png", + wield_image = "shears.png", + stack_max = 1, + max_drop_level=3, + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=0, + groupcaps={ + snappy={times={[3]=0.2}, maxwear=0.05, maxlevel=3}, + wool={times={[3]=0.2}, maxwear=0.05, maxlevel=3} + } + }, +}) diff --git a/spawning.lua b/spawning.lua new file mode 100644 index 0000000..51b52c7 --- /dev/null +++ b/spawning.lua @@ -0,0 +1,47 @@ +plantslib:spawn_on_surfaces({ + avoid_nodes = {"vines:vine"}, + avoid_radius = 5, + spawn_delay = 500, + spawn_plants = {"vines:vine"}, + spawn_chance = 10, + spawn_surfaces = {"default:dirt_with_grass","default:dirt"}, + spawn_on_bottom = true, + plantlife_limit = -0.9, +}) + +plantslib:spawn_on_surfaces({ + avoid_nodes = {"vines:root"}, + avoid_radius = 5, + spawn_delay = 500, + spawn_plants = {"vines:vine"}, + spawn_chance = 10, + spawn_surfaces = {"default:dirt_with_grass","default:dirt"}, + spawn_on_bottom = true, + plantlife_limit = -0.9, +}) + +plantslib:spawn_on_surfaces({ + avoid_nodes = {"vines:vine", "vines:side"}, + avoid_radius = 3, + spawn_delay = 300, + spawn_plants = {"vines:side"}, + spawn_chance = 10, + spawn_surfaces = {}, --TODO + spawn_on_side = true, + near_nodes = {"default:jungletree"}, + near_nodes_size = 5, + plantlife_limit = -0.9, +}) + +plantslib:spawn_on_surfaces({ + spawn_plants = {"vines:willow"}, + spawn_delay = 200, + spawn_chance = 3, + spawn_surfaces = {"moretrees:willow_leaves"}, + spawn_on_side = true, + near_nodes = {"default:water_source"}, + near_nodes_size = 2, + near_nodes_vertical = 5, + near_nodes_count = 1, + plantlife_limit = -0.9, +}) diff --git a/vines.lua b/vines.lua new file mode 100644 index 0000000..a223ccd --- /dev/null +++ b/vines.lua @@ -0,0 +1,23 @@ +vines.register_vine( 'vine', { + description = "Vines", + is_side_vine = false, + average_length = 9 +}) + +vines.register_vine( 'root', { + description = "Roots", + is_side_vine = false, + average_length = 5 +}) + +vines.register_vine( 'side', { + description = "Vines", + is_side_vine = true, + average_length = 7 +}) + +vines.register_vine( 'willow', { + description = "Willow Vines", + is_side_vine = true, + average_length = 9 +}) From 797286f4d429c27269cdbc3bd1e5b23e16271145 Mon Sep 17 00:00:00 2001 From: bas080 Date: Fri, 13 Feb 2015 01:48:47 +0100 Subject: [PATCH 3/5] API Update + new vine - Defines biome in the vines_register function. Thus spawning.lua can be removed. - Vines destroy when a nearby( 3x3 ) leave is dug. They do not drop. To gather vines one still has to use the shears. - Soft depends on moretrees. Allows the overriding of the leave nodes. This is required for removing th vines when the leaves destruct. - Registered a new vine named "vines:jungle" Spawns on jungle tree trunks. Either on the moretrees jungles and the default jungletree nodes. - Textures for the jungle vines. --- depends.txt | 1 + functions.lua | 47 +++++++++++--- spawning.lua | 47 -------------- textures/vines_jungle.png | Bin 0 -> 497 bytes textures/vines_jungle_rotten.png | Bin 0 -> 481 bytes vines.lua | 103 +++++++++++++++++++++++++++---- 6 files changed, 131 insertions(+), 67 deletions(-) delete mode 100644 spawning.lua create mode 100644 textures/vines_jungle.png create mode 100644 textures/vines_jungle_rotten.png diff --git a/depends.txt b/depends.txt index d1473e1..4146336 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1,3 @@ default plants_lib +moretrees? diff --git a/functions.lua b/functions.lua index 219effb..5b946e8 100644 --- a/functions.lua +++ b/functions.lua @@ -1,8 +1,9 @@ -vines.register_vine = function( name, defs ) +vines.register_vine = function( name, defs, biome ) --different properties for bottom and side vines. + local drop_node = 'vines:'..name local drawtype = '' local selection_box - if ( defs.is_side_vine ) then + if ( biome.spawn_on_side ) then selection_box = { type = "wallmounted", } @@ -15,7 +16,9 @@ vines.register_vine = function( name, defs ) drawtype = 'plantlike' end - minetest.register_node("vines:"..name, { + biome.spawn_plants = { "vines:"..name } + + minetest.register_node( "vines:"..name, { description = defs.description, walkable = false, climbable = true, @@ -49,7 +52,7 @@ vines.register_vine = function( name, defs ) end end, after_dig_node = function(pos, node, oldmetadata, user) - vines.dig_vine( pos, node, user ) + vines.dig_vine( pos, drop_node, user ) end }) @@ -79,20 +82,48 @@ vines.register_vine = function( name, defs ) minetest.remove_node( bottom ) end end, - after_dig_node = function(pos, node, oldmetadata, user) - vines.dig_vine( pos, node, user ) + after_dig_node = function( pos, node, oldmetadata, user ) + vines.dig_vine( pos, drop_node, user ) end }) + + plantslib:spawn_on_surfaces( biome ) + + local override_nodes = function( nodes, defs ) + function override( index, registered ) + local node = nodes[ index ] + if index > #nodes then return registered end + if minetest.registered_nodes[node] then + print('overiding: '..node) + minetest.override_item( node, defs ) + registered[#registered+1] = node + end + override( index+1, registered ) + end + override( 1, {} ) + end + + override_nodes( biome.spawn_surfaces,{ + after_destruct = function( pos ) + local pos_min = { x = pos.x -1, y = pos.y - 1, z = pos.z - 1 } + local pos_max = { x = pos.x +1, y = pos.y + 1, z = pos.z + 1 } + local positions = minetest.find_nodes_in_area( pos_min, pos_max, "group:vines" ) + for index, position in pairs(positions) do + minetest.remove_node( position ) + end + end + }) + end -vines.dig_vine = function( pos, node, user ) +vines.dig_vine = function( pos, node_name, user ) --only dig give the vine if shears are used if not user then return false end local wielded = user:get_wielded_item() if 'vines:shears' == wielded:get_name() then local inv = user:get_inventory() if inv then - inv:add_item("main", ItemStack(node.name)) + inv:add_item("main", ItemStack( node_name )) end end end diff --git a/spawning.lua b/spawning.lua deleted file mode 100644 index 51b52c7..0000000 --- a/spawning.lua +++ /dev/null @@ -1,47 +0,0 @@ -plantslib:spawn_on_surfaces({ - avoid_nodes = {"vines:vine"}, - avoid_radius = 5, - spawn_delay = 500, - spawn_plants = {"vines:vine"}, - spawn_chance = 10, - spawn_surfaces = {"default:dirt_with_grass","default:dirt"}, - spawn_on_bottom = true, - plantlife_limit = -0.9, -}) - -plantslib:spawn_on_surfaces({ - avoid_nodes = {"vines:root"}, - avoid_radius = 5, - spawn_delay = 500, - spawn_plants = {"vines:vine"}, - spawn_chance = 10, - spawn_surfaces = {"default:dirt_with_grass","default:dirt"}, - spawn_on_bottom = true, - plantlife_limit = -0.9, -}) - -plantslib:spawn_on_surfaces({ - avoid_nodes = {"vines:vine", "vines:side"}, - avoid_radius = 3, - spawn_delay = 300, - spawn_plants = {"vines:side"}, - spawn_chance = 10, - spawn_surfaces = {}, --TODO - spawn_on_side = true, - near_nodes = {"default:jungletree"}, - near_nodes_size = 5, - plantlife_limit = -0.9, -}) - -plantslib:spawn_on_surfaces({ - spawn_plants = {"vines:willow"}, - spawn_delay = 200, - spawn_chance = 3, - spawn_surfaces = {"moretrees:willow_leaves"}, - spawn_on_side = true, - near_nodes = {"default:water_source"}, - near_nodes_size = 2, - near_nodes_vertical = 5, - near_nodes_count = 1, - plantlife_limit = -0.9, -}) diff --git a/textures/vines_jungle.png b/textures/vines_jungle.png new file mode 100644 index 0000000000000000000000000000000000000000..6c8d3395c22672f89f94543474ad4f43278cdedd GIT binary patch literal 497 zcmVujv1rY!M02y>e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00CJ^L_t(I%Y~A$YQr!TMeh@e z+CfW6OlTbt#bC(PX31bkw@xL{&&U__7y4(0bm#{JGH7tO&=4G`6JvFegsVD<7IQiG z;>Wv>?%!T8+AYynJ)`p)+wqhhZax9P>(Oor0H!PmdLPl#^S9?TTMT?SO$4f8Lk^~i zz}HVjE(`!F<9|3i7p{g4^;Pd=xEeOZVBd#$B(z?rx8rFir^!5mjEyM^f{YE71wm!p z=)8u?IN7h!dF{FLtBe!P76U&b0CMI~r-{I7eIOThoOOlMM0AE##{d0{wU*>ol+^Cm&4>?Wd5davw zRoK2wSrEzCpw+wQ&M#vFrZNs08>ESFVUz_?ng|z$8`&O}_m>5M>Ac3>^%bqw2dIpD nbD&)l2>s0VjG*VUy6yi3S<@2v-*6nm00000NkvXXu0mjf8G_Cw literal 0 HcmV?d00001 diff --git a/textures/vines_jungle_rotten.png b/textures/vines_jungle_rotten.png new file mode 100644 index 0000000000000000000000000000000000000000..bf838a508be60cdd6252a7c8b507f8411f54035f GIT binary patch literal 481 zcmV<70UrK|P)e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00Bu!L_t(I%Y{)0sY);n~uK-~2bh`ooE^~t31$1}+ZFyQOC)S+A9;)y_hD>4) zpFb5DGXSVmp77$Fxe5<7R-;~X6&^^SnYDLAXpM_Evw0^^w~qn*h`G!Oe#BJf1eHqG zSq+s+YF^e^ZF!?tsU%t~Cw4^uWW+8`Vh`^hzhumY7hUEg_BzcfmH$2yt>f5fj@gUb zdSQ;^M{IL1^xk5<3#c)5^7Qm_i9+w~YJS9Lb9Z|oT=7uuE^m8aRvpUS<)zMQQmJHQ zUkpgnSxtV#jJGux$J{N(u@{a0$cuJVOFXz78UA-8}d8j9U XCd?@z9_?7J00000NkvXXu0mjf+WNek literal 0 HcmV?d00001 diff --git a/vines.lua b/vines.lua index a223ccd..349a1ee 100644 --- a/vines.lua +++ b/vines.lua @@ -1,23 +1,102 @@ -vines.register_vine( 'vine', { - description = "Vines", - is_side_vine = false, - average_length = 9 -}) - vines.register_vine( 'root', { description = "Roots", - is_side_vine = false, - average_length = 5 + average_length = 9, +},{ + avoid_nodes = {"vines:root_rotten"}, + avoid_radius = 5, + spawn_delay = 500, + spawn_chance = 10, + spawn_surfaces = { + "default:dirt_with_grass", + "default:dirt" + }, + spawn_on_bottom = true, + plantlife_limit = -0.1, + temp_max = -0.6, + temp_min = 0.2, + humidity_max = -0.7, + humidity_min = 0.2, +}) + +vines.register_vine( 'vine', { + description = "Vines", + average_length = 5, +},{ + avoid_nodes = {"group:vines"}, + avoid_radius = 5, + spawn_delay = 500, + spawn_chance = 100, + spawn_surfaces = { + "default:leaves", + "default:jungleleave", + "moretrees:jungetree_leaves_red", + "moretrees:jungetree_leaves_yellow", + "moretrees:jungetree_leaves_green" + }, + spawn_on_bottom = true, + plantlife_limit = -0.9, + humidity_max = -1, + humidity_min = 0.8, + temp_max = -0.5, + temp_min = 0.3, }) vines.register_vine( 'side', { description = "Vines", - is_side_vine = true, - average_length = 7 + average_length = 7, +},{ + avoid_nodes = {"group:vines"}, + avoid_radius = 5, + spawn_delay = 500, + spawn_chance = 100, + spawn_surfaces = { + "default:leaves", + "default:jungleleave", + "moretrees:jungetree_leaves_red", + "moretrees:jungetree_leaves_yellow", + "moretrees:jungetree_leaves_green" + }, + spawn_on_side = true, + plantlife_limit = -0.9, + humidity_max = 1, + humidity_min = 0.8, + temp_min = 0.1, + temp_max = 1, +}) + +vines.register_vine( 'jungle', { + description = "Jungle Vines", + average_length = 7, +},{ + avoid_nodes = {"group:vines"}, + avoid_radius = 5, + spawn_delay = 500, + spawn_chance = 100, + spawn_surfaces = { + "default:jungletree", + "moretrees:jungletree_trunk" + }, + spawn_on_side = true, + plantlife_limit = -0.9, + humidity_max = 1, + humidity_min = 0.8, + temp_min = 0.1, + temp_max = 1, }) vines.register_vine( 'willow', { description = "Willow Vines", - is_side_vine = true, - average_length = 9 + average_length = 9, +},{ + avoid_nodes = {"vines:willow", "vines:willow_rotten"}, + avoid_radius = 5, + spawn_delay = 500, + spawn_chance = 100, + spawn_surfaces = {"moretrees:willow_leaves"}, + spawn_on_side = true, + plantlife_limit = -0.9, + humidity_max = 1, + humidity_min = 0.8, + temp_min = 0.1, + temp_max = 1, }) From 7bb3f5e04271872972553cfb29a5526e607191cf Mon Sep 17 00:00:00 2001 From: bas080 Date: Fri, 13 Feb 2015 01:54:35 +0100 Subject: [PATCH 4/5] Documentation update - Very minimal API documentation. The code should be self explanatory. - LICENSE information. --- LICENSE.md | 4 ++++ README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 LICENSE.md create mode 100644 README.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..fb67788 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,4 @@ +License +======= +- Code WTFPL +- Texture CC diff --git a/README.md b/README.md new file mode 100644 index 0000000..8840a74 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# Vines + +## Features +- Rope block for spawning rope that slowly drops into the deep. +- Vines are climbable and slowly grow downward. +- Shears that allow the collecting of vines. +- Spawns vines on jungletree leaves. +- Roots on the bottom of dirt and dirt with grass nodes. +- Spawns vines on trees located in swampy area. +- Jungle vines that spawn on the side of jungletrees + +## API +The API is very minimal. It allows the registering of vines. + +There are two types of vines. One that spawns at the bottom of nodes and uses the +plantlike drawtype, and vines that spawn on the side that use signlike +drawtype. + +### Example +*taken from mod* + +```lua + vines.register_vine( 'vine', { + description = "Vines", + is_side_vine = false, + average_length = 9 + }, biome ) +``` + +|key| type| description| +|---| ---| ---| +|description| string|The node tooltip description| +|is_side_vine| bool| If not a side vine it is a plantlike drawtype bottom vine| +|average_length|int| The average length of vines| +|biome| table| A plants_lib biome format (see plants_lib documentation)| + +## Notice +Vines use after_destruct on registered leave nodes to remove vines from which +the leaves are removed. This is done by using the override function. +Malfunctions may occur if other mods override the after_destruct of these nodes +also. From 46c891d4d6107f90b54ced10292c3e9aca7cbcff Mon Sep 17 00:00:00 2001 From: bas080 Date: Fri, 13 Feb 2015 02:10:35 +0100 Subject: [PATCH 5/5] README Update - Link to plants_lib API for explaining the biome argument - Minor changes to the example. --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8840a74..b5ce524 100644 --- a/README.md +++ b/README.md @@ -20,19 +20,25 @@ drawtype. *taken from mod* ```lua + + vines.register_vine( name, definitions, biome ) + + --e.g. + vines.register_vine( 'vine', { description = "Vines", - is_side_vine = false, average_length = 9 }, biome ) + ``` +### definitions |key| type| description| |---| ---| ---| -|description| string|The node tooltip description| -|is_side_vine| bool| If not a side vine it is a plantlike drawtype bottom vine| +|description| string|The vine's tooltip description| |average_length|int| The average length of vines| -|biome| table| A plants_lib biome format (see plants_lib documentation)| + +For biome definitions please see the [plants_lib API documentation](https://github.com/VanessaE/plantlife_modpack/blob/master/API.txt) ## Notice Vines use after_destruct on registered leave nodes to remove vines from which