Hi all,
I'd like a script to be able to know what save its world came from. I can't seem to find anything relevant.
Ideally I'd find it in game.savename or something similar.
Any ideas?
thanks
Can a script know the filename of its save?
Re: Can a script know the filename of its save?
This is not possible to access because it is not a deterministic value. Mods have to be deterministic, so they may not have access to non-deterministic values.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: Can a script know the filename of its save?
Your reality apparently contains insufficient hamster actuator power. This function from LuaGameScript (game) also disagrees with your statement.Bilka wrote:This is not possible to access because it is not a deterministic value. Mods have to be deterministic, so they may not have access to non-deterministic values.
server_save(name)
Instruct the server to save the map.
Parameters
name :: string (optional): Save name. If not specified, writes into the currently-running save.
I'd actually like to know where this name comes from then... so I can give it to my lua script.
Re: Can a script know the filename of its save?
The name comes from you. You can rename a save, but you cannot determine its original name.adamius wrote:I'd actually like to know where this name comes from then... so I can give it to my lua script.
Re: Can a script know the filename of its save?
That is why I posted this in the Modding interface requests forum. I have a mod that would make use of this information yet it is currently not available for a mod to use. And it was passed in from command line so it’s value as passed in is absolutely deterministic.DaveMcW wrote:The name comes from you. You can rename a save, but you cannot determine its original name.adamius wrote:I'd actually like to know where this name comes from then... so I can give it to my lua script.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Can a script know the filename of its save?
Anyone who joins a server loads the game from an auto-generated savegame made in the exact moment they try to join. So the "original" savegame name would have to be explicitly synced to the client afterwards to be deterministic.
Also requests are much more likely to be implemented if you properly explain what you need them for :P.
Also requests are much more likely to be implemented if you properly explain what you need them for :P.
Re: Can a script know the filename of its save?
The “what” is in the title of the post. The “how” is up to the devs. I could suggest that this be implemented such that when a save is created its filename is embedded inside the file when the file is saved. Obviously you wouldn’t write the temp filename when syncing to multiplayer clients due to determinism. The “why” is simple enough, I’d like a mod to be able to draw the filename on the world surface for identification purposes and to do that I simply need the filename of the zip file as it was passed to the headless server command line. The server obviously knows this filename at load time and it will use it to save its local copy. And the server knew this filename when it last saved it. The client copy would also be able to read this value as it gets a copy of the dynamically generated file from the server. In single player mode no desync is possible.eradicator wrote:Anyone who joins a server loads the game from an auto-generated savegame made in the exact moment they try to join. So the "original" savegame name would have to be explicitly synced to the client afterwards to be deterministic.
Also requests are much more likely to be implemented if you properly explain what you need them for .
For clarification, which part of “Can a script know the filename of its save?” is unclear?
Eg if the save file was called myworld.zip, then the script inside a mod could access game.savename to get it.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Can a script know the filename of its save?
Apparently i erroneously wrote "what" instead of "why". This was missing.adamius wrote:The “why” is simple enough, I’d like a mod to be able to draw the filename on the world surface for identification purposes
The "what" part was just fine.adamius wrote:For clarification, which part of “Can a script know the filename of its save?” is unclear?