Logging player joins

Arrange meetings with other people to play MP, announce your servers.
timothy_johnson
Burner Inserter
Burner Inserter
Posts: 16
Joined: Sat Aug 06, 2016 9:41 pm
Contact:

Logging player joins

Post by timothy_johnson »

I'm running a headless Linux server, and I want to write a script that will keep track of who joins the server. Where would I find that information? I only see chat information in the logs.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Logging player joins

Post by darkfrei »

timothy_johnson wrote:I'm running a headless Linux server, and I want to write a script that will keep track of who joins the server. Where would I find that information? I only see chat information in the logs.
You can add some mods to vanilla like scenario.
Please change what you need.
https://mods.factorio.com/mods/darkfrei/Build-Statistic
timothy_johnson
Burner Inserter
Burner Inserter
Posts: 16
Joined: Sat Aug 06, 2016 9:41 pm
Contact:

Re: Logging player joins

Post by timothy_johnson »

Okay, so it's a rewrite/add-on of the control.lua file. Hm. I know bash, I know python, but I don't know lua. I was hoping there was some way to do it without having to learn a new language. Thanks for the pointer, though. I'll look at it some more.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Logging player joins

Post by darkfrei »

timothy_johnson wrote:Okay, so it's a rewrite/add-on of the control.lua file. Hm. I know bash, I know python, but I don't know lua. I was hoping there was some way to do it without having to learn a new language. Thanks for the pointer, though. I'll look at it some more.
Learn Lua in 15 Minutes

And all events are here http://lua-api.factorio.com/latest/events.html
timothy_johnson
Burner Inserter
Burner Inserter
Posts: 16
Joined: Sat Aug 06, 2016 9:41 pm
Contact:

Re: Logging player joins

Post by timothy_johnson »

These links answer all my questions. You're my new favorite person.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Logging player joins

Post by Nexela »

https://www.youtube.com/watch?v=S4eNl1rA1Ns It says 1 hour but after 30 minutes you will know everything lua has to offer :)

It is a quick language to pick up.

basically in control.lua (of a mod or scenario file)

Code: Select all

script.on_event(defines.events.on_player_joined_game, function(event)
game.write_file("PlayerJoins.txt", game.players[event.player_index].name.."\n", true) --Create a file in script_output directory with the joined players name and a carriage return.  Append to file = true
end)
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Logging player joins

Post by darkfrei »

Timestamp http://lua-api.factorio.com/latest/LuaG ... cript.tick
"Save to" settings http://lua-api.factorio.com/latest/LuaG ... write_file
These links answer all my questions.
It was very difficult to start modding for me too. All tutorials are very old and can't explain what's going on in code.
Post Reply

Return to “Multiplayer”