Page 1 of 1

Friday Facts 262 Lua script access

Posted: Sat Sep 29, 2018 12:32 am
by Muppet9010
Does the script access change mean we can access a mods' "global" space from the in-game command line?
Allow accessing Lua scripts by __MOD-NAME__/script.lua style path, so you can reference the same Lua scripts from multiple scenarios in one mod.
Currently to access a variable or data structure in a mods' global from the command line I have to include a custom command in the mod to write out full data structures to log files for inspection. And then use hard-coded data updates in newer test mod versions to change/correct the data state.


I originally posted this in the thread linked from the FFF, but then saw that it was titled around the AI side.

Re: Friday Facts 262 Lua script access

Posted: Sat Sep 29, 2018 12:55 am
by Bilka
The snytax shown in the fff is used when requiring files, which you can't do in the console. This does what you are looking for though:
Rseding91 wrote: Wed Jun 27, 2018 7:58 pm Added support to run console commands in a specific mod context via: /c __mod-name__ *command*.

Re: Friday Facts 262 Lua script access

Posted: Sat Sep 29, 2018 12:59 am
by Muppet9010
Nice. I shall try to make no more data structure mistakes before 0.17 is released :P

Re: Friday Facts 262 Lua script access

Posted: Sat Sep 29, 2018 10:14 am
by eradicator
Bilka wrote: Sat Sep 29, 2018 12:55 am The snytax shown in the fff is used when requiring files, which you can't do in the console. This does what you are looking for though:
Rseding91 wrote: Wed Jun 27, 2018 7:58 pm Added support to run console commands in a specific mod context via: /c __mod-name__ *command*.
Wait...you can run arbitrary commands in arbitray other mods contexts? Does that set a magic flag somewhere? Because i don't want to debug stuff when people can randomly fuck up my globals :p.

Also can you confirm that the require __mod__/file.lua actually works limitless? I.e. things like factorio-stdlib now finally don't need to be copied for every single mod anymore? (because the example explicitly mentions scenarios requiring mods, not mods requiring mods.)

Re: Friday Facts 262 Lua script access

Posted: Sat Sep 29, 2018 3:24 pm
by Nexela
eradicator wrote: Sat Sep 29, 2018 10:14 am Also can you confirm that the require __mod__/file.lua actually works limitless? I.e. things like factorio-stdlib now finally don't need to be copied for every single mod anymore? (because the example explicitly mentions scenarios requiring mods, not mods requiring mods.)
Confirmed