Compare commits

...

5 Commits

Author SHA1 Message Date
Vanessa Dannenberg d30fa509c8 make MineDOT streetlights use the new code
(sorry, cheapie :) )
2021-06-29 13:33:16 -04:00
Vanessa Dannenberg ff5ccba41f extend the generic streetlight code to place schematics
add another type of lamp using that feature
this one is good for parking lots or common areas,
comes in 1-, 2-, and 4-lamp versions,
with either a thin or thick base node.
2021-06-28 23:19:10 -04:00
Vanessa Dannenberg ebf30c2410 refactor the whole check-and-place function
also fix a derp where I left some test nodes
in place in the brass street light :-)
2021-06-28 18:53:10 -04:00
Vanessa Dannenberg 7ef6bd4b9a fixup survival-mode item quantity checks 2021-06-28 00:19:15 -04:00
Vanessa Dannenberg 64d992eec1 add a "modern"-style light
morelights_modern wall lamp on streets thin post

plus some rotation helper options to make it work
(should be generic enough to work for other designs as well)
2021-06-28 00:19:00 -04:00
23 changed files with 438 additions and 216 deletions

View File

@ -5,6 +5,23 @@ local fdir_to_right = {
{ 0, 1 }
}
local fdir_to_back = {
{ 0, -1 },
{ -1, 0 },
{ 0, 1 },
{ 1, 0 }
}
-- rotate around Y in order by fdir(+1)
-- x+xo, x+zo, z+xo, z+zo, CW degrees
local rot_y = {
{ 1, 0, 0, 1, 0 }, -- N
{ 0, 1, -1, 0, 90 }, -- E
{ -1, 0, 0, -1, 180 }, -- S
{ 0, -1, 1, 0, 270 }, -- W
}
--digilines compatibility
local rules_alldir = {
@ -31,155 +48,341 @@ function streetlights.rightclick_pointed_thing(pos, placer, itemstack, pointed_t
return def.on_rightclick(pos, node, placer, itemstack, pointed_thing) or itemstack
end
function streetlights.check_and_place(itemstack, placer, pointed_thing, def)
local function rotate_offset_around_y(origin, offs, fdir)
local ox = offs.x
local oz = offs.z
local rx = rot_y[fdir+1][1] * ox + rot_y[fdir+1][2] * oz
local rz = rot_y[fdir+1][3] * ox + rot_y[fdir+1][4] * oz
return {x = origin.x + rx, y = origin.y, z = origin.z + rz}
end
local pole = def.pole
local base = def.base or def.pole
local light = def.light
local param2 = def.param2
local height = def.height or 5
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
local playername = placer:get_player_name()
local function can_build(target_pos, fdir, model_def, player_name, controls)
local player_name = placer:get_player_name()
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
if model_def.protection_box then
local pos1 = minetest.get_pointed_thing_position(pointed_thing)
local node1 = minetest.get_node(pos1)
if not node1 or node1.name == "ignore" then return end
local def1 = minetest.registered_items[node1.name]
local base_pos = {x=target_pos.x, y=target_pos.y+1, z=target_pos.z}
if (def1 and def1.buildable_to) then
pos1.y = pos1.y-1
local r1 = rotate_offset_around_y(base_pos, model_def.protection_box.omin, fdir)
local r2 = rotate_offset_around_y(base_pos, model_def.protection_box.omax, fdir)
local minp = {x=r1.x, y=r1.y + model_def.protection_box.omin.y, z=r1.z}
local maxp = {x=r2.x, y=r2.y + model_def.protection_box.omax.y, z=r2.z}
return not minetest.is_area_protected(minp, maxp, player_name, 1)
else
local main_node, node3, node4
local main_def, def3, def4
local main_pos, pos3, pos4
for i = 1, model_def.height do
main_pos = { x=target_pos.x, y = target_pos.y+i, z=target_pos.z }
main_node = minetest.get_node(main_pos)
main_def = minetest.registered_items[main_node.name]
if minetest.is_protected(main_pos, player_name) or not (main_def and main_def.buildable_to) then return end
end
pos3 = {
x = target_pos.x+fdir_to_right[fdir+1][1],
y = target_pos.y+model_def.height,
z = target_pos.z+fdir_to_right[fdir+1][2]
}
node3 = minetest.get_node(pos3)
def3 = minetest.registered_items[node3.name]
if minetest.is_protected(pos3, player_name) or not (def3 and def3.buildable_to) then return end
if model_def.topnodes ~= false then
pos4 = {
x = target_pos.x+fdir_to_right[fdir+1][1],
y = target_pos.y+model_def.height-1,
z = target_pos.z+fdir_to_right[fdir+1][2]
}
node4 = minetest.get_node(pos4)
def4 = minetest.registered_items[node4.name]
if minetest.is_protected(pos4, player_name) or not (def4 and def4.buildable_to) then return end
end
local dist_pos = { x = target_pos.x, y = target_pos.y-1, z = target_pos.z }
if controls.sneak and minetest.is_protected(target_pos, player_name) then return end
if model_def.distributor_node and minetest.is_protected(dist_pos, player_name) then return end
return true
end
end
local rc = streetlights.rightclick_pointed_thing(pos1, placer, itemstack, pointed_thing)
if rc then return rc end
if not minetest.check_player_privs(placer, "streetlight") then
minetest.chat_send_player(playername, "*** You don't have permission to use a streetlight spawner.")
return
end
local node1 = minetest.get_node(pos1)
local node2, node3, node4
local def1 = minetest.registered_items[node1.name]
local def2, def3, def4
local pos2, pos3, pos4
for i = 1, height do
pos2 = { x=pos1.x, y = pos1.y+i, z=pos1.z }
node2 = minetest.get_node(pos2)
def2 = minetest.registered_items[node2.name]
if minetest.is_protected(pos2, player_name) or not (def2 and def2.buildable_to) then return end
end
pos3 = { x = pos1.x+fdir_to_right[fdir+1][1], y = pos1.y+height, z = pos1.z+fdir_to_right[fdir+1][2] }
node3 = minetest.get_node(pos3)
def3 = minetest.registered_items[node3.name]
if minetest.is_protected(pos3, player_name) or not (def3 and def3.buildable_to) then return end
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]
if minetest.is_protected(pos4, player_name) or not (def4 and def4.buildable_to) then return end
end
local pos0 = { x = pos1.x, y = pos1.y-1, z = pos1.z }
if controls.sneak and minetest.is_protected(pos1, player_name) then return end
if distributor_node and minetest.is_protected(pos0, player_name) then return end
if not creative.is_enabled_for(player_name) then
local inv = placer:get_inventory()
if not inv:contains_item("main", pole.." 6") then
minetest.chat_send_player(playername, "*** You don't have enough "..pole.." in your inventory!")
local function deduct_materials_schematic(model_def, inv, player_name, controls)
for _,mat in ipairs(model_def.materials) do
if not inv:contains_item("main", mat) then
local matname = string.sub(mat, 1, string.find(mat, " "))
minetest.chat_send_player(player_name, "*** You don't have enough "..matname.." in your inventory!")
return
end
if not inv:contains_item("main", light) then
minetest.chat_send_player(playername, "*** You don't have any "..light.." in your inventory!")
return
end
if needs_digiline_wire and not inv:contains_item("main", digiline_wire_node.." 6") then
minetest.chat_send_player(playername, "*** You don't have enough Digiline wires in your inventory!")
return
end
if controls.sneak then
if not inv:contains_item("main", streetlights.concrete) then
minetest.chat_send_player(playername, "*** You don't have any concrete in your inventory!")
return
else
inv:remove_item("main", streetlights.concrete)
end
end
if distributor_node and needs_digiline_wire then
if not inv:contains_item("main", distributor_node) then
minetest.chat_send_player(playername, "*** You don't have any "..distributor_node.." in your inventory!")
return
else
inv:remove_item("main", distributor_node)
end
end
inv:remove_item("main", pole.." 6")
inv:remove_item("main", light)
if needs_digiline_wire then
inv:remove_item("main", digiline_wire_node.." 6")
end
end
if controls.sneak then
minetest.set_node(pos1, { name = streetlights.concrete })
if not inv:contains_item("main", streetlights.concrete) then
minetest.chat_send_player(player_name, "*** You don't have any concrete in your inventory!")
return
else
inv:remove_item("main", streetlights.concrete)
end
end
local pole2 = pole
if needs_digiline_wire then
base = base.."_digilines"
pole2 = pole.."_digilines"
poletop = poletop.."_digilines"
overhang = overhang.."_digilines"
for _,mat in ipairs(model_def.materials) do
inv:remove_item("main", mat)
end
local pos2b = {x=pos1.x, y = pos1.y+1, z=pos1.z}
minetest.set_node(pos2b, {name = base })
end
for i = 2, height-1 do
pos2 = {x=pos1.x, y = pos1.y+i, z=pos1.z}
minetest.set_node(pos2, {name = pole2 })
local function deduct_materials_non_schematic(model_def, inv, player_name, controls)
-- if main_extends_base, then the base node is one of two pieces
-- and the upper piece is not usually directly available to the player,
-- as with streets:pole_[top|bottom] (the thin one)
--
-- if it's that sort of thing, there could be some waste here when the player digs a pole,
-- if you use an odd number for the pole height along with main_extends_base
local num_main = model_def.height + 1
if model_def.poletop ~= model_def.pole and not model_def.main_extends_base then
num_main = num_main - 1
if not inv:contains_item("main", model_def.poletop) then
minetest.chat_send_player(player_name, "*** You don't have any "..model_def.poletop.." in your inventory!")
return
end
end
local pos2t = {x=pos1.x, y = pos1.y+height, z=pos1.z}
minetest.set_node(pos2t, {name = poletop })
if model_def.overhang ~= model_def.pole and not model_def.main_extends_base then
num_main = num_main - 1
if not inv:contains_item("main", model_def.overhang) then
minetest.chat_send_player(player_name, "*** You don't have any "..model_def.overhang.." in your inventory!")
return
end
end
if def.topnodes ~= false then
minetest.set_node(pos3, { name = overhang })
minetest.set_node(pos4, { name = light, param2 = param2 })
if model_def.base ~= model_def.pole then
num_main = num_main - 1
if model_def.main_extends_base then
if not inv:contains_item("main", model_def.base.." "..math.floor(num_main/2)) then
minetest.chat_send_player(player_name, "*** You don't have enough "..model_def.base.." in your inventory!")
return
end
else
if not inv:contains_item("main", model_def.base) then
minetest.chat_send_player(player_name, "*** You don't have any "..model_def.base.." in your inventory!")
return
end
if not inv:contains_item("main", model_def.pole.." "..num_main) then
minetest.chat_send_player(player_name, "*** You don't have enough "..model_def.pole.." in your inventory!")
return
end
end
else
minetest.set_node(pos3, { name = light, param2 = param2 })
if not inv:contains_item("main", model_def.pole.." "..num_main) then
minetest.chat_send_player(player_name, "*** You don't have enough "..model_def.pole.." in your inventory!")
return
end
end
if needs_digiline_wire and ilights.player_channels[playername] then
minetest.get_meta(pos4):set_string("channel", ilights.player_channels[playername])
if not inv:contains_item("main", model_def.light) then
minetest.chat_send_player(player_name, "*** You don't have any "..model_def.light.." in your inventory!")
return
end
if distributor_node and needs_digiline_wire then
minetest.set_node(pos0, { name = distributor_node })
digilines.update_autoconnect(pos0)
if model_def.needs_digiline_wire and not inv:contains_item("main", model_def.digiline_wire_node.." "..model_def.height + (model_def.has_top and 1 or 0)) then
minetest.chat_send_player(player_name, "*** You don't have enough Digiline wires in your inventory!")
return
end
if model_def.distributor_node and model_def.needs_digiline_wire then
if not inv:contains_item("main", model_def.distributor_node) then
minetest.chat_send_player(player_name, "*** You don't have any "..model_def.distributor_node.." in your inventory!")
return
else
inv:remove_item("main", model_def.distributor_node)
end
end
if controls.sneak then
if not inv:contains_item("main", streetlights.concrete) then
minetest.chat_send_player(player_name, "*** You don't have any concrete in your inventory!")
return
else
inv:remove_item("main", streetlights.concrete)
end
end
-- if we made it this far, then the player has everything needed
-- so deduct as appropriate
if model_def.poletop ~= model_def.pole and not model_def.main_extends_base then
inv:remove_item("main", model_def.poletop)
end
if model_def.overhang ~= pole and not model_def.main_extends_base then
inv:remove_item("main", model_def.overhang)
end
if model_def.base ~= model_def.pole then
if model_def.main_extends_base then
inv:remove_item("main", model_def.base.." "..math.floor(num_main/2))
end
else
inv:remove_item("main", model_def.pole.." "..num_main)
end
inv:remove_item("main", model_def.light)
if model_def.needs_digiline_wire then
inv:remove_item("main", model_def.digiline_wire_node.." "..num_main)
end
if model_def.distributor_node and model_def.needs_digiline_wire then
inv:remove_item("main", model_def.distributor_node)
end
if controls.sneak then
inv:remove_item("main", streetlights.concrete)
end
end
local function build_streetlight(target_pos, target_node, target_dir, fdir, model_def, controls)
if controls.sneak then
minetest.set_node(target_pos, { name = streetlights.concrete })
end
if model_def.needs_digiline_wire then
model_def.base = model_def.base.."_digilines"
model_def.pole = model_def.pole.."_digilines"
model_def.poletop = model_def.poletop.."_digilines"
model_def.overhang = model_def.overhang.."_digilines"
end
local target_fdir
if model_def.copy_pole_fdir == true then
if model_def.node_rotation then
target_fdir = minetest.dir_to_facedir(vector.rotate(target_dir, {x=0, y=model_def.node_rotation, z=0}))
else
target_fdir = fdir
end
if model_def.light_fdir == "auto" then -- the light should use the same fdir as the pole
model_def.light_fdir = target_fdir
end
end
local base_pos = {x=target_pos.x, y = target_pos.y+1, z=target_pos.z}
minetest.set_node(base_pos, {name = model_def.base, param2 = target_fdir })
for i = 2, model_def.height - 1 do
local main_pos = {x=target_pos.x, y = target_pos.y+i, z=target_pos.z}
minetest.set_node(main_pos, {name = model_def.pole, param2 = target_fdir })
end
local top_pos = {x=target_pos.x, y = target_pos.y+model_def.height, z=target_pos.z}
minetest.set_node(top_pos, {name = model_def.poletop, param2 = target_fdir })
local pos2, pos3, pos4
pos3 = {
x = target_pos.x+fdir_to_right[fdir+1][1],
y = target_pos.y+model_def.height,
z = target_pos.z+fdir_to_right[fdir+1][2]
}
if model_def.topnodes ~= false then
pos4 = {
x = target_pos.x+fdir_to_right[fdir+1][1],
y = target_pos.y+model_def.height-1,
z = target_pos.z+fdir_to_right[fdir+1][2]
}
minetest.set_node(pos3, { name = model_def.overhang })
minetest.set_node(pos4, { name = model_def.light, param2 = model_def.light_fdir })
else
minetest.set_node(pos3, { name = model_def.light, param2 = model_def.light_fdir })
end
if model_def.needs_digiline_wire and ilights.player_channels[player_name] then
minetest.get_meta(pos4):set_string("channel", ilights.player_channels[player_name])
end
if model_def.distributor_node and model_def.needs_digiline_wire then
local dist_pos = { x = target_pos.x, y = target_pos.y-1, z = target_pos.z }
minetest.set_node(dist_pos, { name = model_def.distributor_node })
digilines.update_autoconnect(dist_pos)
end
end
function streetlights.check_and_place(itemstack, placer, pointed_thing, model_def)
if not placer then return end
model_def.base = model_def.base or model_def.pole
model_def.light = model_def.light
model_def.height = model_def.height or 5
model_def.needs_digiline_wire = model_def.needs_digiline_wire
model_def.distributor_node = model_def.distributor_node
model_def.poletop = (model_def.topnodes and (type(model_def.topnodes) == "table") and model_def.topnodes.poletop) or model_def.pole
model_def.overhang = (model_def.topnodes and (type(model_def.topnodes) == "table") and model_def.topnodes.overhang) or model_def.pole
model_def.copy_pole_fdir = model_def.copy_pole_fdir
model_def.light_fdir = model_def.light_fdir
local controls = placer:get_player_control()
local player_name = placer:get_player_name()
local placer_pos = placer:get_pos() -- this bit borrowed from builtin/game/item.lua
local target_dir = vector.subtract(pointed_thing.above, placer_pos)
local fdir = minetest.dir_to_facedir(target_dir)
local target_pos = minetest.get_pointed_thing_position(pointed_thing)
local target_node = minetest.get_node(target_pos)
if not target_node or target_node.name == "ignore" then return end
local target_def = minetest.registered_items[target_node.name]
if (target_def and target_def.buildable_to) then
target_pos.y = target_pos.y-1
end
local rc = streetlights.rightclick_pointed_thing(target_pos, placer, itemstack, pointed_thing)
if rc then return rc end
if not minetest.check_player_privs(placer, "streetlight") then
minetest.chat_send_player(player_name, "*** You don't have permission to use a streetlight spawner.")
return
end
if not can_build(target_pos, fdir, model_def, player_name, controls) then
minetest.chat_send_player(player_name, "*** You can't build there, something's in the way or it's protected!")
return
end
if not creative.is_enabled_for(player_name) then
local inv = placer:get_inventory()
if model_def.materials then
deduct_materials_schematic(model_def, inv, player_name, controls)
else
deduct_materials_non_schematic(model_def, inv, player_name, controls)
end
end
if model_def.schematic then
local base_pos = {x=target_pos.x, y=target_pos.y+1, z=target_pos.z}
-- local offs = {
-- x = model_def.placement_offsets.x,
-- z = model_def.placement_offsets.z
-- }
-- local place_pos = rotate_offset_around_y(base_pos, offs, fdir)
minetest.place_schematic(base_pos, model_def.schematic, rot_y[fdir+1][5], nil, false, {place_center_x=true, place_center_z=true})
else
build_streetlight(target_pos, target_node, target_dir, fdir, model_def, controls)
end
end

View File

@ -3,6 +3,7 @@
local modpath = minetest.get_modpath("simple_streetlights")
streetlights = {}
streetlights.schematics = {}
streetlights.basic_materials = minetest.get_modpath("basic_materials")
streetlights.concrete = "basic_materials:concrete_block"
streetlights.distributor = "streets:digiline_distributor"
@ -11,6 +12,11 @@ streetlights.vert_digiline = "digistuff:vertical_bottom"
dofile(modpath.."/functions.lua")
dofile(modpath.."/simple.lua")
if minetest.get_modpath("homedecor_lighting") and minetest.get_modpath("streetspoles") then
dofile(modpath.."/minedot.lua")
if minetest.get_modpath("streetspoles") then
if minetest.get_modpath("homedecor_lighting") then
dofile(modpath.."/minedot.lua")
end
if minetest.get_modpath("morelights_modern") then
dofile(modpath.."/modern.lua")
end
end

View File

@ -1,95 +1,32 @@
local schems = {
single = minetest.register_schematic(string.format("schems%sstreetlight-single.mts",DIR_DELIM)),
double = minetest.register_schematic(string.format("schems%sstreetlight-double.mts",DIR_DELIM)),
}
for k,v in pairs({1, 2}) do
-- why +6? because table entries 1-6 are set in modern.lua :-)
streetlights.schematics[k+6] =
minetest.register_schematic(string.format("schems%sstreetlight_minedot_"..v..".mts",DIR_DELIM))
local singleMaterials = {
ItemStack("streets:bigpole 6"),
ItemStack("streets:bigpole_edge 2"),
ItemStack("homedecor:glowlight_quarter 1"),
}
local s = (v == 1) and "" or "s"
local doubleMaterials = {
ItemStack("streets:bigpole 7"),
ItemStack("streets:bigpole_edge 2"),
ItemStack("streets:bigpole_tjunction 1"),
ItemStack("homedecor:glowlight_quarter 2"),
}
local offsets = {
single = {
[0] = {x = 0,y = 0,z = 0},
[90] = {x = 0,y = 0,z = 0},
[180] = {x = 0,y = 0,z = -2},
[270] = {x = -2,y = 0,z = 0},
},
double = {
[0] = {x = 0,y = 0,z = -2},
[90] = {x = -2,y = 0,z = 0},
[180] = {x = 0,y = 0,z = -2},
[270] = {x = -2,y = 0,z = 0},
},
}
local function takeMaterials(player, sneak, materials)
local name = player:get_player_name()
if creative and creative.is_enabled_for(name) then return true end
local inv = minetest.get_inventory({type = "player",name = name})
local hasMaterials = true
for _,i in ipairs(materials) do
if not inv:contains_item("main",i) then hasMaterials = false end
end
if sneak and streetlights.basic_materials and not inv:contains_item("main", streetlights.concrete) then
hasMaterials = false
end
if hasMaterials then
for _,i in ipairs(materials) do inv:remove_item("main",i) end
if sneak then
inv:remove_item("main", streetlights.concrete)
minetest.register_tool("simple_streetlights:spawner_minedot_"..v, {
description = "Streetlight spawner (MineDOT-stylw, with "..v.." lamp"..s..")",
inventory_image = "simple_streetlights_inv_minedot_"..v..".png",
use_texture_alpha = true,
tool_capabilities = { full_punch_interval=0.1 },
on_place = function(itemstack, placer, pointed_thing)
streetlights.check_and_place(itemstack, placer, pointed_thing, {
schematic = streetlights.schematics[k+6],
materials = {
"streets:bigpole "..(v+5),
"streets:bigpole_edge 2",
"homedecor:glowlight_quarter "..v,
(v == 2) and "streets:bigpole_tjunction 1"
},
protection_box = {
omin = {x = (-2*v + 2), y = 0, z = 0},
omax = {x = 2, y = 5, z = 0},
}
})
end
return true
else
minetest.chat_send_player(name,"You don't have the necessary materials to do that!")
return false
end
})
end
local function place(itemstack,player,pointed)
if not player then return end
local sneak = player:get_player_control().sneak
local name = player:get_player_name()
if not minetest.check_player_privs(name,{streetlight = true}) then
minetest.chat_send_player(name,"*** You don't have permission to use a streetlight spawner.")
return
end
local pos = pointed.above
if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass = true}) then
minetest.record_protection_violation(pos,name)
return
end
local isDouble = string.sub(itemstack:get_name(),-6,-1) == "double"
if not takeMaterials(player, sneak, isDouble and doubleMaterials or singleMaterials) then return end
local facedir = minetest.facedir_to_dir(minetest.dir_to_facedir(player:get_look_dir()))
local schemDir = 0
if facedir.x == 1 then schemDir = 180
elseif facedir.z == 1 then schemDir = 90
elseif facedir.z == -1 then schemDir = 270 end
local offset = offsets[isDouble and "double" or "single"][schemDir]
if sneak and streetlights.basic_materials then
minetest.set_node({x=pos.x, y=pos.y-1, z=pos.z}, {name = streetlights.concrete})
end
local pos = vector.add(pos,offset)
minetest.place_schematic(pos,isDouble and schems.double or schems.single,schemDir,nil,false)
end
minetest.register_tool(":minedot_streetlights:spawner_single",{
description = "MineDOT-style Street Light Spawner (single-sided)",
inventory_image = "minedot_streetlights_single.png",
on_place = place,
})
minetest.register_tool(":minedot_streetlights:spawner_double",{
description = "MineDOT-style Street Light Spawner (double-sided)",
inventory_image = "minedot_streetlights_double.png",
on_place = place,
})
minetest.register_alias("minedot_streetlights:spawner_single", "simple_streetlights:spawner_minedot_1")
minetest.register_alias("minedot_streetlights:spawner_double", "simple_streetlights:spawner_minedot_2")

76
modern.lua Normal file
View File

@ -0,0 +1,76 @@
-- streets:pole_* with morelights_modern:walllamp
minetest.register_tool("simple_streetlights:spawner_modern_walllamp", {
description = "Streetlight spawner (streets thin pole with modern wall lamp)",
inventory_image = "simple_streetlights_inv_pole_modern_walllamp.png",
use_texture_alpha = true,
tool_capabilities = { full_punch_interval=0.1 },
on_place = function(itemstack, placer, pointed_thing)
streetlights.check_and_place(itemstack, placer, pointed_thing, {
base = "streets:pole_bottom",
pole = "streets:pole_top",
light = "morelights_modern:walllamp",
topnodes = false,
height = 4,
copy_pole_fdir = true,
node_rotation = math.pi/2, -- 90° CCW
light_fdir = "auto",
main_extends_base = true
})
end
})
local homedecor_modpath = minetest.get_modpath("homedecor_fences")
for k,v in pairs({1, 2, 4}) do
streetlights.schematics[k] =
minetest.register_schematic(string.format("schems%sstreetlight_parking_lot_"..v..".mts",DIR_DELIM))
local s = (v == 1) and "" or "s"
minetest.register_tool("simple_streetlights:spawner_modern_parking_lot_"..v, {
description = "Streetlight spawner (parking lot light with "..v.." lamp"..s..")",
inventory_image = "simple_streetlights_inv_parking_lot_"..v..".png",
use_texture_alpha = true,
tool_capabilities = { full_punch_interval=0.1 },
on_place = function(itemstack, placer, pointed_thing)
streetlights.check_and_place(itemstack, placer, pointed_thing, {
schematic = streetlights.schematics[k],
materials = {
"morelights_modern:streetpost_d 4",
"morelights_modern:barlight_c "..v
},
protection_box = {
omin = {x =-1, y = 0, z =-1}, -- distances relative to the base node
omax = {x = 1, y = 3, z = 1},
}
})
end
})
streetlights.schematics[k+3] =
minetest.register_schematic(string.format("schems%sstreetlight_parking_lot_hd_fence_"..v..".mts",DIR_DELIM))
minetest.register_tool("simple_streetlights:spawner_modern_parking_lot_hd_fence_"..v, {
description = "Streetlight spawner (parking lot light with thicker base and "..v.." lamp"..s..")",
inventory_image = "simple_streetlights_inv_parking_lot_hd_fence_"..v..".png",
use_texture_alpha = true,
tool_capabilities = { full_punch_interval=0.1 },
on_place = function(itemstack, placer, pointed_thing)
streetlights.check_and_place(itemstack, placer, pointed_thing, {
schematic = streetlights.schematics[k+3],
materials = {
"morelights_modern:streetpost_d 3",
"homedecor:fence_wrought_iron",
"morelights_modern:barlight_c "..v
},
protection_box = {
omin = {x =-1, y = 0, z =-1},
omax = {x = 1, y = 3, z = 1},
}
})
end
})
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 199 B

After

Width:  |  Height:  |  Size: 199 B

View File

Before

Width:  |  Height:  |  Size: 210 B

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 882 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1006 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB