This file contains info for setting up and contributing to this project.
We usen
- TypescriptToLua
- typed-factorio for type definitions
- vscode-factoriomod-debug for development
- Factorio test for testing
- gb-tstl-utils for some compiler-assisted utilities
Fork/clone this repo. Open this project in vscode, and install the vscode extension Factorio Mod Debug.
Checkout the main
branch:
git checkout main
Run npm install
to install dependencies.
Run npm run test
once. This will run some build scripts and other setup for development.
- On windows, you may need to enable developer mode to create symlinks.
Run npm run watch
to watch for changes.
Launch the Test run
vscode launch configuration or Test debug
, which is slower but allows debugging.
Tests will automatically re-run each time the project is rebuilt.
This rerun mechanism works using a combination of the tstlPlugin and logic in
src/test/test-init.ts
.
Files that end in .test.ts
are considered tests, and will be run by factorio-test
.
These are currently located in src/test
or src/lib/test
.
This project strives to have as high test coverage as possible.
These scripts are used to generate some files:
build:locale
: generateds alocale.d.ts
fromsrc/locale
. There is alsowatch:locale
script for this.build:gui-specs
: Used for the factoriojsx framework (seesrc/lib/factoriojsx
).build:tstlPlugin
: Builds the TSTL plugin which facilitates "storing" functions in global (in a consistent way). Seesrc/lib/references.ts
to see how this is done.
If you edit the corresponding files, you may need to re-run these scripts.
The functionality provided by these scripts may become a separate project in the future.
Although this project is written in Typescript, the eventual output is Lua. As such, we do the following:
- This uses gb-tstl-utils; see there for more info.
- Use
==
instead of===
, and!=
instead of!==
. There is no difference in Lua, and double equals is easier to read. - Use
nil
as a shorthand for, and instead ofundefined
. Don't usenull
.