Skip to content

Instantly share code, notes, and snippets.

@patio11
Created February 13, 2024 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patio11/9efa3f810da5b9e04f74c43dc964a0ae to your computer and use it in GitHub Desktop.
Save patio11/9efa3f810da5b9e04f74c43dc964a0ae to your computer and use it in GitHub Desktop.
Monkeypatching Factorio mods for compatibility
-- Thanks to ChatGPT for improving my lua ability
local player = game.player
local surface = player.surface
local sprite_names = {'SNTD-nixie-tube-small-sprite', 'SNTD-nixie-tube-sprite'}
local all_nixie_sprites = surface.find_entities_filtered{name=sprite_names}
local known_sprites = {}
for nixie_id, sprite_array in pairs(global.SNTD_nixieSprites) do
for _, sprite in ipairs(sprite_array) do
known_sprites[sprite.unit_number] = true
end
end
local unknown_sprites = {}
for _, sprite in pairs(all_nixie_sprites) do
if not known_sprites[sprite.unit_number] then
table.insert(unknown_sprites, sprite)
end
end
player.print("We have this many known nixie sprites: " .. tostring(table.getn(known_sprites)))
player.print("We have this many unknown nixie sprites: " .. tostring(table.getn(unknown_sprites)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment