在使用这个mod的过程中我遇到了好几次由于无人机实体被杀死导致kill_count_statistics崩溃,在遇到好几次后我尝试做了一点简单的修复。
研究过无人机的lua代码后,根据给出的clash信息确定在了transport_drone.lua中的743行代码,由于这个无人机mod是赶鸭子上架用来适配Factorio2.0,导致懒狗作者没有修改kill_count_statistics的代码。2.0中作者因为大修了星球系统(也就是Class LuaSurface),修改了kill_count_statistics的获取,不能直接访问entity.kill_count_statistics,改成使用get_kill_count_statistics(Surface surface)获取kill_count_statistics,而由于移植过来的1.1代码任然保留直接访问kill_count_statistics导致了mod崩溃。所以最后我适配了一下2.0的代码使用get获取kill_count_statistics并且传入entity.surface作为参数。
这是我第一次使用lua,第一次修复游戏代码,欢迎指教......
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...
Here are the fixed mod :
https://drive.google.com/file/d/13i-LySxQOD8mzL_-8w-qQJnKP1MinVf2/view?usp=sharing