Hello, I am attempting to re-script my train route/schedule system because it’s quite un-optimised (uses lots of remote functions/remote events/bindables). But I really don’t know where to start, and no one on the developer forum has (surprisingly) asked about this.
At the moment, my system relies on a ModuleScript called RouteSchedules that has a list of routes like this:
routes['example'] = {
Stations = {
{'Station1', 5 --[[Minutes to get there]]},
{'Station2', 5},
},
Depots = {
{'Depot', 'Station2' --[[Destination]], 'Station1'--[[Next station]]},
},
-- other stuff...
}
Then in a ServerScript, I generate the route. Which is stored in a table within the script.
^ I have a problem with this because I have no idea how to detect a train despawning and then removing that train’s schedule from the table.
My issue is mainly with how I know where the train spawns so I can generate the route.
At the moment I put the depots the train can spawn at in a table within the route table, but I don’t feel that this is efficient.
And when a train skips the station, because of the way the next station system works, it assumes it stopped at the station.
Can anyone please provide some insight?