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
a month ago
0.17 - 1.1
2.97K
Transportation Combat Logistic network Circuit network

b [Fixed?] Crash in IR3 with "Heavy Picket" vehicle

5 months ago

https://imgur.com/ez0uvLa

Newly created vehicle from IR3
Heavy Picket - Fuel types are 2 kinds of batteries and hydrogen fuel cell
Has equipment:
- Logistics Network sensor
- Fuel Sensor
- Repair Sensor 3
- Follow Player Sensor
- Miniature Fission Reactor4- Fuel type Uranium Fuel Cell

Only Hydrogen Cells (vehicle fuel not fusion reactor fuel) are in inventory/requested via logistics.

No Crash - If Miniature Fission Reactor NOT installed, vehicle fuels normally via fuel sensor with hydrogen cells
No Crash - If Miniature Fission Reactor is installed AND FUELED MANUALLY and fuel sensor refuels vehicle with hydrogen cells
Crash - If Miniature Fission Reactor is installed with no fuel and vehicle fuel runs out triggering refuel.. crash.
Crash - If Battery Discharge Equipment is installed(uses same Hydrogen cells as the vehicle can be fueled with) with no fuel and vehicle fuel runs out triggering refuel.. crash.
No Crash - If vehicle tank is full but equipment power source is empty... and it does not fuel the equipment.

I don't get into these vehicles... If I do and I have IR3's Fuel Manager turned on, IR3 will fill the vehicle and the power sources itself.

In summary, it seems to crash when looking into fueling an unfueled equipment in the equipment grid at the time when it goes to refuel the main vehicle fuel tank.

Something else that I'd swear used to work but not now(though I could be misremembering) is removal of spent fuel containers to general trunk inventory. they pile up in the fuel outboxes until full then the vehicle gets stuck.

5 months ago

Thanks for the report! I'll try to figure out why the crash happens.

Something else that I'd swear used to work but not now(though I could be misremembering) is removal of spent fuel containers to general trunk inventory. they pile up in the fuel outboxes until full then the vehicle gets stuck.

Must have been some other mod that removed empty fuel cells. As far as I remember we never had code for removing stuff from the burned_result_inventory because there were no cars where that would have been necessary. That's definitely something I'll have to add! :-)

5 months ago

Does your refuel function try to fuel power source equipment in the equipment grid too?

5 months ago

Does your refuel function try to fuel power source equipment in the equipment grid too?

Equipment can get refuelable energy from a LuaBurnerPrototype which (always?) has a fuel inventory and may have a burned-result inventory. Fuel may be anything from wood to nuclear fuel cells, it could even be batteries -- depending on the fuel categories supported by the LuaBurnerPrototype. If there is any equipment with a LuaBurnerPrototype in the grid, my function will look in the trunk for items that belong to any of the fuel_categories expected by the burner.

5 months ago

I'm working on removing items from the burnt_results_inventory of vehicles and equipment. If the fuel inventory (of the vehicle or some equipment) is empty, I first try to add fuel from the trunk (if it contains any usable fuel, this may free one or more slots in the trunk). Then, if vehicle or equipment have items in the burnt_results_inventory, I remove these.

This is no problem if there is room in the trunk for the removed items. If there is not enough room for all items, and if there is a player inside the vehicle, I'll try to move the remaining items to the main inventory of that player. Finally, if there still are items left, I'll spill the remaining items on the ground. Would that be OK, or do you have a better idea?

5 months ago

Maybe to player trash? then ground marking it for deletion.
I think it would also be OK to have it shrug and give up, possibly make an alert or something in the case of nowhere to put empty fuel too.. but dropping the spent cannisters would possibly work?

5 months ago

Maybe to player trash? then ground marking it for deletion.

I've thought about player trash myself. But IIRC, player trash is not available from the start of the game; instead it requires that logistic bots are researched. So, before player trash is available, we could first try to move the used fuel to the player's main inventory, or skip the player entirely and spill everything on the ground directly.

I think it would also be OK to have it shrug and give up, possibly make an alert or something in the case of nowhere to put empty fuel too..

Adding a user setting may be a good idea …

but dropping the spent cannisters would possibly work?

It should. LuaSurface::spill_item_stack returns an array with the created item-on-ground entities, so we can directly loop over these items and mark them for deconstruction.

However, I'm not sure that marking spilled items for deconstruction would really be useful: Suppose the items have been spilled because there was no space in the vehicle trunk or player inventories. Now, if the player had a personal roboport, wouldn't the bots immediately try to pick up the items again? As the player doesn't have inventory space left, I imagine the bots would try to move the spilled items to a logistic chest (which may be far away) or remain in place because they can't drop the items (so if the vehicle would move on the bots would be lost to the player).

5 months ago
(updated 5 months ago)

https://imgur.com/ez0uvLa

You can fix this crash by replacing function common.loc_name in file common.lua with the following:

common.loc_name = function(entity, flags)
  common.assert(entity, "table", "entity")
  common.assert(flags, {"table", "nil"}, "nil or table of flags")

  local ignore_custom_name = flags and flags.ignore_custom_name
  local ignore_unit_number = flags and flags.ignore_unit_number

  ----------------------------------------------------------------------------------
  -- Get localized name of entity
  local loc_name = (not entity and "nil") or
                    (not entity.valid and entity.object_name) or
                    entity.localised_name or entity.name

  ----------------------------------------------------------------------------------
  -- If not prevented by flags, get unique identifier to add to localized name
  local append

  -- LuaEquipmentPrototype doesn't have property 'unit_number'!
  local id = (entity.object_name == "LuaEntity") and
                entity.valid and entity.unit_number

  if id and not (ignore_custom_name and ignore_unit_number) then
    -- Try to get custom name?
    if not ignore_custom_name then
      local name_by_id = global.named_vehicles.by_id[id]
      append = name_by_id and name_by_id.name and common.enquote(name_by_id.name)
    end

    -- Fall back to unit_number?
    if not (append or ignore_unit_number) then
      append = id
    end
  end

  return {"", loc_name, append and " ", append}
end

No Crash - If vehicle tank is full but equipment power source is empty... and it does not fuel the equipment.

Fixed for next version: We'd only look at the equipment if the vehicle had an empty fuel tank. Now fuel tank and equipment will be checked separately. Also, we will now check the fuel of grid equipment even if the vehicle doesn't have a fuel tank (e.g. vanilla spider-vehicles).

5 months ago

However, I'm not sure that marking spilled items for deconstruction would really be useful: Suppose the items have been spilled because there was no space in the vehicle trunk or player inventories. Now, if the player had a personal roboport, wouldn't the bots immediately try to pick up the items again? As the player doesn't have inventory space left, I imagine the bots would try to move the spilled items to a logistic chest (which may be far away) or remain in place because they can't drop the items (so if the vehicle would move on the bots would be lost to the player).

Actually.. when Ive seen that happen you get bots holding items, following you that can't land because you don't have inventory space .

5 months ago

Should be fixed in version 1.1.13!

New response