LuaEntity.stop_spider() has no effect

Bugs that are actually features.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1742
Joined: Sun Oct 14, 2018 8:13 am
Contact:

LuaEntity.stop_spider() has no effect

Post by Pi-C »

Expected behavior: If a spider-vehicle is in motion, it will immediately stop once it has received the stop_spider() command.

Real behavior: For this code

Code: Select all

AD.show("vehicle.autopilot_destination", vehicle.autopilot_destination)
AD.show("vehicle.autopilot_destinations", vehicle.autopilot_destinations)

AD.writeDebug("Trying to stop spider!")
vehicle.stop_spider()

AD.show("vehicle.autopilot_destination", vehicle.autopilot_destination)
AD.show("vehicle.autopilot_destinations", vehicle.autopilot_destinations)
I get the following output:

Code: Select all

20189.718 Script @__autodrive__/libs/debugging.lua:167: vehicle.autopilot_destination: {
  x = -11.5,
  y = -17.5
}
20189.718 Script @__autodrive__/libs/debugging.lua:167: vehicle.autopilot_destinations: {
  {
    x = -11.5,
    y = -17.5
  },
  {
    x = -11.5,
    y = -18.5
  },
  {
    x = -12.42578125,
    y = -19.06640625
  }
}
20189.718 Script @__autodrive__/libs/debugging.lua:167: Trying to stop spider!
20189.718 Script @__autodrive__/libs/debugging.lua:167: vehicle.autopilot_destination: {
  x = -11.5,
  y = -17.5
}
20189.718 Script @__autodrive__/libs/debugging.lua:167: vehicle.autopilot_destinations: {
  {
    x = -11.5,
    y = -17.5
  },
  {
    x = -11.5,
    y = -18.5
  },
  {
    x = -12.42578125,
    y = -19.06640625
  }
}
Neither vehicle.autopilot_destination nor vehicle.autopilot_destinations have been affected by vehicle.stop_spider(), and the vehicle happily continued on its path.

The only way to make sure the vehicle stops seems to be this:

Code: Select all

for w, waypoint in pairs(vehicle.autopilot_destinations) do
	vehicle.autopilot_destination = nil
end
This isn't very intuitive. Shouldn't stop_spider() automatically clear autopilot_destination/autopilot_destinations?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5304
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: LuaEntity.stop_spider() has no effect

Post by Klonan »

Pi-C wrote: Wed Sep 21, 2022 6:04 pm Expected behavior: If a spider-vehicle is in motion, it will immediately stop once it has received the stop_spider() command.

This isn't very intuitive. Shouldn't stop_spider() automatically clear autopilot_destination/autopilot_destinations?
The function is only calling the internal resetSpeed() on the spider, the usecase being after reaching the waypoints to stop all extra momentum/movement

Since autopilot destinations are easily cleared with script, and clearing was never mentioned in the mod requests or the changelog, I will class this as not a bug
Pi-C
Smart Inserter
Smart Inserter
Posts: 1742
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: LuaEntity.stop_spider() has no effect

Post by Pi-C »

Thanks for your reply!
Klonan wrote: Wed Sep 21, 2022 7:41 pm The function is only calling the internal resetSpeed() on the spider, the usecase being after reaching the waypoints to stop all extra momentum/movement
Too bad that isn't documented! :-)
Since autopilot destinations are easily cleared with script, and clearing was never mentioned in the mod requests or the changelog, I will class this as not a bug
They are easily cleared per script once you know how to do that, which isn't obvious:

Code: Select all

autopilot_destination :: MapPosition? [Read/Write] 
Destination of this spidertron's autopilot, if any.

autopilot_destinations :: array[MapPosition] [Read] 
The queued destination positions of spidertron's autopilot.

stop_spider() 
Stops the given SpiderVehicle.
I've added this to the documentation improvement requests.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Post Reply

Return to “Not a bug”