Compare commits
10 Commits
a1befc5957
...
97f2a02feb
Author | SHA1 | Date | |
---|---|---|---|
|
97f2a02feb | ||
|
ebdee92787 | ||
|
408d51b4a1 | ||
|
3cbaf29f74 | ||
|
3b4b03836d | ||
|
a3d9b5403e | ||
|
bd11b222d3 | ||
|
1264daae8f | ||
|
3d3c598103 | ||
|
851b5c800c |
@ -1,6 +1,6 @@
|
||||
Hedges
|
||||
======
|
||||
Hedges mod for Minetest by Shara RedCat which adds hedges that automatically connect to each other when placed and that can be crafted from leaves.
|
||||
Hedges mod for Minetest by Shara RedCat which adds hedges that automatically connect to each other when placed and that can be crafted from leaves. Hedges connect both horizontally and vertically, making it possible to build hedge mazes a player cannot jump over.
|
||||
|
||||
|
||||
API
|
||||
@ -19,8 +19,10 @@ hedges.register_hedge("mod_name:hedge_name", {
|
||||
|
||||
You can also include the following in the definition:
|
||||
|
||||
- description: this will just be "Hedge" if not defined.
|
||||
- groups: must include 'hedge = 1'. Will be {snappy = 3, flammable = 2, leaves = 1, hedge = 1} if not defined.
|
||||
- description: "Hedge" if not defined.
|
||||
- groups: must include "hedge = 1". Will be {snappy = 3, flammable = 2, leaves = 1, hedge = 1} if not defined.
|
||||
- sounds: "default.node_sound_leaves_defaults()" if not defined.
|
||||
- light_source: 0 if not defined.
|
||||
|
||||
|
||||
Licenses and Attribution
|
||||
|
@ -1 +1 @@
|
||||
default
|
||||
default?
|
131
init.lua
131
init.lua
@ -1,10 +1,14 @@
|
||||
|
||||
local hedges = {}
|
||||
hedges = {}
|
||||
|
||||
function hedges.register_hedge(name, def)
|
||||
|
||||
-- register node
|
||||
minetest.register_node(name, {
|
||||
-- register nodes
|
||||
if minetest.get_modpath("default") then
|
||||
def.sounds = def.sounds or default.node_sound_leaves_defaults()
|
||||
end
|
||||
|
||||
minetest.register_node(":" .. name, {
|
||||
description = def.description or "Hedge",
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
@ -14,14 +18,67 @@ function hedges.register_hedge(name, def)
|
||||
waving = 1,
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {{-0.3, -0.5, -0.3, 0.3, 0.4, 0.3}},
|
||||
connect_left = {{-0.5, -0.5, -0.3, -0.3, 0.4, 0.3}},
|
||||
connect_right = {{0.3, -0.5, -0.3, 0.5, 0.4, 0.3}},
|
||||
connect_front = {{-0.3, -0.5, -0.5, 0.3, 0.4, -0.3}},
|
||||
connect_back = {{-0.3, -0.5, 0.3, 0.3, 0.4, 0.5}},
|
||||
fixed = {{-5/16, -0.5, -5/16, 5/16, 5/16, 5/16}},
|
||||
connect_left = {{-0.5, -0.5, -5/16, -5/16, 5/16, 5/16}},
|
||||
connect_right = {{5/16, -0.5, -5/16, 0.5, 5/16, 5/16}},
|
||||
connect_front = {{-5/16, -0.5, -0.5, 5/16, 5/16, -5/16}},
|
||||
connect_back = {{-5/16, -0.5, 5/16, 5/16, 5/16, 0.5}},
|
||||
},
|
||||
connects_to = {"group:fence", "group:wood", "group:tree", "group:hedge"},
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
light_source = def.light_source or 0,
|
||||
sounds = def.sounds,
|
||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
local pos_under = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||
local pos_above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||
local node_under = string.gsub(minetest.get_node(pos_under).name, "_full$", "")
|
||||
local node_above = string.gsub(minetest.get_node(pos_above).name, "_full$", "")
|
||||
|
||||
if minetest.get_item_group(node_under, "hedge") == 1 then
|
||||
minetest.set_node(pos_under, {name = node_under .. "_full"})
|
||||
end
|
||||
if minetest.get_item_group(node_above, "hedge") == 1 then
|
||||
minetest.set_node(pos, {name = name .. "_full"})
|
||||
end
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local pos_under = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||
local node_under = string.gsub(minetest.get_node(pos_under).name, "_full$", "")
|
||||
if minetest.get_item_group(node_under, "hedge") == 1 and
|
||||
digger and digger:is_player() then
|
||||
minetest.set_node(pos_under, {name = node_under})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node(":" .. name .. "_full", {
|
||||
description = def.description or "Hedge",
|
||||
drawtype = "nodebox",
|
||||
paramtype = "light",
|
||||
tiles = {def.texture},
|
||||
groups = def.groups or
|
||||
{snappy = 3, flammable = 2, leaves = 1, hedge = 1,
|
||||
not_in_creative_inventory = 1},
|
||||
waving = 1,
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {{-5/16, -0.5, -5/16, 5/16, 0.5, 5/16}},
|
||||
connect_left = {{-0.5, -0.5, -5/16, -5/16, 0.5, 5/16}},
|
||||
connect_right = {{5/16, -0.5, -5/16, 0.5, 0.5, 5/16}},
|
||||
connect_front = {{-5/16, -0.5, -0.5, 5/16, 0.5, -5/16}},
|
||||
connect_back = {{-5/16, -0.5, 5/16, 5/16, 0.5, 0.5}},
|
||||
},
|
||||
connects_to = {"group:fence", "group:wood", "group:tree", "group:hedge"},
|
||||
light_source = def.light_source or 0,
|
||||
sounds = def.sounds,
|
||||
drop = name,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local pos_under = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||
local node_under = string.gsub(minetest.get_node(pos_under).name, "_full$", "")
|
||||
if minetest.get_item_group(node_under, "hedge") == 1 and
|
||||
digger and digger:is_player() then
|
||||
minetest.set_node(pos_under, {name = node_under})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- register crafting recipe
|
||||
@ -35,36 +92,40 @@ function hedges.register_hedge(name, def)
|
||||
end
|
||||
|
||||
|
||||
-- register hedges
|
||||
hedges.register_hedge("hedges:apple_hedge", {
|
||||
description = "Apple Hedge",
|
||||
texture = "default_leaves.png",
|
||||
material = "default:leaves",
|
||||
})
|
||||
-- register hedges if default mod found
|
||||
if minetest.get_modpath("default") then
|
||||
|
||||
hedges.register_hedge("hedges:jungle_hedge", {
|
||||
description = "Jungle Hedge",
|
||||
texture = "default_jungleleaves.png",
|
||||
material = "default:jungleleaves",
|
||||
})
|
||||
hedges.register_hedge("hedges:apple_hedge", {
|
||||
description = "Apple Hedge",
|
||||
texture = "default_leaves_simple.png",
|
||||
material = "default:leaves",
|
||||
})
|
||||
|
||||
hedges.register_hedge("hedges:pine_hedge", {
|
||||
description = "Pine Hedge",
|
||||
texture = "default_pine_needles.png",
|
||||
material = "default:pine_needles",
|
||||
})
|
||||
hedges.register_hedge("hedges:jungle_hedge", {
|
||||
description = "Jungle Hedge",
|
||||
texture = "default_jungleleaves_simple.png",
|
||||
material = "default:jungleleaves",
|
||||
})
|
||||
|
||||
hedges.register_hedge("hedges:acacia_hedge", {
|
||||
description = "Acacia Hedge",
|
||||
texture = "default_acacia_leaves.png",
|
||||
material = "default:acacia_leaves",
|
||||
})
|
||||
hedges.register_hedge("hedges:pine_hedge", {
|
||||
description = "Pine Hedge",
|
||||
texture = "default_pine_needles.png",
|
||||
material = "default:pine_needles",
|
||||
})
|
||||
|
||||
hedges.register_hedge("hedges:aspen_hedge", {
|
||||
description = "Aspen Hedge",
|
||||
texture = "default_aspen_leaves.png",
|
||||
material = "default:aspen_leaves",
|
||||
})
|
||||
hedges.register_hedge("hedges:acacia_hedge", {
|
||||
description = "Acacia Hedge",
|
||||
texture = "default_acacia_leaves_simple.png",
|
||||
material = "default:acacia_leaves",
|
||||
})
|
||||
|
||||
hedges.register_hedge("hedges:aspen_hedge", {
|
||||
description = "Aspen Hedge",
|
||||
texture = "default_aspen_leaves.png",
|
||||
material = "default:aspen_leaves",
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- alternative recipes using bush leaves
|
||||
|
Loading…
x
Reference in New Issue
Block a user