A very powerful tool to customise your simulation. Write your own functions to modify the inputs
into the simulation.
Example 1: simple kJ-limited boost
kj = kj
or
25
if
speedMs <
airSpeedMs
and kj >
0
then
boost =
power *
0.2
power =
power + boost
boostKj = boost *
stepS /
1000
kj = kj - boostKj
end
Example 2: overwrite simulation inputs
cda =
0.4
massKg =
95
Mutable variables (Changeable)
-
power
– rider power output (W)
-
cda
– drag area (m²)
-
massKg
– rider + bike mass (kg)
-
crr
– coefficent of rolling resistance
-
drivetrainEfficiency
– drivetrain efficiency (0 - 1)
Immutable (read-only)
-
elapsedS
–
seconds from start
-
stepS
– step
duration in seconds
-
distanceM
– total
distance in metres
-
altitudeM
–
altitude in metres
-
speedMs
– speed
in metres per second
-
airSpeedMs
– air
speed in metres per second
-
drivetrainEfficiency
– drivetrain
efficiency (0 - 1)
-
slope
– gradient
(0 - 1)
-
crr
– rolling
resistance coefficient
-
windBearing
–
wind direction in degrees
-
windSpeedMs
–
wind speed in metres per second
-
windSpeedShearedMs
– sheared wind speed in metres per second
-
temperatureC
–
temperature in degrees Celsius
-
humidity
–
relative humidity (0 - 1)
-
travelBearing
–
travel direction in degrees
-
airDensity
– air
density in kg/m³
Tips
-
Use globals for memory, e.g.
kj = kj or 25
.
-
Avoid infinite loops (like
while true do ... end
) – they are blocked.
-
Keep logic light – your script runs thousands of times per ride.