LUA: Access the replay data stream?

Place to post guides, observations, things related to modding that are not mods themselves.
Plawerth
Fast Inserter
Fast Inserter
Posts: 120
Joined: Thu Mar 02, 2017 12:57 am
Contact:

LUA: Access the replay data stream?

Post 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.
Plawerth
Fast Inserter
Fast Inserter
Posts: 120
Joined: Thu Mar 02, 2017 12:57 am
Contact:

Re: LUA: Access the replay data stream?

Post 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.
Last edited by Plawerth on Sun Apr 16, 2017 6:29 am, edited 1 time in total.
pieppiep
Fast Inserter
Fast Inserter
Posts: 170
Joined: Mon Mar 14, 2016 8:52 am
Contact:

Re: LUA: Access the replay data stream?

Post 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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14911
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LUA: Access the replay data stream?

Post 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*
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Modding discussion”