diff --git a/depends.txt b/depends.txt index 0cd9259..92f26e0 100644 --- a/depends.txt +++ b/depends.txt @@ -9,3 +9,4 @@ streetspoles? streets_trafficlight? trafficlight? digilines? +digistuff? diff --git a/init.lua b/init.lua index ac28424..2ba43e2 100644 --- a/init.lua +++ b/init.lua @@ -4,8 +4,9 @@ local modpath = minetest.get_modpath("simple_streetlights") streetlights = {} streetlights.basic_materials = minetest.get_modpath("basic_materials") -streetlights.concrete = "basic_materials:concrete_block" -streetlights.distributor = "streets:digiline_distributor" +streetlights.concrete = "basic_materials:concrete_block" +streetlights.distributor = "streets:digiline_distributor" +streetlights.vert_digiline = "digistuff:vertical_bottom" dofile(modpath.."/simple.lua") if minetest.get_modpath("homedecor_lighting") and minetest.get_modpath("streetspoles") then diff --git a/simple.lua b/simple.lua index 95eff25..e75f6cc 100644 --- a/simple.lua +++ b/simple.lua @@ -65,7 +65,7 @@ minetest.register_privilege("streetlight", { 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() if not placer then return end 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 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 local inv = placer:get_inventory() @@ -145,12 +145,12 @@ local function check_and_place(itemstack, placer, pointed_thing, pole, light, pa end end - if needs_distributor and needs_digiline_wire then - if not inv:contains_item("main", streetlights.distributor) then - minetest.chat_send_player(playername, "*** You don't have any Digiline distributors in your inventory!") + 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", streetlights.distributor) + inv:remove_item("main", distributor_node) end end @@ -163,8 +163,8 @@ local function check_and_place(itemstack, placer, pointed_thing, pole, light, pa end - if needs_distributor and needs_digiline_wire then - minetest.set_node(pos0, { name = streetlights.distributor }) + if distributor_node and needs_digiline_wire then + minetest.set_node(pos0, { name = distributor_node }) end 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 + 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", { description = "Streetlight spawner ("..matname.." pole, with "..lightname..", digilines conducting pole, with distributor 2m below)", inventory_image = "simple_streetlights_inv_pole_"..matname..".png".. "^simple_streetlights_inv_pole_digiline_overlay.png".. - "^simple_streetlights_inv_pole_distributor_overlay.png".. + dist_overlay.. "^simple_streetlights_inv_light_source_"..lightname..".png", use_texture_alpha = true, tool_capabilities = { full_punch_interval=0.1 }, 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, on_use = ilights.digiline_on_use }) @@ -358,7 +369,7 @@ for _, pole in ipairs(poles_tab) do matnode, lightnode, digiline_wire_node, - streetlights.distributor + distributor } }) @@ -368,7 +379,7 @@ for _, pole in ipairs(poles_tab) do recipe = { "simple_streetlights:spawner_"..matname.."_"..lightname, digiline_wire_node, - streetlights.distributor + distributor } }) @@ -377,7 +388,7 @@ for _, pole in ipairs(poles_tab) do type = "shapeless", recipe = { "simple_streetlights:spawner_"..matname.."_"..lightname.."_digilines", - streetlights.distributor + distributor } }) end diff --git a/textures/simple_streetlights_inv_pole_vertical_digiline_overlay.png b/textures/simple_streetlights_inv_pole_vertical_digiline_overlay.png new file mode 100644 index 0000000..e0e2ec9 Binary files /dev/null and b/textures/simple_streetlights_inv_pole_vertical_digiline_overlay.png differ