From 3e1772412511b8af95fc38301d03e1e3fbac13da Mon Sep 17 00:00:00 2001 From: Bas Date: Sat, 26 Jan 2013 02:56:38 +0100 Subject: [PATCH] Added willow vine and spawn_interval variable at the top of the init.lua --- init.lua | 90 ++++++++++++++++++++++++++++++-------- textures/vines_willow.png | Bin 0 -> 316 bytes 2 files changed, 72 insertions(+), 18 deletions(-) create mode 100644 textures/vines_willow.png diff --git a/init.lua b/init.lua index 663c906..3c3c147 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,7 @@ + local mod_name = "vines" local average_height = 12 +local spawn_interval = 1500 -- Nodes minetest.register_node("vines:rope_block", { @@ -25,6 +27,18 @@ minetest.register_node("vines:rope_block", { minetest.env: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.env:get_node(p) + while n.name == 'vines:rope' do + minetest.env:remove_node(p) + p = {x=p.x, y=p.y-1, z=p.z} + n = minetest.env:get_node(p) + end + if n.name == 'vines:rope_end' then + minetest.env:remove_node(p) + end + end }) minetest.register_node("vines:rope", { @@ -99,6 +113,41 @@ minetest.register_node("vines:side", { end, }) +minetest.register_node("vines:willow", { + description = "Vine", + walkable = false, + climbable = true, + drop = 'vines:vines', + sunlight_propagates = true, + paramtype = "light", + paramtype2 = "wallmounted", + tile_images = { "vines_willow.png" }, + drawtype = "signlike", + inventory_image = "vines_side.png", + groups = { snappy = 3,flammable=2, hanging=1 }, + sounds = default.node_sound_leaves_defaults(), + selection_box = { + type = "wallmounted", + }, + on_construct = function(pos, placer) + local p = {x=pos.x, y=pos.y, z=pos.z} + local n = minetest.env:get_node(p) + local walldir = n.param2 + local down=-1 + + while math.random(0,average_height) > 1.0 do + local pt = {x = p.x, y= p.y+down, z=p.z} + local nt = minetest.env:get_node(pt) + if nt.name == "air" then + minetest.env:add_node(pt, {name=n.name, param2 = walldir}) + down=down-1 + else + return + end + end + end, +}) + minetest.register_node("vines:root", { description = "Vine", walkable = false, @@ -155,6 +204,7 @@ minetest.register_node("vines:vine_rotten", { --ABM --make vines grow downward +--[[ minetest.register_abm({ nodenames = {"vines:vine", "vines:side", "vines:root"}, interval = 300, @@ -169,6 +219,8 @@ minetest.register_abm({ end }) +]]-- + minetest.register_abm({ nodenames = {"default:dirt", "default:dirt_with_grass"}, interval = 36000, @@ -212,28 +264,30 @@ minetest.register_craftitem("vines:vines", { inventory_image = "vines_item.png", }) ---remove rope when rope block is removed -minetest.register_on_dignode(function (pos, node, player) - if node.name == 'vines:rope_block' then - local p = {x=pos.x, y=pos.y-1, z=pos.z} - local n = minetest.env:get_node(p) - while n.name == 'vines:rope' do - minetest.env:remove_node(p) - p = {x=p.x, y=p.y-1, z=p.z} - n = minetest.env:get_node(p) - end - if n.name == 'vines:rope_end' then - minetest.env:remove_node(p) - end - end -end) - plantslib:spawn_on_surfaces({ - spawn_delay = 300, + spawn_delay = spawn_interval, spawn_plants = {"vines:side"}, - spawn_chance = 10, + spawn_chance = 1, spawn_surfaces = {"default:leaves"}, spawn_on_side = true }) +plantslib:spawn_on_surfaces({ + spawn_delay = spawn_interval, + spawn_plants = {"vines:vine"}, + spawn_chance = 1, + spawn_surfaces = {"default:leaves"}, + spawn_on_bottom = true +}) + +plantslib:spawn_on_surfaces({ + spawn_delay = spawn_interval, + spawn_plants = {"vines:willow"}, + spawn_chance = 1, + spawn_surfaces = {"moretrees:willow_leaves"}, + spawn_on_side = true, + near_nodes = {"default:water_source"}, + near_nodes_size = 4 +}) + print("[Vines] Loaded!") diff --git a/textures/vines_willow.png b/textures/vines_willow.png new file mode 100644 index 0000000000000000000000000000000000000000..91f8feff37049211dba0375a592c567b2c1fd3ec GIT binary patch literal 316 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4$|-Z8Wqyu9xQ6yYrJ zh%9Dc;1&j9Muu5)B!GhKC7!;n>~|TZ7_u0mrMvphOHqFk z-ZLs$ooRniI<-tprEpMDoIclvuB=7P45#y}KMKg>e)OP|s#o+1c K=d#Wzp$Py0uX(co literal 0 HcmV?d00001