Skip to content

fixed "Error while running event Transport_Drones_Meglinge_Fork::on_entity_died (ID 4) LuaForce doesn't contain key kill_count_statistics." #57

@Aeside1

Description

@Aeside1

During my use of this mod, I encountered several crashes of kill_count_statistics due to the destruction of drone entities. After multiple occurrences, I attempted a simple fix.

Upon studying the Lua code for drones, I identified an issue in line 743 of transport_drone.lua based on the provided clash information. This drone mod was hastily adapted for Factorio 2.0, and as a result, the author neglected to update the kill_count_statistics code. In version 2.0, significant changes were made to the planet system (specifically Class LuaSurface), altering how kill_count_statistics is accessed; it can no longer be directly accessed via entity.kill_count_statistics but must instead use get_kill_count_statistics(Surface surface). The retained direct access from ported 1.1 code led to crashes.

Ultimately, I modified the code to utilize get_kill_count_statistics and passed entity.surface as an argument.

This is my first experience with Lua and fixing game code; any guidance would be appreciated...

I dont konw how to upload my code to github item,Here are the fixed mod :
https://drive.google.com/file/d/13i-LySxQOD8mzL_-8w-qQJnKP1MinVf2/view?usp=sharing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions