Page 1 of 1

Figuring out data.raw types

Posted: Sun Dec 06, 2020 11:32 pm
by boss8989
So im wondering if there is a easy way to find out the exact path/file names.

Like for example inserters are data.raw.inserter, is there somewhere that labels all of these?

I have looked at the data.raw page on the wiki but this doesnt seem to state the specific names, like the inserters are under quiet a few sub headings.

Re: Figuring out data.raw types

Posted: Mon Dec 07, 2020 12:24 am
by eradicator

Re: Figuring out data.raw types

Posted: Mon Dec 07, 2020 12:33 am
by boss8989
eradicator wrote: Mon Dec 07, 2020 12:24 am https://wiki.factorio.com/Data.raw
thanks but as I said in the post that doesnt specify the proper name, as the inserters actually come under several headers

Re: Figuring out data.raw types

Posted: Mon Dec 07, 2020 1:04 am
by eradicator
boss8989 wrote: Mon Dec 07, 2020 12:33 am as the inserters actually come under several headers
Uhm...no they don't? Each prototype is stored in a subtable that is named exactly by its respective prototype type. There are no exceptions.

Code: Select all

data.raw[type][name]
Maybe you should post a code example to better explain what you think you're seeing.

Re: Figuring out data.raw types

Posted: Mon Dec 07, 2020 1:17 am
by boss8989
eradicator wrote: Mon Dec 07, 2020 1:04 am
boss8989 wrote: Mon Dec 07, 2020 12:33 am as the inserters actually come under several headers
Uhm...no they don't? Each prototype is stored in a subtable that is named exactly by its respective prototype type. There are no exceptions.

Code: Select all

data.raw[type][name]
Maybe you should post a code example to better explain what you think you're seeing.
If I search for inserter on that page its under several headers, as in items, corpse, explosion.

edit, I ah think I see what you mean, you click on the link at the top and it will take you to the correct area on that page.

Still having some issues though, say for example the arithmetic combinator, if I write it as I see it in that page it does not work "data.raw.arithmeticcombinator["arithmetic-combinator"]"

Re: Figuring out data.raw types

Posted: Mon Dec 07, 2020 1:41 am
by eradicator
boss8989 wrote: Mon Dec 07, 2020 1:17 am If I search for inserter on that page its under several headers, as in items, corpse, explosion.
Well, each "building" in the game usually needs at least a recipe to craft it, and an item to place it and the actual building. And then a corpse when the building is destroyed etc.

boss8989 wrote: Mon Dec 07, 2020 1:17 am Still having some issues though, say for example the arithmetic combinator, if I write it as I see it in that page it does not work "data.raw.arithmeticcombinator["arithmetic-combinator"]"
You can't just leave out the dash...

Code: Select all

data.raw["arithmetic-combinator"]["arithmetic-combinator"]
If a class ("type") has only one actual prototype ("building") then that prototype usually has the same name as the type, but ofc other mods can add differently named ones.

Re: Figuring out data.raw types

Posted: Mon Dec 07, 2020 1:51 am
by boss8989
eradicator wrote: Mon Dec 07, 2020 1:41 am
boss8989 wrote: Mon Dec 07, 2020 1:17 am If I search for inserter on that page its under several headers, as in items, corpse, explosion.
Well, each "building" in the game usually needs at least a recipe to craft it, and an item to place it and the actual building. And then a corpse when the building is destroyed etc.

boss8989 wrote: Mon Dec 07, 2020 1:17 am Still having some issues though, say for example the arithmetic combinator, if I write it as I see it in that page it does not work "data.raw.arithmeticcombinator["arithmetic-combinator"]"
You can't just leave out the dash...

Code: Select all

data.raw["arithmetic-combinator"]["arithmetic-combinator"]
If a class ("type") has only one actual prototype ("building") then that prototype usually has the same name as the type, but ofc other mods can add differently named ones.
ok that makes sense thanks, the reason I left out the dash's is because the inserter does "data.raw.inserter["inserter"]

Re: Figuring out data.raw types

Posted: Mon Dec 07, 2020 2:37 am
by eradicator
boss8989 wrote: Mon Dec 07, 2020 1:51 am because the inserter does "data.raw.inserter["inserter"]
That's all really just syntactic sugar for

Code: Select all

data["raw"]["inserter"]["inserter"]
They're all just strings. Most lua tutorial should explain that.