Created
August 10, 2023 04:37
-
-
Save rgajrawala/8dfe609fb63b3fb1798351af5a498dfb to your computer and use it in GitHub Desktop.
AssettoServer Entry List Random Traffic Generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const fs = require('fs'); | |
// CONSTANTS // | |
const STARTING_ENTRY = 40; | |
const ENDING_ENTRY = 89; | |
const CARS = [ | |
['traffic_audi_a4_jp'], | |
['traffic_isuzu_flatbed'], | |
['traffic_isuzu_hauler'], | |
['traffic_isuzu_haulerb'], | |
['traffic_isuzu_tanker'], | |
['traffic_isuzu_npr'], | |
['traffic_nissan_leaf'], | |
['traffic_toyota_camry'], | |
['traffic_toyota_prius'], | |
['traffic_toyota_rav4'], | |
['traffic_volvo_v70jp'] | |
]; | |
const AC_CARS_PATH = String.raw`C:\Program Files (x86)\Steam\steamapps\common\Assetto Corsa Dedicated Server\content\cars`; | |
// END CONSTANTS // | |
// Get skins | |
const SKINS = {}; | |
for (const entryCars of CARS) { | |
for (const car of entryCars) { | |
if (SKINS[car]) continue; | |
SKINS[car] = fs.readdirSync(path.join(AC_CARS_PATH, car, 'skins')); | |
} | |
} | |
// Generate list | |
for (let entry = STARTING_ENTRY; entry <= ENDING_ENTRY; ++entry) { | |
const car = getRandomItem(CARS[(entry - STARTING_ENTRY) % CARS.length]); | |
const skin = getRandomItem(SKINS[car]); | |
console.log(`[CAR_${entry}] | |
MODEL=${car} | |
SKIN=${skin} | |
SPECTATOR_MODE=0 | |
DRIVERNAME= | |
TEAM= | |
GUID= | |
BALLAST=0 | |
RESTRICTOR=0 | |
AI=fixed | |
`); | |
} | |
function getRandomItem(list) { | |
return list[~~(Math.random() * list.length)]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment