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] 2.0.7 LuaItemStack doesn't contain key contents.

17 days ago
(updated 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_pre_build (ID 9)
LuaItemStack doesn't contain key contents.
stack traceback:
[C]: in function 'index'
__companion-drones
/script/companion.lua:1529: in function 'get_all_blueprint_entities'
companion-drones/script/companion.lua:1555: in function 'get_blueprint_area'
companion-drones/script/companion.lua:1588: in function 'handler'
core/lualib/event_handler.lua:47: in function <core/lualib/event_handler.lua:45>

on placing a blueprint using blueprint book (but placing a single blueprint works)
mod: space-age

12 days ago

Please can you send me the save just before place the blueprint ?
I cannot simulate this
Thanks

12 days ago

1) Start a new game, 2) make a blueprint book, 3) add a blueprint
4. select the blueprint-book (NOT THE BLUEPRINT) 5) place th blueprint > crash

1529 for _, item in pairs(blueprint_record.contents) do
"LuaItemStack doesn't contain key contents."
this means blueprint_record is a LuaItemStack and in LuaItemStack is no 'contents' field

https://lua-api.factorio.com/latest/classes/LuaItemStack.html

12 days ago

Can you try it in 2.0.8 ?
I am not able to reproduce it

12 days ago

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

Error while running event companion-drones::on_pre_build (ID 9)
LuaItemStack doesn't contain key contents.
stack traceback:
[C]: in function 'index'
__companion-drones
/script/companion.lua:1556: in function 'get_all_blueprint_entities'
companion-drones/script/companion.lua:1582: in function 'get_blueprint_area'
companion-drones/script/companion.lua:1615: in function 'handler'
core/lualib/event_handler.lua:47: in function <core/lualib/event_handler.lua:45>

Same error
"LuaItemStack doesn't contain key contents."
what type do you expect there?

12 days ago
(updated 12 days ago)

local function get_all_blueprint_entities(blueprint_record)
local entities = {}

-- Check if the item is a blueprint book
if blueprint_record.type == "blueprint-book" then
-- Recursively process each item inside the book
for , item in pairs(blueprint_record.contents) do
local nested_entities = get_all_blueprint_entities(item)
for
, nested_entity in pairs(nested_entities) do
table.insert(entities, nested_entity)
end
end
elseif blueprint_record.type == "blueprint" then
-- Add entities if it's a single blueprint
local blueprint_entities = blueprint_record.get_blueprint_entities()
if blueprint_entities then
for _, entity in pairs(blueprint_entities) do
table.insert(entities, entity)
end
end
end

return entities
end

But I am not able to create scenario when blueprint_record.type == "blueprint-book" but is also LuaItemStack

12 days ago
(updated 12 days ago)

Ah now i get it, it is difference when i try to place blueprint book from library or blueprint book as item from inventory

Will fix it tonight

12 days ago

LOL I never said put the book in the library ;-) but this also happens to me, especially when testing if you keep doing the same steps.

go ahead, i wait

11 days ago

Should be fixed in 2.0.9

11 days ago

seems to work, thanks

New response