K2SO Arsenal

by eRisel

Combat-focused addon for Krastorio 2 Spaced Out, adding new ways to fight back against tougher enemy modpacks such as Rampant Fixed, Fulgoran Enemies, and similar combat expansions.

Content
2 days ago
2.0 - 2.1
991
Combat Enemies

g [fixed] Error

6 days ago

Error while loading entity prototype "eRisel-focused-sniper-turret" (ammo-turret): In circuit connector definitions expected table of 8 elements but 4 were given
Modifications: K2 Arsenal

emmmmmmmm,I use Razi Protocol https://mods.factorio.com/mod/razi-protocol?from=search

6 days ago

我用API询问了DEEPSEEK,答复如下:
根因:2.0/2.1 要求炮塔的 circuit_connector 是 8 项(4 朝向 × 2 镜像),而 FocusedSniperTurret.lua 沿用了 1.1 的写法只给了 4 项;create_vector 不会自动补,于是原型校验直接失败,整个存档/游戏都进不去。
补丁思路:把 eRisel-focused-sniper-turret.circuit_connector 复制到 8 项即可;放在 data-final-fixes.lua 里最安全,不依赖改别人文件。
建议同时去 mod 页面提个 issue,让作者把 FocusedSniperTurret.lua 里的列表补成 8 条(或直接继承 gun-turret 的 circuit_connector),这样以后就不用带补丁了。
按照它给的补丁方案,我已经成功进入了游戏,问题代码在这:
一、原因
可以定位到 prototypes/FocusedSniperTurret.lua 里这一段:

LUA
turret.circuit_connector = circuit_connector_definitions.create_vector(
universal_connector_template,
{
{variation = 17, main_offset = util.by_pixel(-21, 1), shadow_offset = util.by_pixel(-12, 10), show_shadow = true},
{variation = 17, ...}, -- 共 4 条,内容完全一样
{variation = 17, ...},
{variation = 17, ...}
},
true
)
这里的逻辑是:

circuit_connector_definitions.create_vector(模板, 列表) 只是按列表长度 1:1 生成连接点定义。你给 4 条,它就返回 4 个元素(第三个参数 true 不会帮你翻倍,它不控制数量)。所以 turret.circuit_connector 最终只有 4 项。
而在 2.0 中,炮塔这类可镜像的实体要求 circuit_connector 必须是 8 项(4 个朝向 × 2 个镜像状态;原版 2.x 的 gun-turret 本身就是 8 项)。加载时引擎会做原型校验:
In circuit connector definitions expected table of 8 elements but 4 were given

这段代码原本采用 1.1 中的写法:1.1 里 gun-turret 确实只有 4 条 create_vector 条目,而且 4 条内容一模一样,说明作者只想表达“一个连接点,四个朝向都用它”。升级到 2.0 后元素数量要求翻倍了,作者却没有改,于是这条原型无法加载。
顺便说明:eRisel-shotgun-turret(Turrets.lua)根本没写 circuit_connector,eRisel-repair-turret 里是 nil,因此目前只有聚焦狙击塔这一条会触发这个错误;不过 Armory.lua 的自建 assembling-machine 也用 4 项 create_vector(装配机 4 项是正确的),所以不必改动。

二、补法 A:直接改 mod 文件(最快,一次性)
把那段列表从 4 条复制成 8 条(内容一样即可):

LUA
turret.circuit_connector = circuit_connector_definitions.create_vector(
universal_connector_template,
{
{variation = 17, main_offset = util.by_pixel(-21, 1), shadow_offset = util.by_pixel(-12, 10), show_shadow = true},
{variation = 17, main_offset = util.by_pixel(-21, 1), shadow_offset = util.by_pixel(-12, 10), show_shadow = true},
{variation = 17, main_offset = util.by_pixel(-21, 1), shadow_offset = util.by_pixel(-12, 10), show_shadow = true},
{variation = 17, main_offset = util.by_pixel(-21, 1), shadow_offset = util.by_pixel(-12, 10), show_shadow = true},
{variation = 17, main_offset = util.by_pixel(-21, 1), shadow_offset = util.by_pixel(-12, 10), show_shadow = true},
{variation = 17, main_offset = util.by_pixel(-21, 1), shadow_offset = util.by_pixel(-12, 10), show_shadow = true},
{variation = 17, main_offset = util.by_pixel(-21, 1), shadow_offset = util.by_pixel(-12, 10), show_shadow = true},
{variation = 17, main_offset = util.by_pixel(-21, 1), shadow_offset = util.by_pixel(-12, 10), show_shadow = true}
},
true
)
另一种更省事的写法:直接借用原版机枪塔的连接点定义(这个塔本来就是拿 gun-turret 的底座贴图改的,偏移也合适):

LUA
turret.circuit_connector = table.deepcopy(data.raw["ammo-turret"]["gun-turret"].circuit_connector)
缺点是 mod 一更新就被覆盖。

建议作者检查一下子文件代码的情况

5 days ago

Thanks for the bug report! Your fix idea was actually pretty reasonable, but I wanted to make sure I understood the root cause properly before patching it.

The issue was that the Focused Sniper Turret was copying the vanilla Gun Turret as its base, so if another mod changed the Gun Turret's directional flags before Arsenal created its own prototype, those changes could be inherited accidentally. In your case that resulted in the turret becoming 8-directional while still having only 4 circuit connector definitions, which caused the startup crash.

Instead of just duplicating the connectors as a one-off fix, I changed the turret so Arsenal now controls its directional setup itself. The Focused Sniper Turret is now officially 8-directional and has 8 matching circuit connector definitions, so changes made to the vanilla Gun Turret by other mods should no longer cause this specific compatibility issue in the future either.

I haven't tried launching that absolute hell of a modpack myself, so please test it in-game and let me know if everything works properly now.

This thread has been locked.