Created
February 13, 2024 15:43
-
-
Save patio11/9efa3f810da5b9e04f74c43dc964a0ae to your computer and use it in GitHub Desktop.
Monkeypatching Factorio mods for compatibility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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