Allow speciying custom top and overhang nodes
Can be true, false, or a table with two entries (topnode, overhang). If false, the main pole extends all the way up to the specified height, and the light is simply placed next to it. if true, the main pole extends all the way up, and then steps right by 1m, with the light hanging from it. This is the default. if a table, the main pole stops 1m short of the top, and the two specified nodes are placed above it, with the overhang to the right, and the light hanging under it. also fixed the custom base node not getting _digilines extension when called-for
This commit is contained in:
parent
92eb5b9e8d
commit
fac56f263c
@ -38,9 +38,10 @@ function streetlights.check_and_place(itemstack, placer, pointed_thing, def)
|
||||
local light = def.light
|
||||
local param2 = def.param2
|
||||
local height = def.height or 5
|
||||
local has_top = (def.has_top ~= false)
|
||||
local needs_digiline_wire = def.needs_digiline_wire
|
||||
local distributor_node = def.distributor_node
|
||||
local poletop = (def.topnodes and (type(def.topnodes) == "table") and def.topnodes.poletop) or pole
|
||||
local overhang = (def.topnodes and (type(def.topnodes) == "table") and def.topnodes.overhang) or pole
|
||||
|
||||
local controls = placer:get_player_control()
|
||||
if not placer then return end
|
||||
@ -85,7 +86,7 @@ function streetlights.check_and_place(itemstack, placer, pointed_thing, def)
|
||||
def3 = minetest.registered_items[node3.name]
|
||||
if minetest.is_protected(pos3, player_name) or not (def3 and def3.buildable_to) then return end
|
||||
|
||||
if has_top then
|
||||
if def.topnodes ~= false then
|
||||
pos4 = { x = pos1.x+fdir_to_right[fdir+1][1], y = pos1.y+height-1, z = pos1.z+fdir_to_right[fdir+1][2] }
|
||||
node4 = minetest.get_node(pos4)
|
||||
def4 = minetest.registered_items[node4.name]
|
||||
@ -146,20 +147,27 @@ function streetlights.check_and_place(itemstack, placer, pointed_thing, def)
|
||||
end
|
||||
|
||||
local pole2 = pole
|
||||
|
||||
if needs_digiline_wire then
|
||||
base = base.."_digilines"
|
||||
pole2 = pole.."_digilines"
|
||||
poletop = poletop.."_digilines"
|
||||
overhang = overhang.."_digilines"
|
||||
end
|
||||
|
||||
local pos2b = {x=pos1.x, y = pos1.y+1, z=pos1.z}
|
||||
minetest.set_node(pos2b, {name = base })
|
||||
|
||||
for i = 2, height do
|
||||
for i = 2, height-1 do
|
||||
pos2 = {x=pos1.x, y = pos1.y+i, z=pos1.z}
|
||||
minetest.set_node(pos2, {name = pole2 })
|
||||
end
|
||||
|
||||
if has_top then
|
||||
minetest.set_node(pos3, { name = pole2 })
|
||||
local pos2t = {x=pos1.x, y = pos1.y+height, z=pos1.z}
|
||||
minetest.set_node(pos2t, {name = poletop })
|
||||
|
||||
if def.topnodes ~= false then
|
||||
minetest.set_node(pos3, { name = overhang })
|
||||
minetest.set_node(pos4, { name = light, param2 = param2 })
|
||||
else
|
||||
minetest.set_node(pos3, { name = light, param2 = param2 })
|
||||
|
12
simple.lua
12
simple.lua
@ -30,12 +30,12 @@ end
|
||||
local digiline_wire_node = "digilines:wire_std_00000000"
|
||||
|
||||
local poles_tab = {
|
||||
-- material name, mod name, node name, optional base, optional height, has top section
|
||||
-- material name, mod name, node name, optional base, optional height, top section
|
||||
{ "wood", "default", "default:fence_wood" },
|
||||
{ "junglewood", "default", "default:fence_junglewood" },
|
||||
{ "brass", "homedecor_fences", "homedecor:fence_brass"},
|
||||
{ "wrought_iron", "homedecor_fences", "homedecor:fence_wrought_iron" },
|
||||
{ "steel", "gloopblocks", "gloopblocks:fence_steel" }
|
||||
{ "steel", "gloopblocks", "gloopblocks:fence_steel"}
|
||||
}
|
||||
|
||||
local lights_tab = {
|
||||
@ -51,7 +51,7 @@ for _, pole in ipairs(poles_tab) do
|
||||
local matnode = pole[3]
|
||||
local basenode = pole[4]
|
||||
local height = pole[5]
|
||||
local has_top = pole[6]
|
||||
local topnodes = pole[6]
|
||||
|
||||
if minetest.get_modpath(matmod) then
|
||||
|
||||
@ -122,7 +122,7 @@ for _, pole in ipairs(poles_tab) do
|
||||
pole=matnode,
|
||||
light=lightnode,
|
||||
param2=lightparam2,
|
||||
has_top = has_top,
|
||||
topnodes = topnodes,
|
||||
height = height
|
||||
})
|
||||
end
|
||||
@ -157,7 +157,7 @@ for _, pole in ipairs(poles_tab) do
|
||||
pole=matnode,
|
||||
light=lightnode,
|
||||
param2=lightparam2,
|
||||
has_top = has_top,
|
||||
topnodes = topnodes,
|
||||
height = height,
|
||||
needs_digiline_wire=true
|
||||
})
|
||||
@ -215,7 +215,7 @@ for _, pole in ipairs(poles_tab) do
|
||||
pole=matnode,
|
||||
light=lightnode,
|
||||
param2=lightparam2,
|
||||
has_top = has_top,
|
||||
topnodes = topnodes,
|
||||
height = height,
|
||||
needs_digiline_wire=true,
|
||||
distributor_node=distributor
|
||||
|
Loading…
x
Reference in New Issue
Block a user