Scripting Racer

 

Home Use console commands for some trickery.


Organiser - free planning & organizing tools

Introduction

Racer supports a simple form of scripting. Commands can either be entered through the console (by pressing Ctrl-~), or are executed from a file directly (or by remote control through UDP actually).

Scripts are stored in the data/scripts/ directory. You can use 'run <script>' to run one of the scripts in that directory, i.e. 'run hello' will run the data/scripts/hello.rex file.

Standard scripts

A number of scripts are run automatically when certain events happen. These are:

Script Description
on_allfinished.rex Called when all cars have finished (when the end results will be displayed) (v086+)
onrace.rex Called at the start of a race.
oncar.rex Called on each new car entering the field.
onlap.rex Called whenever a car crosses the finish line. (v053b3+)
onreset.rex Called when pressing Shift-R
postreset.rex Called after reset has taken place (for example to place the car somewhere on the track using 'reset car 200'). (v053b5+)
onrestart.rex Called just before the car gets reset (auto-return feature). (v053b3+)

 

Commands

Here's the list of available script commands. They can be entered through the console . The future will probably see a lot of additions, since this allows live modifying of parameters. The console will pop up automatically when pressing Shift-~.

Command Description
abs on|off Turn on/off ABS (anti-lock braking system)
ai on|off Turns AI on or off for player car
ai learn on|off Turn on/off AI learn mode (similar to Ctrl-F6)
ai performance <f> Sets AI performance for currently focused car to <f> (f=0..2 where 0=no speed, 2=200%)
ai uoffset <f> Sets AI lateral offset. Test option useful while creating tracks.
analyse all Same as calling analyse for all the options (v085+.
analyse dampers Gives an overview of the damper system. This to check the damper with actual values obtained from official sources. Gives a list of force vs. velocity (i.e. F @ 0.1 m/s = 1000N).
analyse tires Does a 5 second analysis (standard deviation) of the tire load (for tire stability/implicit integration). v087+
analyse wheels Gives an analysis of the wheel & tire (v085+)
asl on|off Turn on/off ASL (active speed limiter). This limits the velocity to that of what the AI would drive, effectively being a sort of 'Braking Help' function.
automatic Switch on automatic gearbox (see also 'manual')
car hide|show Hide or show the current car
cg x <value> Sets the car's CG point. Also available are 'cg y' and 'cg z'.
clear Clear screen (just 1 frame; normally the simulation will keep on rendering)
console enable|disable Enable/disable the console. Mostly used remotely.
controls <set> Switches to another control set file.
debug <n> Select debugging info screen (n=0..9, 0=none).
distort edit Start distortion edit mode
distort save Save distortion state (in racer.ini)
echo <string> Prints a string on the console. No variables are possible yet, just the string is printed literally.
exit Simulates the ESC key
exposure <v> Camera exposure (make sure that renderer.auto_exposure.enable=0 when trying to set this manually). Try values between 0.3 and 10.
flag [!]<type>

(v0.5.4+) Enable/disable a race flag for the current car. If prefixed with a '!', the flag is removed. Possible flags:

  • disqualify - black flag
  • carproblem - car has a problem; taken back into the pits
fullscreen Switch to fullscreen
graph [step] [delta] <min> <max> <variable>

Live telemetry of a certain variable. Use step to add a sample per physics step (otherwise the graphics framerate is used) and use delta to paint the derivative (!) of the signal (so a delta graph is mostly close to 0).

Signals available:

  • car.ai_steer; the focus car's steering variable (-1..1)
  • car.pitch_acc; pitch acceleration in rad/s^2 (v088+)
  • car.roll_acc; roll acceleration in rad/s^2. (v088+)
  • car.yaw_acc; yaw acceleration in rad/s^2. (v088+)
  • wheel0.contact.y; contact patch.
  • wheel0.f_lat; lateral tire force (in Newton) (v088+)
  • wheel0.f_lon; longitudinal tire force (in Newton) (v088+)
  • wheel0.load; the load in Newtons.
  • wheel0.road_noise; the actual used vertical offset due to surface road noise.
  • wheel0.velocity.y; the wheel's velocity.
  • wheel0.contactwc.x; X coordinate of wheel contact patch in world coordinates (WC) (v053b5+)
  • wheel0.surface.x; X coordinate of surface
  • wheel0.surface.y; vertical surface height
  • wheel0.surface.z; Z coordinate of surface
  • wheel0.surface.flags; surface flags
  • wheel0.surface.distance; distance to surface
  • wheel0.surface.t; UV coordinate system
  • wheel0.surface.u; UV coordinate system (lateral from 0..1)
  • wheel0.surface.v; UV coordinate system (longitudinal from 0..1)
  • gforce_lon; the car's longitudinal acceleration (m/s^2)
  • gforce_lat; the car's lateral acceleration (m/s^2)
  • motion.rollacc; motion roll angular acceleration (radians/s^2) (only available with motion platform controllers)
  • motion.yawacc; motion yaw angular acceleration (radians/s^2)
  • motion.pitchacc; motion pitch angular acceleration (radians/s^2)
  • mz; force feedback
  • steering.pos; steering wheel position (in radians)
  • pmda0-pmda2; internal, raw data.
graph clear Clear all telemetry graphs (none visible after this).
image Displays an image (note that when the simulation is running, the image will be overdrawn by the next frame immediately unless you use wait for example).
info <text> Shows the text for a while onscreen (v0.5.5+)
ini [inifile] path value

Sets a value in an ini file. If no .ini file is specified, racer.ini is implicitly used. For example,'ini assist.abs 1' turns on ABS in racer.ini. Note this only changes the value in the ini file; the actual time that the value becomes active is dependent on what value was set.
You can specify '$' for the value, which is translated to an empty string (to clear settings). Use the '$' sign inside values to represent a space, i.e. 'ini race.ai_car_multiple car1$car2$car3'.

lights on|off Turn the current car's lights on/off (v0.8.3+)
manual Switch to manual gearbox (unless car is defined as automatic!)
motionblur method <n> Set motion blur method (0..4). Method 4 is recommended, if you have the graphics hardware to match (uses FBO's)
motionblur blur_alpha <f> Set motion blur mixing amount (0..1). 0 means no mix, 1 means full mix.
mv <cmd> Sends the command (<cmd>) through to all multiview slaves.
movieplay <movie> <bgr> <scaleX> <scaleY>

Plays a movie fullscreen (waits until the movie is finished) (v053b3+). The movie is played through a texture, the optional background image is also displayed as a textured polygon.
Scaling can be used to upscale or downscale the movie (1.0 is the normal size).

pacenotes edit|exit Enter ('edit') or end ('exit') pacenote edit mode. While editing, press L/R, 1-5 to select an image and Shift-S to set a start point end Shift-E to set an end point. Drive around to the spots of your choice.
pacenotes save Save the pacenotes (in data/tracks/<yourtrack>/pacenotes.ini)
pause Toggle pause mode
pause on|off Set pause mode directly
pmd on|off USB support (internal)
race end <n> Ends race, optionally in <n> seconds.
racestats <n> Set race statistics view: 0=none, 1=small standings at bottom, 2=time comparison at top left (often used), 3=big view, 4=session result, 5=ranking (drivers in position order), 6=front/rear car info. Some of these views are quite specific and not generally useful; view 2 is the view targeted at the internet public. (v086+)
realtime <scale> Scales realtime vs. simtime. Default is 1.0. Some problems may appear when stretching time, since some processes are based on time.
reset Reset race (as if Shift-R was pressed)
reset car [n] Resets car to the last road position (as if Shift-F was pressed). Optional parameter is the distance along the track to reset to.
run <script> Runs the script. The scripts are located in data/script. I.e. 'run test' will execute data/scripts/test.rex.
sampleplay <file> Plays a sample. Test only.
scene evaluate | explanation | lapstart Several cutscenes, unusable for the internet version.
tc on|off Traction control enable/disable
test audio Test option; starts a helicopter sounds, going through audio channels. Useful in 5.1 audio tests for example (set audio.speakermode appropriately).
time <HHMM> Set time of day (ie time 0900). This modifies some sun properties.
trackmap save Saves the live rendered environment map at the next renderer (in data/dump/track_*.tga). Only works if live environment mapping is enabled (envmap.live_track=1)
triangles on|off Turn renderer triangle painting on/off (see also 'wireframe')
safety bad Indicates to Racer that safety is somehow compromised externally. Will let all cars run on AI. Used in conjunction with UPS-es for example in professional environments.
scale car <n> Scales the player car (entirely). This means models, wheels, mass etc. Whacky option.
spline move <y> Moves the current spline (under wheel0) up or down the given offset (floating point)
show car Displays the currently selected car for the player (from racer.ini)
show track Displays the currently selected track to drive on (from racer.ini)
show|hide aero Show/hide aerodynamics. Currently only shows the drafting areas in front and rear of cars (065+)
show|hide carbbox Shows/hides the car's bounding box/model (v0.8.3+)
show|hide carpoints Shows/hides carpoints (as if racer.ini's gfx.show_car_points is modified live). Car points show suspension points, roll center, CG etc.
show|hide names Shows/hides car names floating above cars. The focus car never has its name displayed, so you need to have at least 2 cars to see the effect. (v0.7.4+).
show|hide splines Show/hide the road splines. Same as toggling racer.ini's gfx.show_spline_tris. (v0.7.3+)
spline save Saves the (modified) splines in spline.ini. Make a backup of data/tracks/<thetrack>/spline.ini before doing this.
spline squeeze <rc>

Squeeze spline. This softens splines bumps a bit. 'rc' is the maximum deviation for each Y change in the spline (vertical elevation changes). The 'rc' is defined as a ratio: distance to next spline point divided by Y change (so more Y change is allowed for points that are far apart). It's specified as a percentage; so spline squeeze 5 means that the height may change by only 5% compared to the longitudinal/lateral distance. This command attempts to be a tool to smooth out tracks with harsh spline changes.

Currently this command isn't too useful (v053b31).

start engine | stop engine Starts the engine if stalled, 2nd command stops the engine
start slaves | stop slaves Start all slave computers (slaves.slave<x>), stop all slaves
volume <n> Set master volume (0..255)
wait <n> Waits <n> milliseconds
wireframe on|off Turn renderer wireframes on/off (see also 'triangles')
wireframephys on|off Turn on/off collision wireframes (v084+)

Environmental commands:

Command Description
clouds <v> Set cloud amount (0..1). 1 takes the full cloud sky texture, 0 is a clear sky. (v074+)
extinctionfactor <v> Set atmosphere extinction factor. Normally 1, but use values >1 to increase atmosphere influence (more 'fog') (v0.8.3+)
fast_time <v> Simulates fast movement of the day time (for development purposes). Modifies sun properties to simulate the 24 hour day cycle, only very fast. Racer versions below v0.7.2 used 'fast_time on' and 'fast_time off' but this has been modified with a speedup factor. Use fast_time 600 for example as a good start.
fog density <v> Set fog exponential density (values around 0.01-0.05 are realistic). Needs exponential fog mode in track to work. (v0.7.2) Overruled by atmospheric settings (see 'fog rayleigh' and 'fog mie') so it won't work with Cg shaders (those have much better fog than the regular OpenGL fog model).
fog mie <v> Set fog Mie scattering coefficient. Normally around 0.0010 (Cg sky shaders only, v072+).
fog rayleigh <v> Set fog Rayleigh scattering coefficient. Normally around 0.0020 (Cg sky shaders only, v072+).
rain <n> Set rain intensity from 0 to 1 (v0.5.3b8+)
snow <n> Set snow intensity from 0 to 1
sundirx <x> Set sun X coordinate
sun ambient <x> Set sun (atmosphere) ambient color to <x>. Currently only 1 value is used for R, G and B (v087+)
sun diffuse <x> Set sun (atmosphere) diffuse color (the 'sun' color). Currently only 1 value. (v087+)
sun intensity <v> Set sun intensity. A good start value will be around 20. Notice this only works with Cg shaded tracks that use the Racer Cg shaders in data/renderer/shaders. For more info on Cg shaders, go here.
thunder <v> Set thunder intensity from 0..1 (v0.8.9+)

Some extra commands normally not used on locally running sessions (only used for remote control):

Command Description
control race Start a race
control exit Exit the race
ping Pings back (network only) with 'ping'. Doesn't show 'ping' on the graphical console window, just the network link (if present).

Internal development commands:

Command Description
calibrate pmda0-pmda3 Calibrate PMD channel. Stress the channel a couple of times through its minimum and maximum values, the issue 'calibrate save'. Only 1 PMD is currently supported.
calibrate save Save calibration results in racer.ini and stop calibrating.
trigger lights Used in multiplayer

Commands only available in proprietary parts are here.

 


Organiser -planning, organiser and time billing software

(last updated January 19, 2010 )