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
15 days ago
0.17 - 1.1
2.40K
Transportation

b [Fixed] Non-recoverable error upon adding logistic network to vehicle

3 years ago
(updated 3 years ago)

https://i.imgur.com/wFVOKRL.jpg

Just updated to ver 0.2.4, tried adding it to both Hovercraft and AAI vehicles.
Modslist:
https://pastebin.com/8CnQq9dh

3 years ago

What happens if you remove AAI from the game? Do you still get a crash when just Hovercrafts is active?

3 years ago
(updated 3 years ago)

I don't have AAI vehicles (the one that gives control) enabled, but let me try real quick:
So, it works with only autodrive and hovercrafts (plus dependency shortwave), hmmmm. What exactly did you change to enable the buffered inventory? Ill try another save with the mods I have to see if that fixes the issue.

3 years ago

The way that works is, that a hidden requester chest is created if a vehicle with the Logistic network sensor is parked in the logistic area of a roboport. I've just added request_from_buffers to that chest:

  if not (requester and requester.valid) then
state.requester = car.surface.create_entity({
  name = "autodrive-requester",
  position = position,
  force = car.force,
})
-- Allow requesting items from buffer chests
if game.players[state.owner].mod_settings['autodrive-allow-bufferchest-requests'].value then
  state.requester.request_from_buffers = true
end
requester = state.requester
  end

I could imagine that AAI Programmable Vehicles causes problems, just what you'd expect when two mods fight about control over the same vehicle. :-)

3 years ago

I just had the exact same error.

My modlist: https://pastebin.com/9B3tfyuq

I have 3 vehicles controlled by autodrive: 2 cars, 1 tank. One car is sitting idle at spawn (basically it's there for if I die and my car gets destroyed, I have a copy so I don't need to redo the inventory filters). The other car and the tank, I just sent into logistic area to load/unload. I'm not present myself.

I do use a vehicle grid mod, and both the tank and the car have a roboport + battery + power source in addition to the autodrive sensors.

In any case, I'm not using AAI Programmable Vehicles as a mod, so it's not that that makes it crash.

3 years ago

I quickly went over the modlist of Amidaryu, and saw which mods I have also enabled. I came up with the following list:

AutoDeconstruct
autodrive
Bottleneck
even-distribution
FNEI
LogisticTrainNetwork
MaxRateCalculator
Mining_Drones
SchallLampContrast
shortwave
Squeak Through
YARM

So other than autodrive, nothing that really interacts with vehicles.

3 years ago

I've found the mistake: I need to get the runtime settings of the user controlling a vehicle. A vehicle is controlled by a user if the user name appears in the GUI. Otherwise, it isn't associated with a player and we get a crash when trying to read settings of player nil.

There may be a way around this -- if I can get at the "Last user:" info (not sure, have to check). If that isn't possible, I'll have to change from a per-player to a map or startup setting.

3 years ago

Yay, thanks Pi for your hard work!

3 years ago

:-)

3 years ago

I'm not sure what exactly you ended up doing to fix it, but thanks for the fix!

Another option might be to move the checkbox to the Autodrive GUI during the game, next to the car. This would allow you to set the option for each different car individually. For me currently this certainly isn't something that I need, but it might be a cleaner solution than putting it in the settings.

3 years ago

I'm not sure what exactly you ended up doing to fix it, but thanks for the fix!

I needed to get at the user settings of the player. Before the fix, I only looked for the player who controlled a vehicle. This would work if the player name was next to the vehicle in the GUI (i.e. vehicle data and player data were associated by the mod), but it would crash if you'd ordered a vehicle to go somewhere, then chosen another one. But Factorio stores "Last user" for each vehicle, so if there's no connection between player and vehicle, I now ask the vehicle directly for the last player operating it.

Another option might be to move the checkbox to the Autodrive GUI during the game, next to the car. This would allow you to set the option for each different car individually. For me currently this certainly isn't something that I need, but it might be a cleaner solution than putting it in the settings.

I agree, that may be cleaner, but putting it in the settings is easier for me. Perhaps I'll add a button for it in the future. For now, let's see whether the current solution really works without bugs!

Also, there are other things I consider more important. For example, the logistic system isn't really useful yet because you can't send a vehicle to position A to pick up cargo and bring it to position B for unloading. The reason is that vehicles always request items for which there are filtered slots in the inventory, and provide items that are in unfiltered slots. We need a way to toggle the filters on a certain condition so that they request certain items at A and provide them at B. This is important functionality, the GUI is just eye candy -- nice to have, but not exactly necessary.

3 years ago

Another option might be to move the checkbox to the Autodrive GUI during the game, next to the car. This would allow you to set the option for each different car individually. For me currently this certainly isn't something that I need, but it might be a cleaner solution than putting it in the settings.

I agree, that may be cleaner, but putting it in the settings is easier for me. Perhaps I'll add a button for it in the future. For now, let's see whether the current solution really works without bugs!

Yeah, as said, I have no need for this setting to be different on different cars, just wanted to tell you how I would try to solve it if I was making it, but as I've never made a Factorio mod, I don't know how difficult it would be to do.

Also, there are other things I consider more important. For example, the logistic system isn't really useful yet because you can't send a vehicle to position A to pick up cargo and bring it to position B for unloading. The reason is that vehicles always request items for which there are filtered slots in the inventory, and provide items that are in unfiltered slots. We need a way to toggle the filters on a certain condition so that they request certain items at A and provide them at B. This is important functionality, the GUI is just eye candy -- nice to have, but not exactly necessary.

One way you could hack this slightly, might be to put all the contents in a hidden buffer chest when in a logistics network. This would allow it to request extra material in one network, and provide it in another. But please make this optional, as it would break other things (like requesting from other buffer chests). And this is a very hacky way to do it, and probably it should be done in a cleaner way, but I don't have no idea how ;)

3 years ago

Also, there are other things I consider more important. For example, the logistic system isn't really useful yet because you can't send a vehicle to position A to pick up cargo and bring it to position B for unloading. The reason is that vehicles always request items for which there are filtered slots in the inventory, and provide items that are in unfiltered slots. We need a way to toggle the filters on a certain condition so that they request certain items at A and provide them at B. This is important functionality, the GUI is just eye candy -- nice to have, but not exactly necessary.

One way you could hack this slightly, might be to put all the contents in a hidden buffer chest when in a logistics network. This would allow it to request extra material in one network, and provide it in another. But please make this optional, as it would break other things (like requesting from other buffer chests). And this is a very hacky way to do it, and probably it should be done in a cleaner way, but I don't have no idea how ;)

Using buffer chests? The hidden chests are only created when a vehicle moves into a logistic area anyway, so if a vehicle is set to … let's call it "trading mode" …, a buffer chest could be created (automatically turning "Request from buffer chests" off), and requester/provider chests otherwise. But I've no idea yet how to distinguish between slots for requested and provided items.

3 years ago

Using buffer chests? The hidden chests are only created when a vehicle moves into a logistic area anyway, so if a vehicle is set to … let's call it "trading mode" …, a buffer chest could be created (automatically turning "Request from buffer chests" off), and requester/provider chests otherwise. But I've no idea yet how to distinguish between slots for requested and provided items.

So if set to this trading mode, when stopping in a logistic network, you create the buffer chest with the requests set to whatever filters you have on the trunk. Then you immediately dump the whole contents of the trunk in that buffer chest.

This requires a player to keep this in mind when doing their logistic networks. Picking stuff up isn't really a problem, as the buffer chest takes care of that automatically (except it won't pick up stuff from other (real) buffer chests). Dropping stuff off requires requester chests with the request from buffer chests option enabled. That also means they can't really have other buffer chests in that same logistics network, and you can't really have those resources in provider chests or storage chests in that network, as that will fill up the car's buffer chest again, defeating the point.

But as I said, it's a hack. Obvious issue with it: when parked, you have to put the whole trunk contents in the buffer chest, so it would not be visible for the player.

3 years ago

The problem is that inventory slots only have 2 states: filtered or unfiltered. I'd definitely need a third state, so slots can be ignored.

The idea is that you pick up items in A and drop them off to B. So the state of the slots has to be toggled based on where we are: Slots that were used for requesting at A should be providing at B. But what about the stuff you want to keep? It would be bad if bots loaded all fuel or ammo from your trunk! It's quite tricky … :-)

New response