Add vine
This commit is contained in:
parent
cc01719e0c
commit
0a19253ae3
@ -81,6 +81,7 @@ This is the list of all groups used for nodes. Note: If no number/rating is spec
|
|||||||
* `interactive_node`: Node can be interacted with (excluding pure container nodes)
|
* `interactive_node`: Node can be interacted with (excluding pure container nodes)
|
||||||
* `no_spawn_allowed_on`: If set, players can not (initially) spawn on this block
|
* `no_spawn_allowed_on`: If set, players can not (initially) spawn on this block
|
||||||
* `spawn_allowed_in`: If set, players can spawn into this block (note: this group is ignored for the 'air' and 'ignore' nodes)
|
* `spawn_allowed_in`: If set, players can spawn into this block (note: this group is ignored for the 'air' and 'ignore' nodes)
|
||||||
|
* `_attached_node_top=1`: Node attaches to the top of another node. If the node above disappears, the node itself detaches
|
||||||
|
|
||||||
### Node categorization
|
### Node categorization
|
||||||
|
|
||||||
|
8
mods/rp_attached/init.lua
Normal file
8
mods/rp_attached/init.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
minetest.register_on_dignode(function(pos, oldnode, digger)
|
||||||
|
local below = vector.add(pos, vector.new(0,-1,0))
|
||||||
|
local belownode = minetest.get_node(below)
|
||||||
|
local at = minetest.get_item_group(belownode.name, "_attached_node_top") == 1
|
||||||
|
if at then
|
||||||
|
util.dig_down(pos, belownode, digger)
|
||||||
|
end
|
||||||
|
end)
|
3
mods/rp_attached/mod.conf
Normal file
3
mods/rp_attached/mod.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = rp_attached
|
||||||
|
description = Adds more ways for nodes to be attached
|
||||||
|
depends = rp_util
|
@ -1573,6 +1573,80 @@ default.register_decoration(
|
|||||||
seed = 43905,
|
seed = 43905,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Vine decorations
|
||||||
|
--
|
||||||
|
default.register_decoration(
|
||||||
|
{
|
||||||
|
deco_type = "simple",
|
||||||
|
place_on = {"rp_default:stone", "group:dirt"},
|
||||||
|
sidelen = 16,
|
||||||
|
fill_ratio = 0.02,
|
||||||
|
biomes = { "Birch Forest", "Birch Forest Underwater", "Dense Oak Forest", "Forest", "Forest Underwater", "Grassland", "Grassland Underwater", "Grove", "Grove Underwater", "Oak Forest", "Oak Forest Underwater", "Tall Birch Forest", "Tall Birch Forest Underwater", "Tall Oak Forest", "Tall Oak Forest Underwater", },
|
||||||
|
decoration = {"rp_default:vine"},
|
||||||
|
y_min = -30,
|
||||||
|
y_max = default.GLOBAL_Y_MAX,
|
||||||
|
height = 1,
|
||||||
|
height_max = 5,
|
||||||
|
flags = "all_ceilings",
|
||||||
|
})
|
||||||
|
default.register_decoration(
|
||||||
|
{
|
||||||
|
deco_type = "simple",
|
||||||
|
place_on = {"rp_default:stone", "group:dirt"},
|
||||||
|
sidelen = 16,
|
||||||
|
fill_ratio = 0.03,
|
||||||
|
biomes = { "Dense Grassland", "Shrubbery", "Shrubbery Underwater", "Oak Shrubbery", "Oak Shrubbery Underwater" },
|
||||||
|
decoration = {"rp_default:vine"},
|
||||||
|
y_min = -30,
|
||||||
|
y_max = default.GLOBAL_Y_MAX,
|
||||||
|
height = 1,
|
||||||
|
height_max = 10,
|
||||||
|
flags = "all_ceilings",
|
||||||
|
})
|
||||||
|
default.register_decoration(
|
||||||
|
{
|
||||||
|
deco_type = "simple",
|
||||||
|
place_on = {"rp_default:stone", "group:dirt"},
|
||||||
|
sidelen = 16,
|
||||||
|
fill_ratio = 0.04,
|
||||||
|
biomes = { "Dense Grassland", "Dense Oak Forest", "Grove", "Grove Underwater" },
|
||||||
|
decoration = {"rp_default:vine"},
|
||||||
|
y_min = -30,
|
||||||
|
y_max = default.GLOBAL_Y_MAX,
|
||||||
|
height = 1,
|
||||||
|
height_max = 7,
|
||||||
|
flags = "all_ceilings",
|
||||||
|
})
|
||||||
|
default.register_decoration(
|
||||||
|
{
|
||||||
|
deco_type = "simple",
|
||||||
|
place_on = {"rp_default:stone", "group:dirt"},
|
||||||
|
sidelen = 16,
|
||||||
|
fill_ratio = 0.2,
|
||||||
|
biomes = { "Wilderness", "Wilderness Underwater", },
|
||||||
|
decoration = {"rp_default:vine"},
|
||||||
|
y_min = -30,
|
||||||
|
y_max = default.GLOBAL_Y_MAX,
|
||||||
|
height = 1,
|
||||||
|
height_max = 7,
|
||||||
|
flags = "all_ceilings",
|
||||||
|
})
|
||||||
|
default.register_decoration(
|
||||||
|
{
|
||||||
|
deco_type = "simple",
|
||||||
|
place_on = {"rp_default:stone", "group:dirt"},
|
||||||
|
sidelen = 16,
|
||||||
|
fill_ratio = 0.08,
|
||||||
|
biomes = { "Marsh", "Marsh Beach", "Marsh Underwater", "Deep Forest", "Dense Oak Forest", "Mystery Forest", "Mystery Forest Underwater" },
|
||||||
|
decoration = {"rp_default:vine"},
|
||||||
|
y_min = -30,
|
||||||
|
y_max = default.GLOBAL_Y_MAX,
|
||||||
|
height = 1,
|
||||||
|
height_max = 20,
|
||||||
|
flags = "all_ceilings",
|
||||||
|
})
|
||||||
|
|
||||||
end
|
end
|
||||||
-- Papyrus decorations
|
-- Papyrus decorations
|
||||||
|
|
||||||
@ -2156,4 +2230,3 @@ default.register_decoration(
|
|||||||
y_max = 1,
|
y_max = 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,6 +72,76 @@ minetest.register_node(
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Vine
|
||||||
|
|
||||||
|
minetest.register_node(
|
||||||
|
"rp_default:vine",
|
||||||
|
{
|
||||||
|
description = S("Vine"),
|
||||||
|
_tt_help = S("Hangs from stone or dirt"),
|
||||||
|
drawtype = "plantlike",
|
||||||
|
tiles = {"rp_default_vine.png"},
|
||||||
|
use_texture_alpha = "clip",
|
||||||
|
inventory_image = "rp_default_vine_inventory.png",
|
||||||
|
wield_image = "rp_default_vine_inventory.png",
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
walkable = false,
|
||||||
|
climbable = true,
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {-2/16, -0.5, -2/16, 2/16, 0.5, 2/16 },
|
||||||
|
},
|
||||||
|
floodable = true,
|
||||||
|
groups = {_attached_node_top = 1, snappy = 3, plant = 1, vine = 1},
|
||||||
|
sounds = rp_sounds.node_sound_leaves_defaults(),
|
||||||
|
after_dig_node = function(pos, node, metadata, digger)
|
||||||
|
util.dig_down(pos, node, digger)
|
||||||
|
end,
|
||||||
|
after_destruct = function(pos, oldnode)
|
||||||
|
util.dig_down(pos, oldnode)
|
||||||
|
end,
|
||||||
|
on_flood = function(pos, oldnode, newnode)
|
||||||
|
util.dig_down(pos, oldnode)
|
||||||
|
end,
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
-- Boilerplate to handle pointed node handlers
|
||||||
|
local handled, handled_itemstack = util.on_place_pointed_node_handler(itemstack, placer, pointed_thing)
|
||||||
|
if handled then
|
||||||
|
return handled_itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Find position to place vine at
|
||||||
|
local place_in, place_floor = util.pointed_thing_to_place_pos(pointed_thing, true)
|
||||||
|
if place_in == nil then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
local ceilingnode = minetest.get_node(place_floor)
|
||||||
|
|
||||||
|
-- Ceiling must be stone, dirt or another vine
|
||||||
|
if minetest.get_item_group(ceilingnode.name, "dirt") == 0 and ceilingnode.name ~= "rp_default:stone" and ceilingnode.name ~= "rp_default:vine" then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check protection
|
||||||
|
if minetest.is_protected(place_in, placer:get_player_name()) and
|
||||||
|
not minetest.check_player_privs(placer, "protection_bypass") then
|
||||||
|
minetest.record_protection_violation(pos, placer:get_player_name())
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Place vine
|
||||||
|
minetest.set_node(place_in, {name = itemstack:get_name()})
|
||||||
|
|
||||||
|
-- Reduce item count
|
||||||
|
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||||
|
itemstack:take_item()
|
||||||
|
end
|
||||||
|
|
||||||
|
return itemstack
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- Fern
|
-- Fern
|
||||||
|
|
||||||
minetest.register_node(
|
minetest.register_node(
|
||||||
|
BIN
mods/rp_default/textures/rp_default_vine.png
Normal file
BIN
mods/rp_default/textures/rp_default_vine.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
BIN
mods/rp_default/textures/rp_default_vine_inventory.png
Normal file
BIN
mods/rp_default/textures/rp_default_vine_inventory.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
@ -90,6 +90,12 @@ minetest.register_craftitem(
|
|||||||
minetest.set_node(top, {name=unode.name})
|
minetest.set_node(top, {name=unode.name})
|
||||||
used = true
|
used = true
|
||||||
end
|
end
|
||||||
|
elseif (unode.name == "rp_default:vine") then
|
||||||
|
local top = vector.add(upos, vector.new(0,-1,0))
|
||||||
|
if minetest.get_node(top).name == "air" then
|
||||||
|
minetest.set_node(top, {name=unode.name})
|
||||||
|
used = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if used then
|
if used then
|
||||||
|
@ -211,13 +211,20 @@ end
|
|||||||
-- `digger` is a player object that will be treated as
|
-- `digger` is a player object that will be treated as
|
||||||
-- the 'digger' of said nodes.
|
-- the 'digger' of said nodes.
|
||||||
function util.dig_up(pos, node, digger)
|
function util.dig_up(pos, node, digger)
|
||||||
|
if node.name == "ignore" then
|
||||||
|
return
|
||||||
|
end
|
||||||
local np = {x = pos.x, y = pos.y + 1, z = pos.z}
|
local np = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||||
local nn = minetest.get_node(np)
|
local nn = minetest.get_node(np)
|
||||||
if nn.name == node.name then
|
if nn.name == node.name then
|
||||||
if digger then
|
if digger then
|
||||||
minetest.node_dig(np, nn, digger)
|
minetest.node_dig(np, nn, digger)
|
||||||
else
|
else
|
||||||
|
while nn.name == node.name do
|
||||||
minetest.remove_node(np)
|
minetest.remove_node(np)
|
||||||
|
np.y = np.y + 1
|
||||||
|
nn = minetest.get_node(np)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -227,10 +234,21 @@ end
|
|||||||
-- `digger` is a player object that will be treated as
|
-- `digger` is a player object that will be treated as
|
||||||
-- the 'digger' of said nodes.
|
-- the 'digger' of said nodes.
|
||||||
function util.dig_down(pos, node, digger)
|
function util.dig_down(pos, node, digger)
|
||||||
|
if node.name == "ignore" then
|
||||||
|
return
|
||||||
|
end
|
||||||
local np = {x = pos.x, y = pos.y - 1, z = pos.z}
|
local np = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||||
local nn = minetest.get_node(np)
|
local nn = minetest.get_node(np)
|
||||||
if nn.name == node.name then
|
if nn.name == node.name then
|
||||||
|
if digger then
|
||||||
minetest.node_dig(np, nn, digger)
|
minetest.node_dig(np, nn, digger)
|
||||||
|
else
|
||||||
|
while nn.name == node.name do
|
||||||
|
minetest.remove_node(np)
|
||||||
|
np.y = np.y - 1
|
||||||
|
nn = minetest.get_node(np)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -241,13 +259,21 @@ end
|
|||||||
-- into account.
|
-- into account.
|
||||||
--
|
--
|
||||||
-- Takes a pointed_thing from a on_place callback or similar.
|
-- Takes a pointed_thing from a on_place callback or similar.
|
||||||
|
-- * `pointed_thing`: A pointed thing
|
||||||
|
-- * `top`: (optional): If true, is for plant placement at ceiling
|
||||||
|
-- instead (default: false)
|
||||||
|
--
|
||||||
-- Returns `<place_in>, <place_on>` if successful, `nil` otherwise
|
-- Returns `<place_in>, <place_on>` if successful, `nil` otherwise
|
||||||
-- * `place_in`: Where the node is suggested to be placed
|
-- * `place_in`: Where the node is suggested to be placed
|
||||||
-- * `place_on`: Directly below place_in
|
-- * `place_on`: Directly below place_in
|
||||||
function util.pointed_thing_to_place_pos(pointed_thing)
|
function util.pointed_thing_to_place_pos(pointed_thing, top)
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
local offset = -1
|
||||||
|
if top then
|
||||||
|
offset = 1
|
||||||
|
end
|
||||||
local place_in, place_on
|
local place_in, place_on
|
||||||
local undernode = minetest.get_node(pointed_thing.under)
|
local undernode = minetest.get_node(pointed_thing.under)
|
||||||
local underdef = minetest.registered_nodes[undernode.name]
|
local underdef = minetest.registered_nodes[undernode.name]
|
||||||
@ -256,10 +282,10 @@ function util.pointed_thing_to_place_pos(pointed_thing)
|
|||||||
end
|
end
|
||||||
if underdef.buildable_to then
|
if underdef.buildable_to then
|
||||||
place_in = pointed_thing.under
|
place_in = pointed_thing.under
|
||||||
place_on = vector.add(place_in, vector.new(0, -1, 0))
|
place_on = vector.add(place_in, vector.new(0, offset, 0))
|
||||||
else
|
else
|
||||||
place_in = pointed_thing.above
|
place_in = pointed_thing.above
|
||||||
place_on = vector.add(place_in, vector.new(0, -1, 0))
|
place_on = vector.add(place_in, vector.new(0, offset, 0))
|
||||||
local inname = minetest.get_node(place_in).name
|
local inname = minetest.get_node(place_in).name
|
||||||
local indef = minetest.registered_nodes[inname]
|
local indef = minetest.registered_nodes[inname]
|
||||||
if not indef or not indef.buildable_to then
|
if not indef or not indef.buildable_to then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user