Friday Facts 262 Lua script access

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
User avatar
Muppet9010
Filter Inserter
Filter Inserter
Posts: 278
Joined: Sat Dec 09, 2017 6:01 pm
Contact:

Friday Facts 262 Lua script access

Post 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.

Bilka
Factorio Staff
Factorio Staff
Posts: 3132
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Friday Facts 262 Lua script access

Post 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*.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
Muppet9010
Filter Inserter
Filter Inserter
Posts: 278
Joined: Sat Dec 09, 2017 6:01 pm
Contact:

Re: Friday Facts 262 Lua script access

Post by Muppet9010 »

Nice. I shall try to make no more data structure mistakes before 0.17 is released :P

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Friday Facts 262 Lua script access

Post 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.)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Friday Facts 262 Lua script access

Post 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

Post Reply

Return to “Modding discussion”