RTC added

toggle flag changed to 2 sec
This commit is contained in:
Joachim Stolberg 2018-03-19 22:59:42 +01:00
parent c0ac57f4b6
commit dc31bfa24f
2 changed files with 28 additions and 7 deletions

@ -687,3 +687,28 @@ smartline.register_condition("action", {
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
local function toggle_flag(environ)
if environ.toggle == true then
environ.toggle = false
else
environ.toggle = true
end
local function toggle_flag(meta, environ)
environ.toggle = (meta:get_int("runtime") or 0) % 4 >= 2
end
@ -564,7 +560,7 @@ local function execute(meta, number, debug)
if rt_rules and environ and act_gate and conds then
environ.actions = {}
decrement_timers(environ.timers)
toggle_flag(environ)
toggle_flag(meta, environ)
for i,item in ipairs(rt_rules) do
local c1 = eval_cond(item.cond1, environ)
local c2 = eval_cond(item.cond2, environ)