Console data:extend

Place to get help with not working mods / modding interface.
Post Reply
blazespinnaker
Filter Inserter
Filter Inserter
Posts: 665
Joined: Wed Sep 16, 2020 12:45 pm
Contact:

Console data:extend

Post by blazespinnaker »

Is it possible to add a prototype via console? Eg, want to add a custom input.

calling data:extend just says there is no data global, but perhaps there is another, even if hacky way to do this.

It'd be nice to do through console so I can share /c snippets with others without having them to go through the modding hoops.

eg: https://wiki.factorio.com/Console
OptimaUPS Mod, pm for info.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Console data:extend

Post by DaveMcW »

No, the data table is destroyed after the game starts. You can't create prototypes from the console.

The console only supports stuff you can do in control.lua, which is documented here: https://lua-api.factorio.com/latest

blazespinnaker
Filter Inserter
Filter Inserter
Posts: 665
Joined: Wed Sep 16, 2020 12:45 pm
Contact:

Re: Console data:extend

Post by blazespinnaker »

The data table is destroyed? Not copied or cloned? I guess private variables are private.

Shame. I don't really want to publish mods, but I don't mind sharing code.
Last edited by blazespinnaker on Sat Feb 13, 2021 10:07 pm, edited 1 time in total.
OptimaUPS Mod, pm for info.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Console data:extend

Post by darkfrei »

blazespinnaker wrote:
Sat Feb 13, 2021 10:04 pm
The data table is destroyed? Curious how you know that. Any links / code describing that process?
https://lua-api.factorio.com/latest/Data-Lifecycle.html

blazespinnaker
Filter Inserter
Filter Inserter
Posts: 665
Joined: Wed Sep 16, 2020 12:45 pm
Contact:

Re: Console data:extend

Post by blazespinnaker »

darkfrei wrote:
Sat Feb 13, 2021 10:05 pm
blazespinnaker wrote:
Sat Feb 13, 2021 10:04 pm
The data table is destroyed? Curious how you know that. Any links / code describing that process?
https://lua-api.factorio.com/latest/Data-Lifecycle.html
Yeah, I had read that, but I didn't really interpret that being the data table being destroyed. I would have assumed it would have at least been cloned somewhere.
OptimaUPS Mod, pm for info.

Trific
Fast Inserter
Fast Inserter
Posts: 146
Joined: Thu Dec 31, 2020 7:57 pm
Contact:

Re: Console data:extend

Post by Trific »

blazespinnaker wrote:
Sat Feb 13, 2021 10:08 pm
Yeah, I had read that, but I didn't really interpret that being the data table being destroyed. I would have assumed it would have at least been cloned somewhere.
I'm sure it has been, but for the C++ code. No longer needs to exist in Lua.

blazespinnaker
Filter Inserter
Filter Inserter
Posts: 665
Joined: Wed Sep 16, 2020 12:45 pm
Contact:

Re: Console data:extend

Post by blazespinnaker »

Perhaps, though you could theoretically say that about a lot of the datastructures.

One issue I realize now on further reading is desync. Looks like a lot of obvious apis are missing as they would cause issues in MP, though I imagine custom input would be OK.
OptimaUPS Mod, pm for info.

Post Reply

Return to “Modding help”