summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2019-05-31 23:27:54 -0400
committerVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>2019-05-31 23:27:54 -0400
commit2b45a7d33c487758a3ef53318dd779462b414495 (patch)
treeae1567bb71a7cb9d3d501d1d24c6da2194dd06df
parentf8d4270e3ce0923360fcb7b3c41fb0d4291c9777 (diff)
downloaddreambuilder_modpack-2b45a7d33c487758a3ef53318dd779462b414495.tar
dreambuilder_modpack-2b45a7d33c487758a3ef53318dd779462b414495.tar.gz
dreambuilder_modpack-2b45a7d33c487758a3ef53318dd779462b414495.tar.bz2
dreambuilder_modpack-2b45a7d33c487758a3ef53318dd779462b414495.tar.xz
dreambuilder_modpack-2b45a7d33c487758a3ef53318dd779462b414495.zip
update simple_streetlights
-rw-r--r--simple_streetlights/depends.txt1
-rw-r--r--simple_streetlights/init.lua13
-rw-r--r--simple_streetlights/simple.lua62
-rw-r--r--simple_streetlights/textures/simple_streetlights_inv_pole_vertical_digiline_overlay.pngbin0 -> 607 bytes
4 files changed, 50 insertions, 26 deletions
diff --git a/simple_streetlights/depends.txt b/simple_streetlights/depends.txt
index 0cd9259..92f26e0 100644
--- a/simple_streetlights/depends.txt
+++ b/simple_streetlights/depends.txt
@@ -9,3 +9,4 @@ streetspoles?
streets_trafficlight?
trafficlight?
digilines?
+digistuff?
diff --git a/simple_streetlights/init.lua b/simple_streetlights/init.lua
index ac28424..63ae0ca 100644
--- a/simple_streetlights/init.lua
+++ b/simple_streetlights/init.lua
@@ -4,8 +4,17 @@ 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"
+
+function streetlights.rightclick_pointed_thing(pos, placer, itemstack, pointed_thing)
+ local node = minetest.get_node_or_nil(pos)
+ if not node then return false end
+ local def = minetest.registered_nodes[node.name]
+ if not def or not def.on_rightclick then return false end
+ return def.on_rightclick(pos, node, placer, itemstack, pointed_thing) or itemstack
+end
dofile(modpath.."/simple.lua")
if minetest.get_modpath("homedecor_lighting") and minetest.get_modpath("streetspoles") then
diff --git a/simple_streetlights/simple.lua b/simple_streetlights/simple.lua
index 95eff25..84a8f71 100644
--- a/simple_streetlights/simple.lua
+++ b/simple_streetlights/simple.lua
@@ -65,14 +65,11 @@ 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()
- 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 player_name = placer:get_player_name()
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
@@ -81,14 +78,18 @@ local function check_and_place(itemstack, placer, pointed_thing, pole, light, pa
if not node1 or node1.name == "ignore" then return end
local def1 = minetest.registered_items[node1.name]
- print(dump(pos1))
- print(node1.name)
- print(dump(def1))
-
-
if (def1 and def1.buildable_to) then
pos1.y = pos1.y-1
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
@@ -117,7 +118,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 +146,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,10 +164,6 @@ 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 })
- end
-
if controls.sneak then
minetest.set_node(pos1, { name = streetlights.concrete })
end
@@ -187,6 +184,12 @@ local function check_and_place(itemstack, placer, pointed_thing, pole, light, pa
if needs_digiline_wire and ilights.player_channels[playername] then
minetest.get_meta(pos4):set_string("channel", ilights.player_channels[playername])
end
+
+ if distributor_node and needs_digiline_wire then
+ minetest.set_node(pos0, { name = distributor_node })
+ digilines.update_autoconnect(pos0)
+ end
+
end
local poles_tab = {
@@ -331,17 +334,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 +372,7 @@ for _, pole in ipairs(poles_tab) do
matnode,
lightnode,
digiline_wire_node,
- streetlights.distributor
+ distributor
}
})
@@ -368,7 +382,7 @@ for _, pole in ipairs(poles_tab) do
recipe = {
"simple_streetlights:spawner_"..matname.."_"..lightname,
digiline_wire_node,
- streetlights.distributor
+ distributor
}
})
@@ -377,7 +391,7 @@ for _, pole in ipairs(poles_tab) do
type = "shapeless",
recipe = {
"simple_streetlights:spawner_"..matname.."_"..lightname.."_digilines",
- streetlights.distributor
+ distributor
}
})
end
diff --git a/simple_streetlights/textures/simple_streetlights_inv_pole_vertical_digiline_overlay.png b/simple_streetlights/textures/simple_streetlights_inv_pole_vertical_digiline_overlay.png
new file mode 100644
index 0000000..e0e2ec9
--- /dev/null
+++ b/simple_streetlights/textures/simple_streetlights_inv_pole_vertical_digiline_overlay.png
Binary files differ