Loading myWindsock...
Ask Assistant

Here to help you get the most out of your ride.

Departure Time
Time
Temp --
Wind --
Precip --
0 3 6 9 12 15 18 21 24
Performance Settings
Saved
System
Power (W)
CdA (m²)
Physiology
Other
</> CODE
LUA


                                            
                                            
                                        
Syntax OK
Map Settings
Compare Results
Units
Data Tuning
Tailwind Headwind
--:--
--:--:--

MyWindsock Prediction

For Distance
Inc. Elevation
Inc. Weather
Performance Summary
Duration
With Weather
With Elevation
Distance Only
Speed
Min
Max
Power (W)
Max
CdA
Max
Course Summary
Distance
Elevation (m)
Ascent
Descent
Gain
Min
Max
Weather Summary
Temperature
Min
Max
Wind Speed
Min
Max
Air Density
Min
Max
Timeline
/ km
00:00:00 / 0
0 / 00:00:00

Sign In

Don’t have an account? Sign up

Lua

myWindsock Lua Simulation Script

Apply your own logic within the myWindsock simulation.

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

-- Declaring Global energy budget (persists between steps)
kj = kj or 25

-- Boost power while we still have kJ left and we're slower than the air (headwind)
if speedMs < airSpeedMs
and kj > 0 then
  boost = power * 0.2  -- 20% boost
  power = power + boost  -- apply boost

  boostKj = boost * stepS / 1000  -- convert W·s to kJ
  kj = kj - boostKj -- Deduct boost from Global energy budget
end

Example 2: overwrite simulation inputs

-- Directly set CdA and massKg
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.