Page 1 of 1

LUA: Access the replay data stream?

Posted: Sat Apr 15, 2017 9:47 pm
by Plawerth
Is there a way for the lockstep replay data to be directly read via LUA?

This is regarding my in-game per-player grief/event logging concept. If there is no access, then I'm going to have to create my own way to log player events in memory..... which is just only going to duplicate what is already done in the replay logger. But oh well.

My Google searches are not turning up anything useful.

Re: LUA: Access the replay data stream?

Posted: Sat Apr 15, 2017 11:32 pm
by Plawerth
EDIT: Nevermind. I did some poking around at how the game works, and this does not look like it can work.

I will have to try to write my own event logger in LUA, hooking into every listener that appears halfway important.

Re: LUA: Access the replay data stream?

Posted: Mon Apr 17, 2017 1:10 pm
by pieppiep
You can try to reverse-engineer the savegame :)
It's just a zip archive with files in it.
Someone asked about the level.dat in this thread, viewtopic.php?t=8568&p=68027

I've looked a little in a savegame myself, in the level.dat is a (part of?) log of the console.
When I searched for 'command-ran' and go back 6 bytes I found a few block types.

00 01 : block type?
4 bytes : string length
x bytes : string containing 'command-ran'

02 02 : block type playername?
4 bytes : string length
x bytes : string containing the players name

00 02 : block type command typed?
4 bytes : string length
x bytes : string containing the command giving at console
22 bytes : I have no idea what this is

For as fas as I remember 'command-ran' was first, then the playername and last the command.
If the command was a command resulting in an error message that error message was first.

I didn't proceed any further because my interest was lost :)
I don't know what version factorio this was, but it can probably change each update if needed.

Re: LUA: Access the replay data stream?

Posted: Mon Apr 17, 2017 1:22 pm
by Rseding91
I can add support to output all inputs the game processes but there is a *lot* of information that could be output and knowing what format would be most useful to someone wanting to consume it would be very helpful.

All inputs contain the following data:
  • uint8_t action ID
  • uint32_t tick of action
  • uint16_t player index
  • payload *variant - tons of different combinations*