Companion Drones 2.0 [WIP]

by kubiixx

Adds friends - now to Factorio 2.0 WORK IN PROGRESS - crashes may occur - use with caution !

Content
11 days ago
2.0
2.44K

b [FIXED] Crash (just walked in the spidertron with bots)

17 days ago

The mod Companion Drones 2.0 (2.0.7) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event companion-drones::on_tick (ID 0)
LuaEntity doesn't contain key controller_type.
stack traceback:
[C]: in function 'index'
__companion-drones
/script/companion.lua:652: in function 'take_item'
companion-drones/script/companion.lua:828: in function <companion-drones/script/companion.lua:816>
(...tail calls...)
companion-drones/script/companion.lua:938: in function 'try_to_find_work'
companion-drones/script/companion.lua:1099: in function 'perform_job_search'
companion-drones/script/companion.lua:1179: in function 'check_job_search'
companion-drones/script/companion.lua:1217: in function 'handler'
core/lualib/event_handler.lua:47: in function <core/lualib/event_handler.lua:45>

16 days ago

I have exactly the same error! I missed that bugs can be created on Factorio website, and send it in discord directly.
Here is the results of my investigation

The issue occurs at line 652 in companion.lua:

if not target.controller_type or target.controller_type ~= defines.controllers.character then return end

This line doesn't work for vehicles or wagons(and will crash the game since controller_type is a property of LuaPlayer only), as we use this function with those entity types in the code. Here’s my proposed fix:

if target.is_player() and (not target.controller_type or target.controller_type ~= defines.controllers.character) then return end

Since only players have controller_type, this modification makes sense. The code then executes correctly for non-player entities, and I haven’t experienced any crashes for a few hours.

12 days ago

Fixed in 2.0.8

New response