Created
March 3, 2016 02:38
-
-
Save Archomeda/445b2b812db27a405db7 to your computer and use it in GitHub Desktop.
Rocket Count Exporter - Factorio Mod
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
require "defines" | |
-- UNTESTED IN MULTIPLAYER | |
-- UNTESTED WITH ACTUAL ROCKET LAUNCHING | |
-- MINIMALLY TESTED WITH SAVE LOADING | |
-- In order to use this mod: | |
-- 1. Download all the files from this gist | |
-- 2. Create a new folder in your mods folder, called "RocketCountExporter_1.0.0" | |
-- 3. Place all the downloaded files in this folder | |
-- 4. Change the configuration to your likings | |
-- This should not break any saves, since it's just loading information and exporting to a file. | |
-- This means that you can just remove the mod if needed without any consequences other than the file not being updated anymore. | |
function update_count(players) | |
-- Define the file name here (the file will be made in %APPDATA%\Roaming\Factorio\script-output) | |
-- You can hook this up on your OBS or any other application that listens for file modifications | |
file_name = "rocket_count.txt" | |
-- The string format to use, where %d is the actual rocket count, if you just want the count, use "%d" only | |
string_format = "Rockets: %d / 9001" | |
-- Don't change anything below!! | |
rocket_count = 0 | |
for index, player in pairs(players) do | |
if player.gui.left.rocket_score.rocket_count ~= nil then | |
-- Hopefully this works, it might break if the game gets updated later, because this is using the current value in the GUI | |
rocket_count = player.gui.left.rocket_score.rocket_count.caption | |
end | |
end | |
game.write_file(file_name, string.format(string_format, rocket_count)) | |
end | |
script.on_init(function() | |
update_count(game.players) | |
end) | |
script.on_event(defines.events.on_rocket_launched, function(event) | |
update_count(event.rocket.force.players) | |
end) |
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
{ | |
"name": "RocketCountExporter", | |
"version": "1.0", | |
"title": "Rocket Count Exporter", | |
"author": "Archomeda", | |
"contact": "", | |
"homepage": "", | |
"description": "A simple mod that exports the rocket count to a separate file." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment