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 revision Previous revision
curves [2022/05/24 08:50]
emozolyak [Get value from the curve via Lua]
curves [2022/05/24 08:52] (current)
emozolyak [Get value from the curve via Lua]
Line 128: Line 128:
 Example of usage: Example of usage:
 <code lua - Getter> <code lua - Getter>
-include "curves.lib"+include "curves.lib" 
  
 function main (userId) function main (userId)
     local SAFE_VALUE = 10      local SAFE_VALUE = 10 
-    local current_hour = tonumber(os.date("*t", os.time())).hour  +    local curHour = tonumber( os.date("*t", os.time()).hour  
-     +    INFO("curHour "  .. curHour) 
-    local y, valueOutOfRange = getCurveValue("curve_for_current_hour", current_hour)+    local y, valueOutOfRange = getCurveValue("curve_for_curHour", curHour)
          
     if (not valueOutOfRange) then     if (not valueOutOfRange) then
-        WriteReg("value_for_current_hour", y)+        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