[Solved]Export Game Event Data and Players to Log File again
[Solved]Export Game Event Data and Players to Log File again
Hi!
I'm posting this Log File related issue here, because it seems the obvious solution to write a mod (but I don't know how to do this yet) and also because I need help and I want more opinions on this.
In conjunction with a v.0.13.x dedicated multiplayer server, a friend of mine ran a Telegram (Messenger) Bot, which would post logins in the groupchat. As of 0.14.1, the Log File has changed, and Player Names are no longer in the server Log Files. Would be nice to hear some reasoning on this from the devs too!
The bot can also control initialization of the game and could take care about maintaining mods and saves.
In the interest of reviving the Bot's best features (announcing player joins [and deaths}) I want to create a mod that writes these events down to a specific file or server log.
Any example how this is done in Lua would be very appreciated!
I'm posting this Log File related issue here, because it seems the obvious solution to write a mod (but I don't know how to do this yet) and also because I need help and I want more opinions on this.
In conjunction with a v.0.13.x dedicated multiplayer server, a friend of mine ran a Telegram (Messenger) Bot, which would post logins in the groupchat. As of 0.14.1, the Log File has changed, and Player Names are no longer in the server Log Files. Would be nice to hear some reasoning on this from the devs too!
The bot can also control initialization of the game and could take care about maintaining mods and saves.
In the interest of reviving the Bot's best features (announcing player joins [and deaths}) I want to create a mod that writes these events down to a specific file or server log.
Any example how this is done in Lua would be very appreciated!
Last edited by Phoscur on Sun Jan 08, 2017 3:33 pm, edited 1 time in total.
Re: Export Game Event Data [and Player Names to Log File again]
I'd also very much like to know, so: bump
-
- Long Handed Inserter
- Posts: 71
- Joined: Mon Oct 17, 2016 10:33 am
- Contact:
Re: Export Game Event Data [and Player Names to Log File again]
Code: Select all
script.on_event(defines.events.on_player_joined_game, function(event)
game.write_file("joinlist", game.players[event.player_index].name.."\n", true, 0)
end)
Re: Export Game Event Data [and Player Names to Log File again]
Thank you Articulating!
These are the lines I was looking for. Now I only have to put them with some Factorio Mod Config and Bootstrapping.
Then I probably should publish them to have them easily distributed to the clients too.
Although I don't see why this code needs to run on the clients. Is it possible to only run this Mod on the server?
It would be like a GFX mod for clients, but for the server, as this is only output related.
Could we hack this directly into the server too?
These are the lines I was looking for. Now I only have to put them with some Factorio Mod Config and Bootstrapping.
Then I probably should publish them to have them easily distributed to the clients too.
Although I don't see why this code needs to run on the clients. Is it possible to only run this Mod on the server?
It would be like a GFX mod for clients, but for the server, as this is only output related.
Could we hack this directly into the server too?
Re: Export Game Event Data [and Player Names to Log File again]
You can add the code directly to savegames, just unzip a savegame and add it to the control.lua file, no mod required.Phoscur wrote:Then I probably should publish them to have them easily distributed to the clients too.
Although I don't see why this code needs to run on the clients. Is it possible to only run this Mod on the server?
It would be like a GFX mod for clients, but for the server, as this is only output related.
Could we hack this directly into the server too?
The code will still be run on all clients, but if the last argument (for_player) of the write_file function is set to 0 then it only writes the file on the server. The other clients won't even notice.
Re: Export Game Event Data [and Player Names to Log File again]
Brilliant daniel34! I'm going to test this asap. Having the next multiplayer session on tuesday
Re: [Solved]Export Game Event Data and Players to Log File again
I can confirm, the proposed codelines from Articulating work as expected!
Now player join, respawn and even rocket launch data is exported.
I tested this by killing myself ingame with a modified control.lua xD
There is an ingame message when a player is killed. Which would be the kill event to subscribe to, and how do I get the "killer" e.g. a Diesel Locomotive ?
Now player join, respawn and even rocket launch data is exported.
I tested this by killing myself ingame with a modified control.lua xD
There is an ingame message when a player is killed. Which would be the kill event to subscribe to, and how do I get the "killer" e.g. a Diesel Locomotive ?
-
- Long Handed Inserter
- Posts: 71
- Joined: Mon Oct 17, 2016 10:33 am
- Contact:
Re: [Solved]Export Game Event Data and Players to Log File again
It's being added in 0.15, until then you'll have to wait
Re: [Solved]Export Game Event Data and Players to Log File again
You can use on_player_died to log deaths. However what caused the death will have to wait until .15
Re: [Solved]Export Game Event Data and Players to Log File again
Great! And if I wanted to register players logging off, or dropping, which events would I subscribe to?
on_player_left_game?
on_player_left_game?
-
- Long Handed Inserter
- Posts: 71
- Joined: Mon Oct 17, 2016 10:33 am
- Contact:
Re: [Solved]Export Game Event Data and Players to Log File again
You can find the list of events here, in this case on_player_left_game is correct.Phoscur wrote:Great! And if I wanted to register players logging off, or dropping, which events would I subscribe to?
on_player_left_game?
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: [Solved]Export Game Event Data and Players to Log File again
FYI, if you want to very quickly log events without any coding, you can use Mooncat's "Creative Mode" mod - it has a set of options to display events in-game and also log them to disk for later review, etc. https://mods.factorio.com/mods/Mooncat/creative-mode
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.