Files
factorio-scenario-ExpCluster/exp_legacy/module/modules/commands/train.lua
2024-11-19 22:29:35 +00:00

24 lines
836 B
Lua

--[[-- Commands Module - Set Automatic Train
- Adds a command that set all train back to automatic
@commands Set Automatic Train
]]
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
require("modules.exp_legacy.config.expcore.command_general_parse")
local format_number = require("util").format_number
Commands.new_command("set-trains-to-automatic", { "expcom-train.description" }, "Set All Trains to Automatic")
:register(function(player)
local count = 0
for _, v in pairs(player.force.get_trains()) do
if v.manual_mode then
count = count + 1
v.manual_mode = false
end
end
game.print{ "expcom-train.manual-result", player.name, format_number(count) }
return Commands.success
end)