if there's no digiline distributor, fall back to vertical digilines from "digistuff" mod
(if neither mod exists, there will no option to set the distribution node)master
parent
fa2cbfdd90
commit
d31c5590fe
|
@ -9,3 +9,4 @@ streetspoles?
|
||||||
streets_trafficlight?
|
streets_trafficlight?
|
||||||
trafficlight?
|
trafficlight?
|
||||||
digilines?
|
digilines?
|
||||||
|
digistuff?
|
||||||
|
|
5
init.lua
5
init.lua
|
@ -4,8 +4,9 @@ local modpath = minetest.get_modpath("simple_streetlights")
|
||||||
|
|
||||||
streetlights = {}
|
streetlights = {}
|
||||||
streetlights.basic_materials = minetest.get_modpath("basic_materials")
|
streetlights.basic_materials = minetest.get_modpath("basic_materials")
|
||||||
streetlights.concrete = "basic_materials:concrete_block"
|
streetlights.concrete = "basic_materials:concrete_block"
|
||||||
streetlights.distributor = "streets:digiline_distributor"
|
streetlights.distributor = "streets:digiline_distributor"
|
||||||
|
streetlights.vert_digiline = "digistuff:vertical_bottom"
|
||||||
|
|
||||||
dofile(modpath.."/simple.lua")
|
dofile(modpath.."/simple.lua")
|
||||||
if minetest.get_modpath("homedecor_lighting") and minetest.get_modpath("streetspoles") then
|
if minetest.get_modpath("homedecor_lighting") and minetest.get_modpath("streetspoles") then
|
||||||
|
|
37
simple.lua
37
simple.lua
|
@ -65,7 +65,7 @@ minetest.register_privilege("streetlight", {
|
||||||
give_to_singleplayer = true
|
give_to_singleplayer = true
|
||||||
})
|
})
|
||||||
|
|
||||||
local function check_and_place(itemstack, placer, pointed_thing, pole, light, param2, needs_digiline_wire, needs_distributor)
|
local function check_and_place(itemstack, placer, pointed_thing, pole, light, param2, needs_digiline_wire, distributor_node)
|
||||||
local controls = placer:get_player_control()
|
local controls = placer:get_player_control()
|
||||||
if not placer then return end
|
if not placer then return end
|
||||||
local playername = placer:get_player_name()
|
local playername = placer:get_player_name()
|
||||||
|
@ -117,7 +117,7 @@ local function check_and_place(itemstack, placer, pointed_thing, pole, light, pa
|
||||||
if minetest.is_protected(pos4, player_name) or not (def3 and def4.buildable_to) then return end
|
if minetest.is_protected(pos4, player_name) or not (def3 and def4.buildable_to) then return end
|
||||||
|
|
||||||
if controls.sneak and minetest.is_protected(pos1, player_name) then return end
|
if controls.sneak and minetest.is_protected(pos1, player_name) then return end
|
||||||
if needs_distributor and minetest.is_protected(pos0, 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
|
if not creative.is_enabled_for(player_name) then
|
||||||
local inv = placer:get_inventory()
|
local inv = placer:get_inventory()
|
||||||
|
@ -145,12 +145,12 @@ local function check_and_place(itemstack, placer, pointed_thing, pole, light, pa
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if needs_distributor and needs_digiline_wire then
|
if distributor_node and needs_digiline_wire then
|
||||||
if not inv:contains_item("main", streetlights.distributor) then
|
if not inv:contains_item("main", distributor_node) then
|
||||||
minetest.chat_send_player(playername, "*** You don't have any Digiline distributors in your inventory!")
|
minetest.chat_send_player(playername, "*** You don't have any "..distributor_node.." in your inventory!")
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
inv:remove_item("main", streetlights.distributor)
|
inv:remove_item("main", distributor_node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -163,8 +163,8 @@ local function check_and_place(itemstack, placer, pointed_thing, pole, light, pa
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if needs_distributor and needs_digiline_wire then
|
if distributor_node and needs_digiline_wire then
|
||||||
minetest.set_node(pos0, { name = streetlights.distributor })
|
minetest.set_node(pos0, { name = distributor_node })
|
||||||
end
|
end
|
||||||
|
|
||||||
if controls.sneak then
|
if controls.sneak then
|
||||||
|
@ -331,17 +331,28 @@ for _, pole in ipairs(poles_tab) do
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local distributor = nil
|
||||||
|
local dist_overlay = nil
|
||||||
|
|
||||||
if minetest.registered_items[streetlights.distributor] then
|
if minetest.registered_items[streetlights.distributor] then
|
||||||
|
distributor = streetlights.distributor
|
||||||
|
dist_overlay = "^simple_streetlights_inv_pole_distributor_overlay.png"
|
||||||
|
elseif minetest.registered_items[streetlights.vert_digiline] then
|
||||||
|
distributor = streetlights.vert_digiline
|
||||||
|
dist_overlay = "^simple_streetlights_inv_pole_vertical_digiline_overlay.png"
|
||||||
|
end
|
||||||
|
|
||||||
|
if distributor then
|
||||||
minetest.register_tool("simple_streetlights:spawner_"..matname.."_"..lightname.."_digilines_distributor", {
|
minetest.register_tool("simple_streetlights:spawner_"..matname.."_"..lightname.."_digilines_distributor", {
|
||||||
description = "Streetlight spawner ("..matname.." pole, with "..lightname..", digilines conducting pole, with distributor 2m below)",
|
description = "Streetlight spawner ("..matname.." pole, with "..lightname..", digilines conducting pole, with distributor 2m below)",
|
||||||
inventory_image = "simple_streetlights_inv_pole_"..matname..".png"..
|
inventory_image = "simple_streetlights_inv_pole_"..matname..".png"..
|
||||||
"^simple_streetlights_inv_pole_digiline_overlay.png"..
|
"^simple_streetlights_inv_pole_digiline_overlay.png"..
|
||||||
"^simple_streetlights_inv_pole_distributor_overlay.png"..
|
dist_overlay..
|
||||||
"^simple_streetlights_inv_light_source_"..lightname..".png",
|
"^simple_streetlights_inv_light_source_"..lightname..".png",
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = true,
|
||||||
tool_capabilities = { full_punch_interval=0.1 },
|
tool_capabilities = { full_punch_interval=0.1 },
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
check_and_place(itemstack, placer, pointed_thing, matnode, lightnode, lightparam2, true, true)
|
check_and_place(itemstack, placer, pointed_thing, matnode, lightnode, lightparam2, true, distributor)
|
||||||
end,
|
end,
|
||||||
on_use = ilights.digiline_on_use
|
on_use = ilights.digiline_on_use
|
||||||
})
|
})
|
||||||
|
@ -358,7 +369,7 @@ for _, pole in ipairs(poles_tab) do
|
||||||
matnode,
|
matnode,
|
||||||
lightnode,
|
lightnode,
|
||||||
digiline_wire_node,
|
digiline_wire_node,
|
||||||
streetlights.distributor
|
distributor
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -368,7 +379,7 @@ for _, pole in ipairs(poles_tab) do
|
||||||
recipe = {
|
recipe = {
|
||||||
"simple_streetlights:spawner_"..matname.."_"..lightname,
|
"simple_streetlights:spawner_"..matname.."_"..lightname,
|
||||||
digiline_wire_node,
|
digiline_wire_node,
|
||||||
streetlights.distributor
|
distributor
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -377,7 +388,7 @@ for _, pole in ipairs(poles_tab) do
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
recipe = {
|
recipe = {
|
||||||
"simple_streetlights:spawner_"..matname.."_"..lightname.."_digilines",
|
"simple_streetlights:spawner_"..matname.."_"..lightname.."_digilines",
|
||||||
streetlights.distributor
|
distributor
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 607 B |
Loading…
Reference in New Issue