diff options
author | cheapie <no-email-for-you@example.com> | 2017-01-16 18:12:11 -0600 |
---|---|---|
committer | cheapie <no-email-for-you@example.com> | 2017-01-16 18:12:11 -0600 |
commit | fd64aeba76655bcd3680a8d408e050597d34e5b0 (patch) | |
tree | 1370a6a6977c221658728c6f31b85f339693a2da | |
download | emtraffic-fd64aeba76655bcd3680a8d408e050597d34e5b0.tar emtraffic-fd64aeba76655bcd3680a8d408e050597d34e5b0.tar.gz emtraffic-fd64aeba76655bcd3680a8d408e050597d34e5b0.tar.bz2 emtraffic-fd64aeba76655bcd3680a8d408e050597d34e5b0.tar.xz emtraffic-fd64aeba76655bcd3680a8d408e050597d34e5b0.zip |
Add content
-rw-r--r-- | LICENSE | 24 | ||||
-rw-r--r-- | README | 8 | ||||
-rw-r--r-- | depends.txt | 1 | ||||
-rw-r--r-- | init.lua | 106 | ||||
-rw-r--r-- | sounds/emtraffic_solenoid.ogg | bin | 0 -> 9868 bytes | |||
-rw-r--r-- | textures/emtraffic_front.png | bin | 0 -> 3822 bytes | |||
-rw-r--r-- | textures/emtraffic_sides.png | bin | 0 -> 3213 bytes |
7 files changed, 139 insertions, 0 deletions
@@ -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/> @@ -0,0 +1,8 @@ +Electromechanical Traffic Light Controller for Minetest +======================================================= + +Dependencies: digilines + +Crafting: No recipes provided, for now + +Use: Place it, and it'll send signals suitable for controlling streets/roads traffic lights on channels "a","b","c",and "d". diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..da1d119 --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +digilines diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..cd70486 --- /dev/null +++ b/init.lua @@ -0,0 +1,106 @@ +local polemount_nodebox = { + { -0.35, -0.45, 0.35, 0.35, 0.45, 0.85 } +} + + +minetest.register_node("emtraffic:controller", { + tiles = { + "emtraffic_sides.png", + "emtraffic_sides.png", + "emtraffic_sides.png", + "emtraffic_sides.png", + "emtraffic_sides.png", + "emtraffic_front.png", + }, + description = "Electromechanical Traffic Signal Controller", + paramtype = "light", + paramtype2 = "facedir", + drawtype = "nodebox", + groups = {dig_immediate=2}, + sounds = default.node_sound_metal_defaults(), + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("state","greena") + digiline:receptor_send(pos,digiline.rules.default,"a","RED") + digiline:receptor_send(pos,digiline.rules.default,"b","RED") + digiline:receptor_send(pos,digiline.rules.default,"c","RED") + digiline:receptor_send(pos,digiline.rules.default,"d","RED") + local timer = minetest.get_node_timer(pos) + timer:start(3) + end, + on_timer = function(pos) + minetest.sound_play("emtraffic_solenoid",{gain=0.25,max_hear_distance=8,pos=pos}) + local meta = minetest.get_meta(pos) + local timer = minetest.get_node_timer(pos) + local state = meta:get_string("state") + if state == "allreda" then + state = "greena" + minetest.after(0.5,function(pos) + digiline:receptor_send(pos,digiline.rules.default,"a","RED") + digiline:receptor_send(pos,digiline.rules.default,"b","RED") + digiline:receptor_send(pos,digiline.rules.default,"c","RED") + digiline:receptor_send(pos,digiline.rules.default,"d","RED") + timer:start(3) + end,pos) + elseif state == "yellowa" then + state = "allredb" + minetest.after(0.5,function(pos) + digiline:receptor_send(pos,digiline.rules.default,"a","YELLOW") + digiline:receptor_send(pos,digiline.rules.default,"b","RED") + digiline:receptor_send(pos,digiline.rules.default,"c","YELLOW") + digiline:receptor_send(pos,digiline.rules.default,"d","RED") + end,pos) + timer:start(3) + elseif state == "greena" then + state = "yellowa" + minetest.after(0.5,function(pos) + digiline:receptor_send(pos,digiline.rules.default,"a","GREEN") + digiline:receptor_send(pos,digiline.rules.default,"b","RED") + digiline:receptor_send(pos,digiline.rules.default,"c","GREEN") + digiline:receptor_send(pos,digiline.rules.default,"d","RED") + end,pos) + timer:start(15) + elseif state == "allredb" then + state = "greenb" + minetest.after(0.5,function(pos) + digiline:receptor_send(pos,digiline.rules.default,"a","RED") + digiline:receptor_send(pos,digiline.rules.default,"b","RED") + digiline:receptor_send(pos,digiline.rules.default,"c","RED") + digiline:receptor_send(pos,digiline.rules.default,"d","RED") + end,pos) + timer:start(3) + elseif state == "yellowb" then + state = "allreda" + minetest.after(0.5,function(pos) + digiline:receptor_send(pos,digiline.rules.default,"a","RED") + digiline:receptor_send(pos,digiline.rules.default,"b","YELLOW") + digiline:receptor_send(pos,digiline.rules.default,"c","RED") + digiline:receptor_send(pos,digiline.rules.default,"d","YELLOW") + end,pos) + timer:start(3) + elseif state == "greenb" then + state = "yellowb" + minetest.after(0.5,function(pos) + digiline:receptor_send(pos,digiline.rules.default,"a","RED") + digiline:receptor_send(pos,digiline.rules.default,"b","GREEN") + digiline:receptor_send(pos,digiline.rules.default,"c","RED") + digiline:receptor_send(pos,digiline.rules.default,"d","GREEN") + end,pos) + timer:start(10) + end + meta:set_string("state",state) + end, + node_box = { + type = "fixed", + fixed = polemount_nodebox + }, + selection_box = { + type = "fixed", + fixed = polemount_nodebox + }, + digiline = + { + receptor = {}, + effector = {}, + }, +}) diff --git a/sounds/emtraffic_solenoid.ogg b/sounds/emtraffic_solenoid.ogg Binary files differnew file mode 100644 index 0000000..f892f40 --- /dev/null +++ b/sounds/emtraffic_solenoid.ogg diff --git a/textures/emtraffic_front.png b/textures/emtraffic_front.png Binary files differnew file mode 100644 index 0000000..336984d --- /dev/null +++ b/textures/emtraffic_front.png diff --git a/textures/emtraffic_sides.png b/textures/emtraffic_sides.png Binary files differnew file mode 100644 index 0000000..49a5ef8 --- /dev/null +++ b/textures/emtraffic_sides.png |