+1 vote
asked May 10, 2017 in Scripting by alexlustigman (150 points) | 47 views

1 Answer

+1 vote

Yes. To simplify these type of operation, RealMotion implemented the math library. (http://lua-users.org/wiki/MathLibraryTutorial) The sin and cos are included within the library.

RealMotion also include a lua script that creates the input and output pins based on a formula: Eval.lua. It's the easiest way to prototype and equation. 

  1. To open the script, add a Lua box.
  2. In the box properties, click on Open and select the Eval.lua script.
  3. Go in the Variable tab and follow the example.

A sample is also found in File New -> Samples/Content/Control And Scripting/Lua Eval Sample

Below is how an LFO can be made from the Lua Eval script.

And here is the Lua box:

<?xml version="1.0" encoding="utf-8"?>
    <Graph Path="file:///C:/Users/LouisPhil/Documents/RealMotion/LFO Lua/">
            <Box Id="Lua Script0" Type="c0ff779f-3fcf-4418-9553-7f356d9cdf65" Version="2.1.1" Id="Lua Script0">
                    <Parameter Id="Root" Type="3441d45e-e213-41fa-9307-43034e402c8f" Version="2.1.0">
                        <Parameter Id="General" Type="38a94b45-0bc2-4390-94b7-fcc3175ea874" Version="2.1.0">
                            <Parameter Id="Lua Filename" Type="e4d6ec06-3bbb-4d4e-b93e-d01c4a76d5b7" Version="2.1.0">
                                <Value Id="Value" Type="f19bf32d-8a3d-4e40-8bc2-48e7419cf8a9" Value="file://rm/install/Media/Scripts/Eval.lua" Version="2.1.0" />
                        <Parameter Id="Variables" Type="38a94b45-0bc2-4390-94b7-fcc3175ea874" Version="2.1.0">
                            <Parameter Id="Inputs" Type="ca3ce95b-27b3-4672-872d-26130f12aa32" Version="2.1.0">
                                <Value Id="Value" Type="c82b05e4-5111-4c7e-879a-41c12d20b176" Value="{'time',PIN_FLOAT},{'speedMult',PIN_FLOAT}," Version="2.1.0" />
                            <Parameter Id="Outputs" Type="ca3ce95b-27b3-4672-872d-26130f12aa32" Version="2.1.0">
                                <Value Id="Value" Type="c82b05e4-5111-4c7e-879a-41c12d20b176" Value="{'sin',PIN_FLOAT}" Version="2.1.0" />
                            <Parameter Id="Code" Type="ca3ce95b-27b3-4672-872d-26130f12aa32" Version="2.1.0">
                                <Value Id="Value" Type="c82b05e4-5111-4c7e-879a-41c12d20b176" Value="sin = math.sin(time)" Version="2.1.0" />
                    <Pin Id="time" Type="Input" />
                    <Pin Id="sin" Type="Output" />
                    <Pin Id="speedMult" Type="Input" />
        <Connections />
            <Box Id="Lua Script0" PX="-25" PY="-62.5" />
    <Project Path="file:///C:/Users/LouisPhil/Documents/RealMotion/LFO Lua/" />

answered May 10, 2017 by Louis-Philippe Bell (440 points)
edited May 10, 2017 by Maxime Bergeron
You can copy the code from Louis-Philippe's answer and paste it directly in the graph panel of RealMotion. This will add a box to your project with the correct parameters.
Before asking a question, please make sure it is not already asked by somebody else. You can also check the Wiki for the boxes documentations and user guides.