-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* lua fixes: - fix lua function calling, didn't work in the last releases (regression) - add lua funcs which don't modify the stack (for converters etc) - added better lua examples
- Loading branch information
Showing
8 changed files
with
91 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
-- simple function, return the lower number of the two operands | ||
function lower(a,b) | ||
if a < b then | ||
return a | ||
else | ||
return b | ||
end | ||
end | ||
|
||
-- calculate parallel resistance. Batch function (registered with -1, | ||
-- see below). Takes a table as parameter. | ||
-- | ||
-- Formula: 1/( (1/R1) + (1/R2) + ...) | ||
function parallelresistance(list) | ||
sumres = 0 | ||
|
||
for i, value in ipairs(list) do | ||
sumres = sumres + 1 / value | ||
end | ||
|
||
return 1 / sumres | ||
end | ||
|
||
-- converter example | ||
function inch2centimeter(inches) | ||
return inches * 2.54 | ||
end | ||
|
||
function init() | ||
-- expects 2 args | ||
register("lower", 2, "lower") | ||
|
||
-- expects a list of all numbers on the stack, batch mode | ||
register("parallelresistance", -1, "parallel resistance") | ||
|
||
-- expects 1 arg, but doesn't pop() | ||
register("inch2centimeter", 0) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters