mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-23 07:43:45 +01:00
RTC added
toggle flag changed to 2 sec
This commit is contained in:
parent
c0ac57f4b6
commit
dc31bfa24f
@ -687,3 +687,28 @@ smartline.register_condition("action", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
local function daytime()
|
||||||
|
local t = minetest.get_timeofday()
|
||||||
|
return string.format("%02d:%02d", math.floor(t*24) % 24, math.floor(t*1440) % 60)
|
||||||
|
end
|
||||||
|
|
||||||
|
smartline.register_condition("rtc", {
|
||||||
|
title = "Read RTC",
|
||||||
|
formspec = {
|
||||||
|
{
|
||||||
|
type = "label",
|
||||||
|
name = "lbl",
|
||||||
|
label = "Hint: The condition is always false.\nThe time is available as state\n(see Display actions).",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
on_execute = function(data, environ)
|
||||||
|
environ.state = daytime()
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
button_label = function(data)
|
||||||
|
return "RTC"
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
@ -265,12 +265,8 @@ local function decrement_timers(timers)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function toggle_flag(environ)
|
local function toggle_flag(meta, environ)
|
||||||
if environ.toggle == true then
|
environ.toggle = (meta:get_int("runtime") or 0) % 4 >= 2
|
||||||
environ.toggle = false
|
|
||||||
else
|
|
||||||
environ.toggle = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -564,7 +560,7 @@ local function execute(meta, number, debug)
|
|||||||
if rt_rules and environ and act_gate and conds then
|
if rt_rules and environ and act_gate and conds then
|
||||||
environ.actions = {}
|
environ.actions = {}
|
||||||
decrement_timers(environ.timers)
|
decrement_timers(environ.timers)
|
||||||
toggle_flag(environ)
|
toggle_flag(meta, environ)
|
||||||
for i,item in ipairs(rt_rules) do
|
for i,item in ipairs(rt_rules) do
|
||||||
local c1 = eval_cond(item.cond1, environ)
|
local c1 = eval_cond(item.cond1, environ)
|
||||||
local c2 = eval_cond(item.cond2, environ)
|
local c2 = eval_cond(item.cond2, environ)
|
||||||
|
Loading…
Reference in New Issue
Block a user