diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..26a23b5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.lua text +*.json text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..803f700 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.* + +!.git* diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..aa1b92f --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,24 @@ +EvoGUI is released under the MIT license. Informally, this means you can +do basically whatever with it you like, as long as you leave this file intact. +The full legalese is below. + + +EvoGUI is Copyright (c) 2015 Octav "narc" Sandulescu + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..bc0773d --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +This is a [Factorio](http://www.factorio.com/) mod. It adds a small UI frame +that informs you of the current biter evolution level, as well as your play +time. + + +## License ## + +The source of **EvoGUI** is Copyright 2015 Octav "narc" Sandulescu. It +is licensed under the [MIT license][mit], available in this package in the file +[LICENSE.md](LICENSE.md). + +[mit]: http://opensource.org/licenses/mit-license.html + + +## Statistics ## + +20 exceptions were caught during the creation of this mod. diff --git a/control.lua b/control.lua new file mode 100644 index 0000000..3fac379 --- /dev/null +++ b/control.lua @@ -0,0 +1,13 @@ +require "defines" +require "evoGUI" + +local function log(message) + for i, p in ipairs(game.players) do + p.print(message) + end +end + +game.on_event(defines.events.on_tick, function(event) + local status, err = pcall(evogui.update_gui) + if err then log(string.format("[evoGUI] Error: %s", err)) end +end) diff --git a/evoGUI.lua b/evoGUI.lua new file mode 100644 index 0000000..d085395 --- /dev/null +++ b/evoGUI.lua @@ -0,0 +1,25 @@ +require "defines" + +if not evogui then evogui = {} end +evogui.previous = -1 + +local function update_gui() + local run_time_seconds = math.floor(game.tick/60) + local run_time_minutes = math.floor(run_time_seconds/60) + local run_time_hours = math.floor(run_time_minutes/60) + + if evogui.previous ~= run_time_seconds then + for i, player in ipairs(game.players) do + if player.gui.top.evoGUI == nil then + player.gui.top.add{type="frame", name="evoGUI", direction = "vertical"} + player.gui.top.evoGUI.add{type="label", name="evolution_factor"} + player.gui.top.evoGUI.add{type="label", name="run_time"} + end + player.gui.top.evoGUI.evolution_factor.caption = string.format("Biter evolution: %0.1f%%", game.evolution_factor * 100) + player.gui.top.evoGUI.run_time.caption = string.format("Play time: %d:%02d:%02d", run_time_hours, run_time_minutes, run_time_seconds) + end + evogui.previous = run_time_seconds + end +end + +evogui.update_gui = update_gui diff --git a/info.json b/info.json new file mode 100644 index 0000000..1a288ea --- /dev/null +++ b/info.json @@ -0,0 +1,10 @@ +{ + "name": "EvoGUI", + "version": "0.1.0", + "title": "Evolution Factor Indicator", + "author": "Octav \"narc\" Sandulescu", + "contact": "factorio-mods@narc.ro", + "homepage": "None right now", + "description": "Places an indicator on your UI telling you the current biter evolution factor (as a percentage). It also tells you how long you've been playing.", + "dependencies": ["base >= 0.12.0"] +}