[0.18.18] Command triggered event without player_index

This subforum contains all the issues which we already resolved.
Jorn86
Long Handed Inserter
Long Handed Inserter
Posts: 70
Joined: Sun May 01, 2016 7:08 pm
Contact:

[0.18.18] Command triggered event without player_index

Post by Jorn86 »

I received a bug report for one of my mods, that seems to indicate a console command event was fired, without containing the player index. That field isn't optional according to the docs, so I thought it was good to mention it.

The offending line code in my mod (as mentioned in the stacktace, line 76) was something like

Code: Select all

commands.add_command("mycommand", { "mymod.command" }, function(event)
    // do stuff
    game.players[event.player_index].print({"my_mod.stuff_done"})
end)
The stack trace:

Code: Select all

215.907 Error MainLoop.cpp:1202: Exception at tick 107206793: Error while running
command "resetradars": radar-tech/control.lua:76: bad argument #3 of 3 to 'index' (string expected, got nil)
stack traceback:
[C]: in function '__index'
__radar-tech/control.lua:76: in function <radar-tech/control.lua:67>
215.907 Error ServerMultiplayerManager.cpp:90: MultiplayerManager failed: "Error while running command "resetradars
": radar-tech/control.lua:76: bad argument #3 of 3 to 'index' (string expected, got nil)
stack traceback:
[C]: in function '__index'
__radar-tech/control.lua:76: in function <radar-tech/control.lua:67>"
215.907 Info ServerMultiplayerManager.cpp:771: updateTick(107206793) changing state from(InGame) to(Failed)
215.907 Quitting: multiplayer error.
I have not been able to reproduce it myself, and fixed it by just doing game.print instead of printing only to the player. But I thought this interesting enough to post here.

PyroFire
Filter Inserter
Filter Inserter
Posts: 356
Joined: Tue Mar 08, 2016 8:18 am
Contact:

Re: [0.18.18] Command triggered event without player_index

Post by PyroFire »

that's the console.

Rseding91
Factorio Staff
Factorio Staff
Posts: 14150
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.18.18] Command triggered event without player_index

Post by Rseding91 »

Thanks for the report. I fixed the docs for the next release. It will be missing if called from the server console or rcon.
If you want to get ahold of me I'm almost always on Discord.

Jorn86
Long Handed Inserter
Long Handed Inserter
Posts: 70
Joined: Sun May 01, 2016 7:08 pm
Contact:

Re: [0.18.18] Command triggered event without player_index

Post by Jorn86 »

Thanks!

Post Reply

Return to “Resolved Problems and Bugs”