Data.lua in scenarios

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

SamSam
Inserter
Inserter
Posts: 32
Joined: Fri Jul 10, 2015 2:02 am
Contact:

Data.lua in scenarios

Post by SamSam »

Even if it only allowed GUI styles or technologies and disallowed entities, having data.lua functional in scenarios would be quite useful in some cases. Maybe you want to restrict this to mods only, but it seems to me like adding limitations is usually not a good thing. Maybe there's a reason due to the way scenarios are loaded, in which case i understand if it is too complex or bad for performance to change the behaviour.
Thank you :D
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Data.lua in scenarios

Post by ssilk »

Hm. I think you need to understand, that this is not possible yet.

The right way to do this is to define as many different GUI's as you need and exchange them "on the fly". :)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
SamSam
Inserter
Inserter
Posts: 32
Joined: Fri Jul 10, 2015 2:02 am
Contact:

Re: Data.lua in scenarios

Post by SamSam »

Is there a reason that this isn't possible? It works like this in a mod, and I'm just requesting that this behaviour is extended. Maybe I'm missing something here :?:
Rseding91
Factorio Staff
Factorio Staff
Posts: 14403
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Data.lua in scenarios

Post by Rseding91 »

SamSam wrote:Is there a reason that this isn't possible? It works like this in a mod, and I'm just requesting that this behaviour is extended. Maybe I'm missing something here :?:
Because all mods must be the same when joining a game. Because scenarios don't have prototype data they can be loaded runtime and as such don't require you install anything special to join a server with a custom scenario running.
If you want to get ahold of me I'm almost always on Discord.
SamSam
Inserter
Inserter
Posts: 32
Joined: Fri Jul 10, 2015 2:02 am
Contact:

Re: Data.lua in scenarios

Post by SamSam »

I think I get it, a mod's data.lua is run when the game is restarted?
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Data.lua in scenarios

Post by daniel34 »

SamSam wrote:I think I get it, a mod's data.lua is run when the game is restarted?
Yes. data.lua is only run when the game (the Factorio application/server) starts, during the mod loading phase. control.lua is run everytime you load a savegame or start a new game.

See also this: https://wiki.factorio.com/index.php?tit ... Flifetimes
When Factorio starts up, all data-related scripts are run in a shared lua interpreter to populate and modify a global variable named data which is used to define prototypes. First all mods' data.lua are called, then all mods' data-updates.lua, then finally all mods' data-final-fixes.lua. Note that this means there is no game session running (i.e. no global or game state) at the time data-related scripts are executed, and any changes to lua module state will be discarded, preventing them from affecting control.lua.
[...]
control.lua is used by mods to directly interact with a game session while the game is being played; it has access to game state and to global (see below). All mods' control.lua are sandboxed from each other by running them in separate interpreters that exist for the duration of a game session. Because control.lua is reloaded and re-run every time a new game session is started, you don't need to completely restart Factorio to notice changes made to control.lua; simply saving/loading or starting a new game is sufficient.
quick links: log file | graphical issues | wiki
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Data.lua in scenarios

Post by ssilk »

It's a repeated wish, that modders don't need to restart the whole game, if they just change small graphics.

Added to viewtopic.php?f=80&t=27805 Suggestion around Game-Internal Mods-Handling/Mods-Management
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Post Reply

Return to “Ideas and Suggestions”