Autodrive

by Pi-C

Car equipment for train avoidance, logistic network integration, circuit network connectivity, fuel refill, ammo reload, vehicle repair, radio control, enemy targeting, and gate control.

Content
13 days ago
0.17 - 1.1
2.40K
Transportation
Owner:
Pi-C
Source:
N/A
Homepage:
https://gitlab.com/aerosuidae/autodrive
License:
MIT
Created:
4 years ago
Latest Version:
1.1.11 (13 days ago)
Factorio version:
0.17 - 1.1
Downloaded by:
2.40K users

Autodrive was originally made by dorfl, who later transferred ownership of the mod to me. When dorfl made the mod, the game was still in development (Factorio 0.17) and spidertrons didn't exist yet. So it started as a mash-up of ideas for making cars smarter by installing sensors in its equipment grid. As of version 1.1.3, vehicles based on a spider-vehicle prototype are finally supported as well.

Grids

Not all vehicles come with an equipment grid. Therefore, Autodrive will add a minimal grid with just enough slots to place one sensor of each type to vehicles without a grid. Only Autodrive's sensors can be put into this grid. Mod authors can tell Autodrive to extend their grids if they are concerned that its sensors consume too much of the available space (see below).

Sensors

  • Train sensor: Vehicles will sense a nearby moving train and brake automatically, or accelerate hard if already crossing rails. Does nothing useful if you're driving along rails!
  • Enemy sensor: Vehicles will sense and target nearby enemies within range of its guns. If the vehicle is unarmed or has run out of ammo, it will enter panic mode and accelerate when it senses enemies.
  • Fuel sensor: Vehicles will refuel from the trunk inventory. If the vehicle's equipment grid contains some burner equipment, this will be refueled as well.
  • Ammo sensor: If a vehicle weapon runs out of ammo, Autodrive will switch to the next weapon which still has ammo. When no weapon has any ammo left, Autodrive will check the vehicle trunk for usable ammo and try to reload all weapons.
  • Repair sensor: Vehicles will be automatically repaired as long as there are vanilla repair-packs or modded repair tools in the trunk. The recipe for the repair sensors requires construction bots. There are 3 tiers of this sensor. The recipes for the higher tiers require more bots, but these will work together and therefore repair the vehicle faster.
  • Gate sensor: Vehicles will be able to open gates when they have no human driver. Enables path finding through gates (see below).
  • Follow sensor: Vehicles will follow the player who activated follow mode.
  • Logistic network sensor: Vehicle will interact with the logistic network when parked. Filtered trunk slots are refilled like a requester chest, and unfiltered slots are exported like an active provider chest. Grew out of my (i.e. dorfl) old Logiquipment mod.
  • Circuit network sensor: Vehicles will interact with the circuit network via a Shortwave channel. Use the radio control to select a vehicle and a radio to associate the two. Send X and Y signals to the shortwave channel to direct the vehicle.

All sensors work when driving a vehicle manually, when a vehicle is parked, and when it's under remote control.

Trains

The train sensor is your friend... but it's not perfect. For high-traffic train areas, block off the rails with walls to force cars to path to gates. When RC driving all the way across the map, quickly scan the dashed yellow path and ensure there are no long segments where a car will be driving along rails.

The train sensor will accelerate a car very hard to get it off the rails in time to avoid a fast train, so don't stand in front of your car because it might kill you to save itself! :-)

Logistic Network

  1. Put a logistic network sensor into a car grid.
  2. Set some trunk filtered slots (middle mouse button). These will be treated like logistic request slots.
  3. Park the car inside a logistics zone with robots -- mod won't activate if a car is moving.
  4. Robots should arrive...

Note that:

  • Sensor only ticks every few seconds, so be patient! :)
  • Filtered trunk slots are used to set the request slots of a hidden requester chest.
  • Unfiltered trunk slots are considered trash and put into a hidden active provider chest.
  • If the current fuel is requested in a slot, the fuel tank will be filled up first.
  • Entering and starting the car is fine -- items still in hidden chests will be reclaimed.

Remote Control

Autodrive includes a remote-control automatic pathing tool. The RC is similar to the one in AAI Programmable Vehicles. You can run both mods in a game, but the sensors only work when AAI vehicle AI is turned off and the Autodrive remote-control is used. Sensors will not work for programmed vehicles because the tick handlers will fight for control.

Vehicle Roboports

One long-time problem with AAI and vehicle grids is losing robots and some types of grid equipment inventory contents. Autodrive is designed to solve those bugs, so for example, it's fine to kit out a Hauler with a personal roboport and a burner grid generator, and send it off to build remote mining outposts.

Pathing

Cars request paths with clearance max(width, height) x 1.6 which avoids crashes and getting stuck on other entities. Mostly. The Factorio path-finding API exposed in 0.17 sometimes returns strange paths.

Bounce Crashing

Cars bounce backward a bit after a crash which usually leaves enough clearance to re-path. You might have seen this behaviour in other RTS games. They also auto-heal themselves and the other entity a bit. :-)

Trees

A car driving with the RC will try to path between trees, bounce-crashing and removing any tree it actually hits. The Hauler can bulldoze its way, albeit very slowly, through any forest.

Circuit Network

The circuit network can be used to emulate the remote control:

  1. Build and place a circuit sensor in a car grid.
  2. Build a shortwave radio and set the channel (instructions in that mod) to something, say Car(17).
  3. Use the remote control tool to drag-select both the car and the radio at the same time. Car will bind to the chosen channel and display it as a yellow caption while selected, eg car:17.
  4. Send X and Y signals to the radio I/O port to direct the car to a map location.
  5. Car will check for a signal change once per second.

There's a Markers mod to help choose and track map coordinates. I guess these become something like waypoints, except they're just informational; you still have to explicitly send X,Y signals.

Cars report back on the same channel once per second:

  • V: current X co-ordinate
  • W: current Y co-ordinate
  • A: duration since arrival at current map location in ticks
  • B: duration since arrival at current map location in seconds (floor(A/60))
  • D: duration since departure in ticks
  • E: duration since departure in seconds (floor(D/60))

A and D are mutually exclusive.

Note that X=0, Y=0 doesn't work, due to Factorio's convention of treating 0 as no-signal.

UPS

The biggest UPS hits are:

  • Cars actively driving because it's Lua and on-tick. Having lots of vehicles is fine, just not all pathing and driving at once...
  • Cars with a logistic sensor left parked in a logistic network zone for no reason. Remove the sensor or park cars outside the yellow zone once they've finished logistics requests.

Shortwave & Autodrive Graphics fix

This mod changes the appearance of our sensors and remote control, and provides a Japanese locale. While my own graphics kind of work, my skills in this area are rather limited. Therefore, I'm glad that somebody with more talent came up with new artwork. Definitely give it a try! (I can't add a dependency to Autodrive as that would introduce a circular dependency.)

AAI Programmable Vehicles compatibility

Yes, except the RC and AI notes above. AAI stand-alone vehicles like the Hauler, Warden and Chaingunner work with both mods.

Logistic Carts compatibility

Yes, both mods can run together, but sensors don't work on carts.

DMV - Directional Movement Vehicles

Autodrive should recognize the new prototypes created by DMV. If you add DMV to an existing game, you can continue to use the cars you've already placed, but any vehicle you craft after adding DMV will be a spider-vehicle under the hood.

Gizmos Car Keys (improved) compatibility

As author of GCKI and the latest version of Autodrive, I recommend using this mod because GCKI and Autodrive complement each other: Claim a vehicle using the keys from GCKI to make it your own. If you summon it to a location near you later on, it will be there immediately. Hop in and use the Remote Control from Autodrive to drive wherever you want to.

Autodrive has no optional dependency on this mod because GCKI already depends on Autodrive (having a defined loading order saves some remote calls), and adding dependencies to both mods would result in a circular dependency error.

Krastorio 2 compatibility

Should be compatible. On request, I've added that equipment installed in a vehicle's grid will also be automatically refueled if it has a fuel sensor. This has been tested with Krastorio specifically, but should also work with equipment from other mods.

VehicleSnap compatibility

Autodrive and VehicleSnap don't seem to interfere with each other, so you can use both mods together. Autodrive does it's own pathfinding, but VehicleSnap may still be useful for the times you want to drive manually.

Vehicle Wagon 2 compatibility

If a vehicle controlled by Autodrive is loaded onto a vehicle wagon, it will be removed from the GUI, to be restored again on unloading. Thanks to robot256 for cooperating on this!

Compatibility with mods that provide grids

If you are the author of a mod that adds small grids to vehicles, and you think that you can't spare the number of slots necessary to accomodate all Autodrive sensors (currently 9, all are 1x1 items), you can easily add the name of your grids to those that Autodrive will extend. Just to add this to data-updates.lua of your mod:

if mods["autodrive"] and autodrive_global and autodrive_global.extend_grid_name_patterns then
  table.insert(autodrive_global.extend_grid_name_patterns, STRING)
end

STRING may be a regular expression that matches one or several grid names, e.g.

table.insert(autodrive_global.extend_grid_name_patterns, "^my%-.+%-grid$")

It may also be a full grid name, e.g.

table.insert(autodrive_global.extend_grid_name_patterns, "my-car-grid")

If you're uncomfortable with regular expressions, you can use several line like these, one for each grid you want to add:

table.insert(autodrive_global.extend_grid_name_patterns, "my-car-grid")
table.insert(autodrive_global.extend_grid_name_patterns, "my-tank-grid")