summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2019-06-01 16:50:42 -0500
committercheapie <no-email-for-you@example.com>2019-06-01 16:50:42 -0500
commitb19b5f39d8e093f3c453c083631ff123f3c41ba1 (patch)
tree98643172a1fdeadb911125747a8245b784532936
parent6e3f9d4c111bebfed6d1876a27a4980b979fb2ba (diff)
downloaddigistuff-b19b5f39d8e093f3c453c083631ff123f3c41ba1.tar
digistuff-b19b5f39d8e093f3c453c083631ff123f3c41ba1.tar.gz
digistuff-b19b5f39d8e093f3c453c083631ff123f3c41ba1.tar.bz2
digistuff-b19b5f39d8e093f3c453c083631ff123f3c41ba1.tar.xz
digistuff-b19b5f39d8e093f3c453c083631ff123f3c41ba1.zip
Add timer
-rw-r--r--README6
-rw-r--r--init.lua1
-rw-r--r--nic.lua1
-rw-r--r--textures/digistuff_timer_top.pngbin0 -> 6301 bytes
-rw-r--r--timer.lua80
5 files changed, 87 insertions, 1 deletions
diff --git a/README b/README
index 0212160..824e50c 100644
--- a/README
+++ b/README
@@ -10,7 +10,7 @@ Textures WITH "adwaita" in the file name - These are icons by the GNOME Project,
Depends:
Required: digilines (base only) and mesecons (base only)
-Only needed for craft recipes: default, mesecons_luacontroller, homedecor
+Only needed for craft recipes: default, mesecons_luacontroller, basic_materials
How to use digilines buttons:
@@ -50,6 +50,10 @@ Every second while a player is within "radius" meters of that point, a table lis
How to use the dimmable lights:
After setting the channel, send a number from 0 to 14 to set the light level.
+
+How to use the timer:
+Send a number representing a time in seconds, from 0.5 to 3600. When the time expires, the timer will send "done" back on the same channel. If the loop feature is enabled (use the commands "loop_on" and "loop_off" to set this) the timer will automatically be set for the same time again each time it expires.
+
How to use the junction box:
These are just plain digilines conductors (like digimese) but can skip over one node to another junction box or certain other nodes.
As in, [digiline][junction box][dirt][junction box][digiline] will work to transmit signals "through" the dirt.
diff --git a/init.lua b/init.lua
index dcf5e29..300a32c 100644
--- a/init.lua
+++ b/init.lua
@@ -12,6 +12,7 @@ local components = {
"piezo",
"detector",
"piston",
+ "timer",
}
for _,name in ipairs(components) do
dofile(string.format("%s%s%s.lua",minetest.get_modpath(minetest.get_current_modname()),DIR_DELIM,name))
diff --git a/nic.lua b/nic.lua
index 8760bdf..50bf105 100644
--- a/nic.lua
+++ b/nic.lua
@@ -14,6 +14,7 @@ minetest.register_node("digistuff:nic", {
"jeija_microcontroller_sides.png",
"jeija_microcontroller_sides.png"
},
+ inventory_image = "digistuff_nic_top.png",
drawtype = "nodebox",
selection_box = {
--From luacontroller
diff --git a/textures/digistuff_timer_top.png b/textures/digistuff_timer_top.png
new file mode 100644
index 0000000..63bf5c0
--- /dev/null
+++ b/textures/digistuff_timer_top.png
Binary files differ
diff --git a/timer.lua b/timer.lua
new file mode 100644
index 0000000..4755564
--- /dev/null
+++ b/timer.lua
@@ -0,0 +1,80 @@
+minetest.register_node("digistuff:timer", {
+ description = "Digilines Timer",
+ groups = {cracky=3},
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ meta:set_string("formspec","field[channel;Channel;${channel}")
+ end,
+ tiles = {
+ "digistuff_timer_top.png",
+ "jeija_microcontroller_bottom.png",
+ "jeija_microcontroller_sides.png",
+ "jeija_microcontroller_sides.png",
+ "jeija_microcontroller_sides.png",
+ "jeija_microcontroller_sides.png"
+ },
+ inventory_image = "digistuff_timer_top.png",
+ drawtype = "nodebox",
+ selection_box = {
+ --From luacontroller
+ type = "fixed",
+ fixed = { -8/16, -8/16, -8/16, 8/16, -5/16, 8/16 },
+ },
+ node_box = {
+ --From Luacontroller
+ type = "fixed",
+ fixed = {
+ {-8/16, -8/16, -8/16, 8/16, -7/16, 8/16}, -- Bottom slab
+ {-5/16, -7/16, -5/16, 5/16, -6/16, 5/16}, -- Circuit board
+ {-3/16, -6/16, -3/16, 3/16, -5/16, 3/16}, -- IC
+ }
+ },
+ paramtype = "light",
+ sunlight_propagates = true,
+ on_receive_fields = function(pos, formname, fields, sender)
+ local name = sender:get_player_name()
+ if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then
+ minetest.record_protection_violation(pos,name)
+ return
+ end
+ local meta = minetest.get_meta(pos)
+ if fields.channel then meta:set_string("channel",fields.channel) end
+ end,
+ on_timer = function(pos)
+ local meta = minetest.get_meta(pos)
+ local channel = meta:get_string("channel")
+ digiline:receptor_send(pos,digiline.rules.default,channel,"done")
+ local loop = meta:get_int("loop") > 0
+ return loop
+ end,
+ digiline =
+ {
+ receptor = {},
+ effector = {
+ action = function(pos,node,channel,msg)
+ local meta = minetest.get_meta(pos)
+ if meta:get_string("channel") ~= channel then return end
+ if msg == "loop_on" then
+ meta:set_int("loop",1)
+ elseif msg == "loop_off" then
+ meta:set_int("loop",0)
+ else
+ local time = tonumber(msg)
+ if time and time >= 0.5 and time <= 3600 then
+ local timer = minetest.get_node_timer(pos)
+ timer:start(time)
+ end
+ end
+ end
+ },
+ },
+
+})
+minetest.register_craft({
+ output = "digistuff:timer 2",
+ recipe = {
+ {"","mesecons:wire_00000000_off","default:coal_lump"},
+ {"digilines:wire_std_00000000","basic_materials:ic","mesecons:wire_00000000_off"},
+ {"","mesecons:wire_00000000_off","default:paper"},
+ }
+})