[2.0.15][Space Age] Access via mod to cago_pod during rocket launch causes non-recoverable

Bugs that are actually features.
User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 239
Joined: Sat Nov 09, 2019 6:49 am
Contact:

[2.0.15][Space Age] Access via mod to cago_pod during rocket launch causes non-recoverable

Post by picklock »

I am currently in the process of adapting my mod Picklocks rocket silo stats for Space Age. I would like to record the payload of launched rockets. In the base game I use the inventory of the cargo_pod.

In Space Age, the following error occurs when defining the inventory of the cargo_pod:

Code: Select all

The mod Picklocks rocket silo stats (1.3.0) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event PicksRocketStats::on_rocket_launched (ID 10)
__PicksRocketStats__/control.lua:631: attempt to index field 'cargo_pod' (a nil value)
stack traceback:
	__PicksRocketStats__/control.lua:631: in function <__PicksRocketStats__/control.lua:597>
Here is the corresponding line of code that works in the base game and causes the error in Space age:

Code: Select all

local inventory = event.rocket.cargo_pod.get_inventory(defines.inventory.cargo_unit)
I would have expected the code from the base game to also work in Space Age.
The error always occurs in Space Age.

See also the following discussion:
viewtopic.php?p=633329#p633329
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters | Picklocks QuickBar Import/Export | Picklocks Nauvis Cliff-Explosives
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4151
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.15][Space Age] Access via mod to cago_pod during rocket launch causes non-recoverable

Post by boskid »

For me this looks like a modding interface request pretending to be a bug report. cargo_pod is already detached from the rocket at the time when this event is raised so there is nothing strictly broken here: you are trying to use a variable that is nil.
User avatar
picklock
Fast Inserter
Fast Inserter
Posts: 239
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [2.0.15][Space Age] Access via mod to cago_pod during rocket launch causes non-recoverable

Post by picklock »

Thanks for the answer.
Then the only way to query the payload of the rocket is with the event "on_rocket_launch_ordered". This can be used to read the inventory of the cargo_pod.
Or is there a method in space-age to read the payload of the rocket with the event "on_rocket_launched"?
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters | Picklocks QuickBar Import/Export | Picklocks Nauvis Cliff-Explosives
Post Reply

Return to “Not a bug”