Compare commits

...

10 Commits

Author SHA1 Message Date
ezhh
97f2a02feb Fix API 2018-09-04 23:46:20 +01:00
ezhh
ebdee92787 Switch to simple leaves textures where available 2018-07-09 01:29:57 +01:00
ezhh
408d51b4a1 Adjust node boxes 2018-07-07 16:09:18 +01:00
ezhh
3cbaf29f74 Update readme 2018-07-07 14:35:14 +01:00
ezhh
3b4b03836d Allow top-bottom connections based on hedge group 2018-07-07 14:27:49 +01:00
ezhh
a3d9b5403e Enable connecting hedges of any height 2018-07-07 13:10:33 +01:00
ezhh
bd11b222d3 Add tall hedge nodes 2018-07-07 11:40:58 +01:00
ezhh
1264daae8f Only use default sounds if default mod is present 2018-07-07 11:25:30 +01:00
ezhh
3d3c598103 Make dependency on default optional 2018-07-07 11:10:28 +01:00
ezhh
851b5c800c Add sounds and light source to API 2018-07-07 01:12:28 +01:00
3 changed files with 102 additions and 39 deletions

View File

@ -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

View File

@ -1 +1 @@
default
default?

131
init.lua
View File

@ -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