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
curves [2022/05/24 08:50] – [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" 
  
 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
curves.txt · Last modified: 2022/05/24 08:52 by emozolyak

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki