Refactor some of the Guis from the legacy plugin (#399)
* Fix bugs in core and add default args to Gui defs * Refactor production Gui * Refactor landfill blueprint button * Fix more bugs in core * Consistent naming of new guis * Refactor module inserter gui * Refactor surveillance gui * Add shorthand for data from arguments * Make element names consistent * Add types * Change how table rows work * Refactor player stats gui * Refactor quick actions gui * Refactor research milestones gui * Refactor player bonus gui * Refactor science production gui * Refactor autofill gui * Cleanup use of aligned flow * Rename "Gui.element" to "Gui.define" * Rename Gui types * Rename property_from_arg * Add guide for making guis * Add full reference document * Add condensed reference * Apply style guide to refactored guis * Bug fixes
This commit is contained in:
@@ -6,34 +6,34 @@ local Commands = require("modules/exp_commands")
|
||||
local format_player_name = Commands.format_player_name_locale
|
||||
local format_number = require("util").format_number
|
||||
|
||||
--- @class Command.Trains
|
||||
local module = {}
|
||||
|
||||
function module.manual(player, surface, force)
|
||||
local trains = game.train_manager.get_trains{
|
||||
stock = "locomotive",
|
||||
has_passenger = false,
|
||||
is_manual = true,
|
||||
is_moving = false,
|
||||
surface = surface,
|
||||
force = force,
|
||||
}
|
||||
|
||||
for _, train in ipairs(trains) do
|
||||
train.manual_mode = false
|
||||
end
|
||||
|
||||
game.print{ "exp-commands_trains.response", format_player_name(player), format_number(#trains, false) }
|
||||
end
|
||||
--- @class ExpCommand_Trains.commands
|
||||
local commands = {}
|
||||
|
||||
--- Set all trains to automatic
|
||||
Commands.new("set-trains-to-automatic", { "exp-commands_trains.description" })
|
||||
--- @class ExpCommand_Artillery.commands.artillery: ExpCommand
|
||||
--- @overload fun(player: LuaPlayer, surface: LuaSurface?, force: LuaForce?)
|
||||
commands.set_trains_to_automatic = Commands.new("set-trains-to-automatic", { "exp-commands_trains.description" })
|
||||
:optional("surface", { "exp-commands_trains.arg-surface" }, Commands.types.surface)
|
||||
:optional("force", { "exp-commands_trains.arg-force" }, Commands.types.force)
|
||||
:register(function(player, surface, force)
|
||||
--- @cast surface LuaSurface?
|
||||
--- @cast force LuaForce?
|
||||
module.manual(player, surface, force)
|
||||
end)
|
||||
local trains = game.train_manager.get_trains{
|
||||
stock = "locomotive",
|
||||
has_passenger = false,
|
||||
is_manual = true,
|
||||
is_moving = false,
|
||||
surface = surface,
|
||||
force = force,
|
||||
}
|
||||
|
||||
return module
|
||||
for _, train in ipairs(trains) do
|
||||
train.manual_mode = false
|
||||
end
|
||||
|
||||
game.print{ "exp-commands_trains.response", format_player_name(player), format_number(#trains, false) }
|
||||
end) --[[ @as any ]]
|
||||
|
||||
return {
|
||||
commands = commands,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user