curves
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
curves [2022/01/14 13:40] – ↷ Links adapted because of a move operation emozolyak | curves [2022/05/23 21:11] – [Get value from the curve via Lua] emozolyak | ||
---|---|---|---|
Line 99: | Line 99: | ||
<code lua - curves.lib> | <code lua - curves.lib> | ||
- | function | + | --[[ |
- | --[[ | + | The function |
- | --Curve handler | + | Example of a curve, having multiple ranges of kx + b, set in a register of a String type with Json |
- | | + | [{" |
- | Put curve register as first argument and X coordinate as second. | + | --]] |
- | | + | function getCurveValue (curveReg, inputValue) |
- | Get as result status if it is inside curve range of outside(false) and the Y value as second output argument | + | |
+ | | ||
+ | local tab = cjson.decode( R(curveReg) ) | ||
+ | local outputValue, | ||
| | ||
- | | + | for _, sub_ in ipairs(tab) do |
- | curve_status, | + | if ( (sub_.range[s] <= inputValue) |
- | --]] | + | |
- | table = cjson.decode( R ( curve_register ) ) | + | |
- | -- inRangeCurve( table, x_to_find_y ) | + | |
- | | + | |
- | if ( value.range[1] <= x_to_find_y | + | |
- | | + | |
- | in_range_status, | + | |
- | return in_range_status, y | + | |
end | end | ||
end | end | ||
- | | + | -- edge cases |
- | -- in_range_status, | + | |
- | | + | |
- | | + | |
- | elseif | + | elseif |
- | | + | |
- | | + | |
- | return in_range_status, | + | |
end | end | ||
- | + | | |
- | | + | |
end | end | ||
</ | </ | ||
Line 141: | Line 135: | ||
local t = os.date(" | local t = os.date(" | ||
current_hour = tonumber(t.hour) | current_hour = tonumber(t.hour) | ||
- | curve_status, | + | curve_status, |
if curve_status then | if curve_status then | ||
WriteReg(" | WriteReg(" |
curves.txt · Last modified: 2022/05/24 08:52 by emozolyak