summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2018-11-02 16:42:41 -0500
committercheapie <no-email-for-you@example.com>2018-11-02 16:42:41 -0500
commit206a730e89ec7db09f4570a4cfbd26671f8b6ddc (patch)
tree030de83a49e501c72ca232a2a53fb5780a25bfe0
downloadminedot_streetlights-206a730e89ec7db09f4570a4cfbd26671f8b6ddc.tar
minedot_streetlights-206a730e89ec7db09f4570a4cfbd26671f8b6ddc.tar.gz
minedot_streetlights-206a730e89ec7db09f4570a4cfbd26671f8b6ddc.tar.bz2
minedot_streetlights-206a730e89ec7db09f4570a4cfbd26671f8b6ddc.tar.xz
minedot_streetlights-206a730e89ec7db09f4570a4cfbd26671f8b6ddc.zip
Initial commitHEADmaster
-rw-r--r--COPYING24
-rw-r--r--depends.txt2
-rw-r--r--init.lua90
-rw-r--r--schems/streetlight-double.mtsbin0 -> 159 bytes
-rw-r--r--schems/streetlight-single.mtsbin0 -> 125 bytes
-rw-r--r--textures/minedot_streetlights_double.pngbin0 -> 210 bytes
-rw-r--r--textures/minedot_streetlights_single.pngbin0 -> 199 bytes
7 files changed, 116 insertions, 0 deletions
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
diff --git a/depends.txt b/depends.txt
new file mode 100644
index 0000000..52273b7
--- /dev/null
+++ b/depends.txt
@@ -0,0 +1,2 @@
+streetspoles
+homedecor
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..a1f8f82
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,90 @@
+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)),
+}
+
+local singleMaterials = {
+ ItemStack("streets:bigpole 6"),
+ ItemStack("streets:bigpole_edge 2"),
+ ItemStack("homedecor:glowlight_quarter 1"),
+}
+
+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,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 hasMaterials then
+ for _,i in ipairs(materials) do inv:remove_item("main",i) 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 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)
+ end
+ local isDouble = string.sub(itemstack:get_name(),-6,-1) == "double"
+ if not takeMaterials(player,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]
+ 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,
+})
+
+if not minetest.get_modpath("simple_streetlights") then
+ minetest.register_privilege("streetlight",{
+ description = "Can use streetlight spawners",
+ })
+end
diff --git a/schems/streetlight-double.mts b/schems/streetlight-double.mts
new file mode 100644
index 0000000..80ba16f
--- /dev/null
+++ b/schems/streetlight-double.mts
Binary files differ
diff --git a/schems/streetlight-single.mts b/schems/streetlight-single.mts
new file mode 100644
index 0000000..73439f3
--- /dev/null
+++ b/schems/streetlight-single.mts
Binary files differ
diff --git a/textures/minedot_streetlights_double.png b/textures/minedot_streetlights_double.png
new file mode 100644
index 0000000..0a6f3fc
--- /dev/null
+++ b/textures/minedot_streetlights_double.png
Binary files differ
diff --git a/textures/minedot_streetlights_single.png b/textures/minedot_streetlights_single.png
new file mode 100644
index 0000000..be0556c
--- /dev/null
+++ b/textures/minedot_streetlights_single.png
Binary files differ