User Tools

Site Tools


curves

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
curves [2022/05/23 21:11] – [Get value from the curve via Lua] emozolyakcurves [2022/05/24 08:52] (current) – [Get value from the curve via Lua] emozolyak
Line 128: Line 128:
 Example of usage: Example of usage:
 <code lua - Getter> <code lua - Getter>
-include "curves.lib" +include "curves.lib" 
-SAFE_VALUE = 10+
  
 function main (userId) function main (userId)
- +    local SAFE_VALUE = 10  
-    local = os.date("*t", os.time())  +    local curHour tonumber( os.date("*t", os.time()).hour )  
-    current_hour = tonumber(t.hour+    INFO("curHour "  .. curHour
-    curve_status, y = getCurveValue( "curve_for_current_hour", current_hour +    local y, valueOutOfRange = getCurveValue("curve_for_curHour", curHour) 
-    if curve_status then +     
-        WriteReg("value_for_current_hour", y)+    if (not valueOutOfRange) then 
 +        W("value_for_curHour", y)  -- WriteReg
     else     else
-        WriteReg("value_for_current_hour", SAFE_VALUE)+        W("value_for_curHour", SAFE_VALUE)
     end     end
-         
- 
 end end
 </code> </code>
curves.txt · Last modified: 2022/05/24 08:52 by emozolyak

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki