commit 6708414db30bd54c3dd8d16ac0c5d258a07275c9 Author: Carlos Galindo Date: Fri Aug 4 10:30:11 2017 +0200 Initial commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b382a24 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2017 kauron + +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/control.lua b/control.lua new file mode 100644 index 0000000..9fcc1e6 --- /dev/null +++ b/control.lua @@ -0,0 +1,29 @@ +-- sends a train to its next station if its in automatic +function toNextStation(t) + local l = 0 + for _ in pairs(t.schedule.records) do l = l + 1 end + + if not t.manual_mode and l > 1 then + local s = t.schedule + s.current = math.fmod(s.current, l) + 1 + t.schedule = s + t.manual_mode = false + return true + end + return false +end + + +script.on_event("go-to-next-station", function(event) + local player = game.players[event.player_index] + -- 2 alternatives: player is mousing over train or inside a train. + if player.selected and player.selected.train then + if toNextStation(player.selected.train) then return end + end + + if player.vehicle and player.vehicle.train then + if toNextStation(player.vehicle.train) then return end + end +end) + + diff --git a/data.lua b/data.lua new file mode 100644 index 0000000..166acb0 --- /dev/null +++ b/data.lua @@ -0,0 +1,7 @@ +data:extend({ + { + type = "custom-input", + name = "go-to-next-station", + key_sequence = "SHIFT + N" + } +}) diff --git a/info.json b/info.json new file mode 100644 index 0000000..212da53 --- /dev/null +++ b/info.json @@ -0,0 +1,9 @@ +{ + "name": "next-station", + "version": "0.1.1", + "title": "Next Station", + "author": "kauron", + "description": "Adds a hotkey to send the trains to their next station. First check if the player is mousing over a train and then the train the player is riding.", + "factorio_version": "0.15", + "dependencies": ["base >= 0.15.32"] +} diff --git a/locale/en/next-station.cfg b/locale/en/next-station.cfg new file mode 100644 index 0000000..5a685ab --- /dev/null +++ b/locale/en/next-station.cfg @@ -0,0 +1,2 @@ +[controls] +go-to-next-station=Go to the next station