TrackLang: Making a Simple Loop (Hello World)
Your first TrackLang tutorial! Build a simple oval loop track from scratch. This is the "Hello World" of track development—a complete, working circuit you can create in minutes and test immediately. By the end, you'll understand TrackLang basics and have a foundation for building complex tracks.
What We'll Build
A simple oval track with:
- Start/finish line
- Two straightaways (100 meters each)
- Two 180° turns connecting the straights
- Total length: ~500 meters
Goal: Learn TrackLang syntax by building something simple that actually works. You'll see your track in 3D as you code!
Step 1: Open Track Developer
- Create a new track or open an existing one
- Click "Edit Track" → "Track Developer"
- You'll see a code editor on the left and empty 3D view on the right
Step 2: Declare the Track
Every TrackLang file starts with a track declaration. Type this into the editor:
track simple_loop {
name = "My First Loop"
width = 12
circuit = true
}What this means:
track simple_loop- Creates a track with key "simple_loop" (used in feature locations)name = "My First Loop"- Display name shown to userswidth = 12- Track is 12 meters wide (typical motocross track)circuit = true- This is a closed loop (not point-to-point)
✅ Click "Run" to test. You should see no errors in the console.
Step 3: Add the Finish Line
Every track needs a finish line. This marks the start/finish location. Add this inside the track braces:
track simple_loop {
name = "My First Loop"
width = 12
circuit = true
}
# Finish line at the very start (0 meters)
feature simple_loop@0 finish start {
name = "Start/Finish"
}What this means:
feature simple_loop@0- Feature on "simple_loop" track at position 0 metersfinish- This is a finish line feature typestart- Feature key (unique identifier)name = "Start/Finish"- Display name
✅ Click "Run" again. You should see a small marker in the 3D view at the track start!
Step 4: Add First Turn
Let's add a 180° right turn 100 meters from the start:
# First 180-degree turn at 100 meters
feature simple_loop@100 right_turn turn1 {
name = "Turn 1"
radius = 20
angle = 180
entry {
width = 12
centerHeight = 0
}
apex {
width = 10 # Narrow at apex
}
exit {
width = 12
}
}What this means:
simple_loop@100- Turn starts 100m from track startright_turn- This is a right-hand turnturn1- Feature keyradius = 20- Turn has 20m radiusangle = 180- 180° turn (complete U-turn)entry/apex/exit- Define how track transitions through the turn- Width narrows to 10m at apex (tight turn), widens back to 12m at exit
✅ Click "Run". You should see a curved section appear in 3D!
Step 5: Add Second Turn (Complete the Loop)
Now add a second 180° turn 100 meters after the first turn ends. This completes the oval:
# Second 180-degree turn, 100m after turn1 ends
feature simple_loop@turn1+100 right_turn turn2 {
name = "Turn 2"
radius = 20
angle = 180
entry {
width = 12
centerHeight = 0
}
apex {
width = 10
}
exit {
width = 12
}
}Notice the relative positioning:
@turn1+100- Position this turn 100m after turn1 ends- This is relative positioning—much easier to adjust than absolute positions!
- If you change turn1's radius (which affects its length), turn2 automatically adjusts
✅ Click "Run". You should now see a complete oval loop in 3D!
Complete Code
Here's the full TrackLang code for your first loop:
track simple_loop {
name = "My First Loop"
width = 12
circuit = true
}
# Finish line at the very start
feature simple_loop@0 finish start {
name = "Start/Finish"
}
# First 180-degree turn at 100 meters
feature simple_loop@100 right_turn turn1 {
name = "Turn 1"
radius = 20
angle = 180
entry {
width = 12
centerHeight = 0
}
apex {
width = 10
}
exit {
width = 12
}
}
# Second 180-degree turn, 100m after turn1
feature simple_loop@turn1+100 right_turn turn2 {
name = "Turn 2"
radius = 20
angle = 180
entry {
width = 12
centerHeight = 0
}
apex {
width = 10
}
exit {
width = 12
}
}Step 6: Test Your Track
You've built a working track! Now test it:
- Click "Run" one more time to ensure no errors
- Rotate the 3D view - Click and drag to see your track from different angles
- Check the console - Should show "Distance Covered: ~440m" (two 100m straights + two turns)
- Save a version - Click "Save New Version" to preserve your work
- Run an ad-hoc race - Test with automated timing to verify the track works in real life!
Understanding What You Built
Track Layout
0m: Start/Finish → 100m straight → Turn 1 (180°, ~63m) → 100m straight → Turn 2 (180°, ~63m) → back to start
Turn Length Calculation
Turn length is automatically calculated: radius × 2 × π × (angle/360)
For 180° turns at 20m radius: 20 × 2 × 3.14159 × 0.5 ≈ 63m
Total Track Length
200m (straights) + 126m (turns) = 326m measured at centerline
Actual track length ~440m including entry/exit transitions
Experiment: Make It Your Own
Now that you have a working track, try modifying it:
Change Track Size
- Try
@200instead of@100for longer straights - Change
radius = 30for wider turns - Adjust
width = 15for a wider track
Add Elevation
- Set
centerHeight = 5in turn1's apex for a banked turn - Try
centerHeight = -2for a dip
Make It Asymmetric
- Use
@turn1+150for a longer second straight - Try
angle = 120andangle = 240for different turn sizes - Mix
left_turnandright_turnfor a figure-8
Add a Jump
- Add
feature simple_loop@50 jump table_top { ... } - Set entry/apex/exit heights for a jump in the first straight
Tip: After each change, click "Run" to see the update in 3D. If you make a mistake, just undo (Ctrl+Z) and try again!
Common Mistakes
Forgetting Closing Braces
Every { needs a matching }. Check that track, features, and subsections all close properly.
Wrong Track Key in Locators
If you named your track simple_loop, use simple_loop@100, not track@100 or mx@100.
Missing Properties
Turns need radius and angle. If missing, defaults are used which might not look right.
Overlapping Features
If features overlap (e.g., @100 and @95), you'll get warnings. Use relative positioning to avoid this.
Next Steps
Congratulations! You've built your first TrackLang track. Here's what to learn next:
- Add complexity: Try adding jumps, slopes, and more turns to your loop
- Study the reference: Read the TrackLang Reference to learn all features and properties
- Use templates: Explore pre-built templates for common track styles
- Test with automated timing: Run an ad-hoc race to validate your track works with real timing data
- Version control: Save multiple versions as you experiment with different layouts
- Go public: Make your track public for others to use and fork!
Quick Reference
Essential TrackLang Patterns
# Track declaration (required)
track <name> { ... }
# Finish line (required)
feature <track>@0 finish start { ... }
# Turn
feature <track>@<location> right_turn <key> {
radius = <number>
angle = <number>
}
# Jump
feature <track>@<location> jump <key> {
entry { centerHeight = 0 }
apex { entryCenterHeight = 3, exitCenterHeight = 0 }
exit { centerHeight = 0 }
}
# Slope
feature <track>@<location> slope <key> {
entry { centerHeight = 0 }
apex { centerHeight = 10 }
exit { centerHeight = 10 }
}Related Topics
- TrackLang: Getting Started - Introduction and Track Developer basics
- TrackLang: Language Reference - Complete syntax documentation
- Running Ad-Hoc Races - Testing your track with automated timing
Was this information useful?
Help us improve our documentation by rating this article and sharing your feedback.