Caught by an in-game crash on real Factorio 2.0.77 (with Space
Exploration + Krastorio 2 loaded):
Error while running event kafkatorio-events::on_chunk_generated
Unknown collision-layer name: resource-layer
Factorio 2.0 made collision layers fully prototype-defined (previously
a fixed set of built-in names). Checked the official factorio-data
2.0.77 tag's core/lualib/collision-mask-defaults.lua: resource-type
entities now use layer name "resource", not "resource-layer". Fixed
both find_entities_filtered() call sites in EntityUpdateHandler.ts
that scan for resource entities around mined/placed tiles and newly
generated chunks.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Caught by actually running the mod on a real Factorio 2.0.77 server:
Error while loading mod-setting prototype
"kafkatorio:cache-expiration-seconds_kafkatorio-packet-keyed-PlayerUpdate"
(double-setting): Invalid prototype name. Only characters
A-Z a-z 0-9 _- are allowed.
cacheDurationSettingName() built names with a ":" separator
("kafkatorio:cache-expiration-seconds_..."), which Factorio 2.0
rejects outright. Replaced it with "-", matching the mod-name-prefix
convention the engine's own docs recommend. This is a pure runtime
validation issue invisible to the TypeScript compiler - exactly the
kind of thing only actually loading the mod in-game catches.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Without an explicit rootDir, tstl computed output paths relative to
tsconfig.json's own directory (modules/events-mod/) rather than the
actual TypeScript source root (src/main/typescript/), so control.lua
and settings.lua ended up nested under src/main/typescript/ in the
packaged mod zip instead of at its root - where Factorio requires them
to be. The mod would not have loaded at all as packaged.
This went uncaught because packageFactorioMod never previously
produced real output (blocked by the now-fixed kxs-ts-gen-core/JitPack
issue). Verified by actually running packageFactorioMod and inspecting
the resulting zip: control.lua, settings.lua and info.json are now at
the root, and control.lua's require() calls ("main.global-init" etc.)
correctly resolve against that flat layout.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The version catalog pointed kxs-ts-gen-core at a JitPack coordinate
(com.github.adamko-dev.kotlinx-serialization-typescript-generator) that
no longer serves real artifacts there, despite JitPack's build-status
API still reporting it as built. The library is properly published to
Maven Central under dev.adamko.kxstsgen - a commented-out line with
that exact coordinate was already sitting in the catalog. Swapping to
it fixes dependency resolution for every module depending on
versions-platform (which previously blocked any Gradle task touching
events-library, including all of its tests).
That unblocked two more pre-existing, unrelated bugs that had never
been caught because this module never previously compiled:
- LuaJsonList<T> : List<T> by list triggered a longstanding Kotlin
compiler bug (KT-3546, "accidental override" on generic toArray)
specific to delegating java.util.List via `by`. Replaced with a
hand-written Collection<T> implementation (no delegation codegen,
no bug), which still satisfies Kotest's forOne/forAll inspectors -
the only thing any code actually needs from it.
- The kxs-ts-gen Kotlin->TypeScript generator (kt2ts2.kt) still emitted
the pre-2.0 bare `uint`/`int` names and no import statement, since it
predates typed-factorio's move to virtual modules. Updated its
primitive-type mappings to uint32/int32 and added the "factorio:runtime"
import to its generated header, so the regenerated schema matches what
the rest of events-mod now expects.
Verified via real Gradle tasks (not just manual tooling): events-library
compiles and all tests pass; events-mod's full build - Kotlin schema
generation, npm install, tstl compile, and info.json generation (with
factorio_version "2.0" and the space-exploration/Krastorio2 optional
dependencies) - succeeds end-to-end.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
typed-factorio 2.0.0+ stopped declaring types as ambient globals - they
now live in virtual modules ("factorio:runtime", "factorio:common",
"factorio:settings") and must be explicitly imported. Adds those imports
throughout events-mod. Also:
- Bumps typescript-to-lua 1.11.1 -> 1.25.2 and typescript 4.9 -> 5.4.2,
since tstl pins an exact peer TypeScript version and typed-factorio
3.x needs a newer one than 4.9 supports (a real compiler bug in
TS 4.9 against the generated defines.segmented_unit_ai_state enum).
- Bumps the pinned isolated Node (14.19.1 -> 24.21.0), since
typescript-to-lua 1.25.2 requires Node >=16.10.0.
- Renames bare uint/int -> uint32/int32 (import aliases), since the
unsized aliases no longer exist.
- Drops OnEntityDestroyedEvent from an unused documentation-only union
type - that event no longer exists in the 2.0 API.
- LuaEntityPrototype.max_health is now get_max_health() (quality-aware).
- Fixes a branded-type mismatch between our generated schema's
ForceIndex and typed-factorio's own ForceIndex.
Verified by actually running tstl end-to-end (clean compile, Lua
emitted) after installing a real JDK and Node toolchain.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Bumps the Factorio engine pin and typed-factorio (1.11.0 -> 3.36.0,
targeting 2.0.75) and fixes the resulting breaking API changes:
global -> storage, game.*_prototypes -> prototypes.*, game.table_to_json/
encode_string -> helpers.*, OnBuiltEntityEvent.created_entity -> .entity,
removed TileRead/ColorTable/MapPositionTable-style write-form aliases,
new CollisionMask shape, restructured settings-stage type imports, and
new defines.entity_status values (added to the Status enum, generated
schema, and EntityStatusRecord mapping). Also declares optional mod
dependencies on space-exploration and Krastorio2.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- create LuaJsonList to handle empty Lua JSON lists being sent as empty objects
- fix exporting of resources and entities
- split up map tiles into different layer directories
- add 'chunk size' to MapChunkPosition
- move tests to correct packages
- bump tstl
- decrease tstl logging
- remove some defined, but unused, kafka topics
- syslog, rest, websocket servers & web-map: decrease logging
- webmap: add additional layers for buildings and resources
- refactor and move queue & emitter classes for consistency
- don't emit all prototypes at once
- add simple queue for 'instant' packets so the printer doesn't get overwhelmed and mix up the output