1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-03 14:53:01 +02:00

Merge pull request #1215 from grilledham/fix-commands-from-server

Fix commands not working when run from the server console.
This commit is contained in:
grilledham 2021-05-20 20:53:53 +01:00 committed by GitHub
commit 6e81c72741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -149,7 +149,13 @@ function Command.add(command_name, options, callback)
help_text,
function(command)
local print -- custom print reference in case no player is present
local player = game.get_player(command.player_index)
local player_index = command.player_index
local player = nil
if player_index ~= nil and player_index ~= 0 then
player = game.get_player(player_index)
end
local player_name = player and player.valid and player.name or '<server>'
if not player or not player.valid then
print = log