mirror of
https://github.com/minetest-mods/ropes.git
synced 2024-11-28 10:23:44 +01:00
New vines and compatible with plant_lib
This commit is contained in:
parent
ed515fb249
commit
d669079a60
12
README.md
12
README.md
@ -1,4 +1,12 @@
|
||||
vines
|
||||
Vines
|
||||
=====
|
||||
|
||||
Vines mod for minetest. Also adds ropes.
|
||||
Description
|
||||
====
|
||||
Vines mod for Minetest. That also adds ropebox
|
||||
|
||||
Types of vines
|
||||
=====
|
||||
* Side vines
|
||||
* Root vines
|
||||
* Bottom vines
|
||||
|
@ -1 +1,2 @@
|
||||
default
|
||||
plants_lib
|
||||
|
181
init.lua
181
init.lua
@ -1,4 +1,12 @@
|
||||
print("[Vines] v1.0")
|
||||
--Vines Mod for minetest adds vines to trees and dirt with grass nodes,
|
||||
--Also adds spawning API made for things that grow on the side of nodes signlike(param2) and things that grow downward.
|
||||
|
||||
--BY: Bas080
|
||||
--DESCRIPTION: Vines for minetest
|
||||
--Licence: WTFPL
|
||||
|
||||
local mod_name = "vines"
|
||||
local average_height = 12
|
||||
|
||||
-- Nodes
|
||||
minetest.register_node("vines:rope_block", {
|
||||
@ -40,7 +48,6 @@ minetest.register_node("vines:rope", {
|
||||
type = "fixed",
|
||||
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
|
||||
},
|
||||
|
||||
})
|
||||
|
||||
minetest.register_node("vines:rope_end", {
|
||||
@ -64,6 +71,61 @@ minetest.register_node("vines:rope_end", {
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node("vines:side", {
|
||||
description = "Vine",
|
||||
walkable = false,
|
||||
climbable = true,
|
||||
drop = 'vines:vines',
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
tile_images = { "vines_side.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
|
||||
|
||||
print("Placed")
|
||||
|
||||
while math.random(0,average_height) > 1.0 do
|
||||
print("One")
|
||||
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,
|
||||
climbable = true,
|
||||
drop = 'vines:vines',
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
tile_images = { "vines_root.png" },
|
||||
drawtype = "plantlike",
|
||||
inventory_image = "vines_root.png",
|
||||
groups = { snappy = 3,flammable=2, hanging=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",
|
||||
@ -77,6 +139,10 @@ minetest.register_node("vines:vine", {
|
||||
inventory_image = "vines_vine.png",
|
||||
groups = { snappy = 3,flammable=2, hanging=1 },
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -1/2, -0.3, 0.3, 1/2, 0.3},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node("vines:vine_rotten", {
|
||||
@ -91,71 +157,26 @@ minetest.register_node("vines:vine_rotten", {
|
||||
inventory_image = "vines_vine_rotten.png",
|
||||
groups = { snappy = 3,flammable=2, hanging=1 },
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -1/2, -0.3, 0.3, 1/2, 0.3},
|
||||
},
|
||||
})
|
||||
|
||||
--ABM
|
||||
--make vines grow downward
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:leaves", "growing_trees:leaves", "default:dirt_with_grass", },
|
||||
interval = 180,
|
||||
chance = 200,
|
||||
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,
|
||||
nodenames = {"vines:vine", "vines:side", "vines:root"},
|
||||
interval = 300,
|
||||
chance = 8,
|
||||
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(pos, {name="vines:vine_rotten"})
|
||||
minetest.env:add_node(p, {name="vines:vine"})
|
||||
walldir = node.param2
|
||||
minetest.env:add_node(p, {name=node.name, param2 = walldir})
|
||||
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({
|
||||
@ -163,15 +184,10 @@ minetest.register_abm({
|
||||
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({
|
||||
@ -179,7 +195,6 @@ minetest.register_abm({
|
||||
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)
|
||||
|
||||
@ -192,33 +207,6 @@ minetest.register_abm({
|
||||
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',
|
||||
@ -231,9 +219,10 @@ minetest.register_craft({
|
||||
|
||||
minetest.register_craftitem("vines:vines", {
|
||||
description = "Vines",
|
||||
inventory_image = "vines_vine.png",
|
||||
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}
|
||||
@ -248,3 +237,13 @@ minetest.register_on_dignode(function (pos, node, player)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
plantslib:spawn_on_surfaces({
|
||||
spawn_delay = 300,
|
||||
spawn_plants = {"vines:side"},
|
||||
spawn_chance = 10,
|
||||
spawn_surfaces = {"default:leaves"},
|
||||
spawn_on_side = true
|
||||
})
|
||||
|
||||
print("[Vines] Loaded!")
|
||||
|
BIN
textures/vines_item.png
Normal file
BIN
textures/vines_item.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 359 B |
BIN
textures/vines_root.png
Normal file
BIN
textures/vines_root.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 441 B |
BIN
textures/vines_side.png
Normal file
BIN
textures/vines_side.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 537 B |
Loading…
Reference in New Issue
Block a user