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 feet each)
- Two 180° turns connecting the straights
- Total length: ~500 feet
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"name = "My First Loop"- Display name shown to userswidth = 12- Track is 12 feet widecircuit = true- This is a closed loop
✅ 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:
feature simple_loop@0 finish finish_line {}What this means:
feature simple_loop@0- Feature on "simple_loop" track at 0 feet (the baseline)finish- This is a finish line feature typefinish_line- A unique key for this feature
✅ Click "Run". You should see the checkered finish line appear in the 3D view at the track start!
Step 4: Add First Turn
Let's add a 180° right turn 100 feet from the start:
# First 180-degree turn at 100 meters
feature simple_loop@100 right_turn turn1 {
radius = 20
angle = 180
entry {
width = 12
height = 0
}
apex {
width = 10 # Narrow at apex
}
exit {
width = 12
}
}# First 180-degree turn at 100 feet
feature simple_loop@100 right_turn turn1 {
radius = 20
angle = 180
}What this means:
simple_loop@100- Turn starts 100ft from track startright_turn- This is a right-hand turnturn1- Feature keyradius = 20- Turn has 20ft radiusangle = 180- 180° turn (complete U-turn)
✅ 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 feet after the first turn ends. This completes the oval:
# Second 180-degree turn, 100ft after turn1 ends
feature simple_loop@turn1+100 right_turn turn2 {
radius = 20
angle = 180
}Notice the relative positioning:
@turn1+100- Position this turn 100ft 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 finish_line {}
# First 180-degree turn at 100 feet
feature simple_loop@100 right_turn turn1 {
radius = 20
angle = 180
}
# Second 180-degree turn, 100ft after turn1
feature simple_loop@turn1+100 right_turn turn2 {
radius = 20
angle = 180
}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: ~440ft" (two 100ft 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
0ft: Start/Finish → 100ft straight → Turn 1 (180°, ~63ft) → 100ft straight → Turn 2 (180°, ~63ft) → back to start
Turn Length Calculation
Turn length is automatically calculated: radius × 2 × π × (angle/360)
For 180° turns at 20ft radius: 20 × 2 × 3.14159 × 0.5 ≈ 63ft
Total Track Length
200ft (straights) + 126ft (turns) = 326ft measured at centerline
Actual track length ~440ft 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
leftHeight = 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 { length = 12 }
apex { height = 13, length = 8 } #length is optional, used for tabletops
exit { height = 2, length = 10 }
}
# Slope
feature <track>@<location> slope <key> {
entry { height = 0 }
apex { height = 10 }
exit { height = 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.