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
17 days ago
0.17 - 1.1
2.41K
Transportation

g Crash

4 years ago

Hi, just got back to playing Factorio and got a crash when I used the car key the first time after updating to 0.1.11:

1834.123 Error MainLoop.cpp:1199: Exception at tick 5016072: The mod Autodrive caused a non-recoverable error.
Please report this error to the mod author.

Error while running event autodrive::on_tick (ID 0)
LuaEntity API call when LuaEntity was invalid.
    stack traceback:
    __autodrive__/control.lua:137: in function 'gui_car_unpublish'
    __autodrive__/control.lua:646: in function 'remove_car'
    __autodrive__/control.lua:728: in function 'tick_car'
    __autodrive__/control.lua:1057: in function <__autodrive__/control.lua:1054>
stack traceback:
    [C]: in function '__index'
    __autodrive__/control.lua:137: in function 'gui_car_unpublish'
    __autodrive__/control.lua:646: in function 'remove_car'
    __autodrive__/control.lua:728: in function 'tick_car'
    __autodrive__/control.lua:1057: in function <__autodrive__/control.lua:1054
dorfl β˜†
4 years ago

Thanks for the report. I think the required fix is in 0.1.12, but important to note the .11 multiplayer updates affected quite a bit of the code and I've not tested them with car key... tread carefully, save a lot, etc.

4 years ago

Thanks for the quick update! 0.1.12 seems to fix it. I just summoned the car without a crash. I'll keep you updated if I run into problems after playing some more.

4 years ago

Another crash:

Error while running event autodrive::on_tick (ID 0)
__autodrive__/control.lua:183: attempt to index local 'state' (a string value)
stack traceback:
    __autodrive__/control.lua:183: in function 'notify'
        __autodrive__/control.lua:697: in function 'request_path'
    __autodrive__/control.lua:889: in function 'tick_car'
    __autodrive__/control.lua:1057: in function <__autodrive__/control.lua:1054

This happened while I was trying out shortwave radio/network sensor, but I can't tell what I did at the moment. Also, I'm not quite sure how to use these correctly. I can input coordinates by setting values for X and Y in a constant combinator. But that is used for a one-way trip. How could I send the coordinates for a complete route (e.g. pick up ore at one place, bring it to a storage near the smelters, go pick up fuel, repeat)?

I originally thought one should place a radio (all radios for one car transmitting over the same channel) near every waypoint, and it would always send the coordinates of the next stop, so the car can read it if it's near the radio and calculate a path to the new destination. But that's obviously not the way this mod works. :-)

4 years ago

Something else: The On-/Off-button on the radio doesn't have any effect. As soon as I set a signal in the constant combinator wired to the radio, the car starts moving -- even if the radio is turned off.

dorfl β˜†
4 years ago

Thanks for the report; 0.1.13 fixes the crash. It was triggered when a non-colliding-position couldn't be found within a certain radius of the path target... which I've also just discovered is surprisingly hard to test for failure, because Factorio is really very good with finding obscure spaces for bounding boxes :-)

Yeah, the circuit network control was added to just mimic the functionality of the control. "Go to X,Y". The car also sends its own arrival/departure signals so the circuit network can react. Details on the information tab. So waypoints and routes are possible if you're into combinators. Best I've done is 3 combinators per waypoint and 3 more for timing pauses before each departure to allow robots time to work. I'm not sure how far down the path of automated routes I want Autodrive to go. That's really an AAI thing...

dorfl β˜†
4 years ago

The On/Off bug might be a Shortwave thing. Will check.

4 years ago

Thanks for the report; 0.1.13 fixes the crash. It was triggered when a non-colliding-position couldn't be found within a certain radius of the path target... which I've also just discovered is surprisingly hard to test for failure, because Factorio is really very good with finding obscure spaces for bounding boxes :-)

Thanks again!

Best I've done is 3 combinators per waypoint and 3 more for timing pauses before each departure to allow robots time to work.

Would you mind sharing a blueprint? I've found a solution myself, but it's big! Trouble is that you can't rely on that X=W and Y=V, they may be a bit off. So I've decided to check whether the car has arrived (B is set) in an area (X-10/X+10, Y-10/Y+10) around the way point before sending the coordinates of the next one. But that totally bloats the thing, so I need 13 combinators (one constant combinator plus a dozen of the others) per waypoint. Given that the setup is identical for each way point (apart from the constant combinators holding the values, obviously), this would be the perfect use case for the Factorissimo-like embedded combinators suggested here.

About the robots: That's another issue where I was naively assuming things. You don't really need to park a car in an exact position so it can be accessed by inserters (can do that if you park your car manually), but that means that trains are easier before robots.

I'm not sure how far down the path of automated routes I want Autodrive to go. That's really an AAI thing...

Yes, no point in reinventing the wheel. Also, I quite like that Autodrive is not as complex as AAI seems to be. It allows you to get used to programming vehicles before graduating to the advanced stuff with zone marking etc.

4 years ago

The On/Off bug might be a Shortwave thing. Will check.

It has another bug related to that it consists of two entities: Some wisps damaged my radio. I could repair the dial knob, but if I try to use a repair pack with the I/O port, I get a message "Not operable". Nevertheless, the I/O port is marked with a yellow health bar because it has only 6/10 HP left.

4 years ago
(updated 4 years ago)

… I need 13 combinators (one constant combinator plus a dozen of the others) per waypoint.

Optimized, so I save 3 combinators per way point. The fix comes with an overhead of 3 combinators for discarding all signals but X and Y and changing the wire before feeding into the radio (so input/output are separated). These 3 combinators handle input from all way points, so they don't count much if you define lots of way points. Yet, even this optimized set-up uses more combinators than your 3+3 version. :-)

dorfl β˜†
4 years ago
(updated 4 years ago)

Heh, well we're probably trying to do different things :-) My test route is a simplistic list of waypoints with 60s pause at each:

  • 3 combinators per waypoint: 1 constant to hold X,Y, and 2 deciders relaying X and Y to the radio based on a route waypoint signal N
  • 1 arithmetic combinator acting as a memory cell for N. It cycles through N%<waypoints> when pulsed
  • 1 decider combinator emitting N when car B == 60, to increment the above after car is stopped for 60s
  • 1 decider combinator permitting B through once every 60 ticks, basically edge-triggering each second
  • 1 arithmetic combinator generating a cycling 1 -> 60 tick clock signal to time the above

So, 3 per waypoint + 4 to cycle though the list. I forgot about the clock signal earlier as it's something I have throughout the base for other stuff.

4 years ago
(updated 4 years ago)

I've just been trying to figure out how to get it work, so the time to wait is still set to a value that's not enough for loading/unloading.

Constant combinator stores the coordinates (X, Y) of a waypoint and the time to wait (T). It's connected to two arithmetic combinators: one outputs EACH -10, the other EACH + 10. From each arithmetic combinator I go into two deciders (one for X, one for Y) with a green wire. These four deciders are also fed via red wire with the radio signals. Each decider checks for one of these conditions: X<=W, Y<=V, X>=W, and Y>=V. Output is GREEN=1 if true. Next row is two deciders: One checks for GREEN=4 (meaning the current position is within an area of 10x10 around X/Y). The other is connected to the constant combinator and checks for B>=T. Both deciders output GREEN=1 if true. They are connected to another decider that is also connected to the constant combinator of the next waypoint; if GREEN=2, it outputs EACH (current value).

Now, the output of the last decider is X, Y, T of the next waypoint, and GREEN=2. I need another 2 combinators to eliminate T and GREEN. I've used arithmetic combinators (T *- 1, GREEN * -1) and another decider to combine input and change the wire. So X and Y are sent via green wire into the radio, while W, V, and B are read via red wire from the radio. I guess I could even save that very last combinator if I replaced the two arithmetic combinators with deciders (if X!=0 output value of X, if Y!=0 output value of Y). That would make it 10 combinators per waypoint plus 2 deciders overhead to sanitize the input for the radio.

However, this setup only works if the car already is at one of the waypoints! I'll have to manually set the coordinates with nothing but a temporary constant combinator connected to the radio before I can hook up my contraption. But once the whole thing has been initialized, the car should happily go in circles from one waypoint to the other. (Only tested with 2 locations for now, but it should work.)

4 years ago

Error while running event autodrive::on_tick (ID 0)
Unknown sprite "item/angels-cab-_-solid"
stack traceback:
autodrive/control.lua:106: in function 'gui_car_publish'
autodrive/control.lua:817: in function 'tick_car'
autodrive/control.lua:1091: in function <autodrive/control.lua:1088>
stack traceback:
[C]: in function 'add'
autodrive/control.lua:106: in function 'gui_car_publish'
autodrive/control.lua:817: in function 'tick_car'
autodrive/control.lua:1091: in function <autodrive/control.lua:1088>

dorfl β˜†
4 years ago

Thanks for the report. Fixed in 0.1.15.

4 years ago

Great, thank you for your job.

New response