Page 1 of 1

Console data:extend

Posted: Sat Feb 13, 2021 9:38 pm
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

Re: Console data:extend

Posted: Sat Feb 13, 2021 9:53 pm
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

Re: Console data:extend

Posted: Sat Feb 13, 2021 10:04 pm
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.

Re: Console data:extend

Posted: Sat Feb 13, 2021 10:05 pm
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

Re: Console data:extend

Posted: Sat Feb 13, 2021 10:08 pm
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.

Re: Console data:extend

Posted: Sun Feb 14, 2021 3:05 am
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.

Re: Console data:extend

Posted: Sun Feb 14, 2021 3:29 am
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.