Repository navigation
Update luacheck to Factorio 2.1.24 - #1673
Conversation
The list predated 2.1: it was missing 820 values, so luacheck flagged valid code (build_check_type.manual_ghost), and kept 109 that 2.1 removed, so it let them through. It's now generated from 2.1.24's runtime API. The difficulty settings presets used defines.difficulty_settings, gone since 2.0 along with expensive recipes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Optional suggestion: That python script you used. Maybe we should stick that in the docs folder with some explanation for how to use. Also convert it to pwsh to match what we use in the CI actions? |
There was a problem hiding this comment.
Need to update this Factorio version
There was a problem hiding this comment.
Done in 38128ae: it says 2.1.24 now, and luacheck-api.ps1 keeps it in step with the API it generates from.
| }, | ||
| } | ||
|
|
||
| stds.factorio_control = { |
There was a problem hiding this comment.
Done in 38128ae. The whole control stage block (game, script, prototypes, rendering, helpers, settings, commands, remote, rcon) is now generated from the 2.1.24 runtime API, like defines. It drops the 80 pre-2.0 rendering functions and game.get_filtered_entity_prototypes, help, desync_players... and adds 31 that were missing (prototypes.recipe, prototypes.mod_data, game.create_inventory...). script.on_event/on_init/on_load/on_nth_tick/generate_event_name/set_event_filter and commands.add_command stay out on purpose, so code goes through Event and Command.add.
.github/scripts/luacheck-api.ps1 regenerates the game, script, prototypes, rendering, helpers, settings, commands, remote and rcon globals and the defines in .luacheckrc from a Factorio runtime-api.json, and the version comment. The control globals were from 1.1: they still had rendering's 80 pre-2.0 functions and game.get_filtered_entity_prototypes, help..., and lacked prototypes.recipe, prototypes.mod_data, game.create_inventory... docs/LUACHECK.md says how to run it and what it leaves out on purpose. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Good idea, done in 38128ae: the script is now |
luacheck only knows the Factorio API listed in
.luacheckrc, and that list predates Factorio 2.1. Itsdefineswere missing 820 values, so luacheck flagged valid code as "accessing undefined field" (defines.build_check_type.manual_ghost, most of the 2.x events, input actions and prototype types), and still had 109 that 2.1 no longer has (defines.time,circuit_connector_id,circuit_condition_index,difficulty_settings,build_check_type.ghost_place...), so it let code using them through, though they're nil in game. The control stage globals (game,script,rendering,prototypes...) were from 1.1: they still had rendering's 80 pre-2.0 functions (rendering.destroy,get_*/set_*) andgame.get_filtered_entity_prototypes,help,desync_players,styles..., and lacked 31 fields, among themprototypes.recipe,prototypes.mod_data,game.create_inventoryandscript.get_event_name.Change
.github/scripts/luacheck-api.ps1(new): regenerates the parts of.luacheckrcthat come from the runtime API that Factorio publishes for each version (https://lua-api.factorio.com/2.1.24/runtime-api.json): the control stage globalsgame,script,prototypes,rendering,helpers,settings,commands,remoteandrconwith their methods and attributes, and every define. They sit between-- luacheck-api.ps1: begin/end <part>lines; the script rewrites those and the-- Current Factorio Versionline and leaves the rest of the file alone..luacheckrc: both parts generated from 2.1.24. luacheck now flags a field the API doesn't have, writing to a global object (game = nil) and writing a read-only attribute (game.tick = 0). Attributes holding an object or a table (game.forces,settings.global) stay writable, sogame.forces.player.manual_mining_speed_modifier = 1passes (luacheck can't make a field read only but its contents writable). As before,script.on_event,on_init,on_load,on_nth_tick,generate_event_name,set_event_filterandcommands.add_commandare left out, so RedMew code goes throughEventandCommand.add.docs/LUACHECK.md(new): what is generated, what is left out on purpose and why, and how to update it for a new Factorio version.AGENTS.mdpoints to it.resources/difficulty_settings.lua: the only code the new defines flag. Itsdefaultandexpensive_recipepresets useddefines.difficulty_settings, which went in 2.0 with expensive recipes.defaultnow holds 2.1's two difficulty settings,technology_price_multiplierandspoil_time_modifier, andexpensive_recipegoes. Nothing requires the file (it's the example inredmew_surface.lua's comment), so no map changes.redmew_surface.lua's comment says what difficulty settings hold in 2.1.Tests
luacheck .: 0 warnings / 0 errors.rendering.destroy,game.write_file,game.get_filtered_entity_prototypes,game.tick = 0,helpers.stage = ...,script.on_event,script.generate_event_name,script.set_event_filterandcommands.add_command, and passesprototypes.recipe[...],game.forces.player.x = 1,settings.global[...] = {...},game.speed = 2anddefines.build_check_type.manual_ghost.definesoutput is byte for byte the list the first commit made with a Python script, and running it again changes nothing.Updating for a later Factorio version
What luacheck flags afterwards is code using API the new version removed or renamed.
🤖 Generated with Claude Code