Unexpected results with data.raw

Place to get help with not working mods / modding interface.
sinropa
Inserter
Inserter
Posts: 24
Joined: Sun Jun 09, 2019 12:36 am
Contact:

Unexpected results with data.raw

Post by sinropa »

Hello all!

I started work on a total conversion mod today, and I have to say I'm not off to a good start - ha!


So to get things up and running, I wrote a very trivial script to build a playground to dev in:

Code: Select all

--enable and remove mats from recipes
for k, v in pairs(data.raw.recipe) do

v.enabled = true
v.ingredients = {}

end
As you can see this simply iterates and blindly activates everything, or it should.

There are a few common recipes this doesn't hit.

So for example, this will unlock assembly machines 1 and 3 while 2 is missing. Console unlocking science brought an unmodified assembly 2 into the players crafting options.

So I'm looking for any possible cause that I am not hitting these items (at least not last, I suppose)

I am only running base beta and I've tried moving my script into data-final-fixes.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3717
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Unexpected results with data.raw

Post by DaveMcW »

Code: Select all

for k, v in pairs(data.raw.recipe) do
  v.enabled = true
  if v.normal then v.normal.enabled = true end
  if v.expensive then v.expensive.enabled = true end
  v.ingredients = {}
end
I agree this is a horrible design and poorly documented.
sinropa
Inserter
Inserter
Posts: 24
Joined: Sun Jun 09, 2019 12:36 am
Contact:

Re: Unexpected results with data.raw

Post by sinropa »

Interesting.

Thank you for your reply. Is there a better dump of the games structures available or should I expect to do my own export?

I will give this a go, and again thanks for your time fixing the sample
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Unexpected results with data.raw

Post by eradicator »

Code: Select all

/c game.player.force.research_all_technologies()
/c game.player.cheat_mode = true
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.
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: Unexpected results with data.raw

Post by Qon »

sinropa wrote: Sun Jun 09, 2019 3:40 am Is there a better dump of the games structures available or should I expect to do my own export?
There used to be one at the wiki for prototype definitions. You can still use that page of course. That's what you should use. It's just the raw dump that is missing from that page now.

All the info is also at https://github.com/wube/factorio-data (same info as in your Factorio directory). And it also has some comments and pages that are missing from the wiki. But it is the game files so it has comments but it isn't actual documentation of how to use it or what properties that are available but just were not set for the base games things.

If you want the entire thing as a searchable text file then I'll attach the dump that used to be available there for you. I'm using it because it's quick to search through in a text editor but it doesn't have any comments or documentation and you need to understand the structure to find the right things in it because it's a 200k lines document so you easily get way too many results from the wrong sections of the document. So

I would recommend that use the wiki primarily and the files in your Factorio/data directory (or the github, which can be easier to search through since it has Qonvenient multi-file search) if you want examples of how the base game defines the prototypes.
Attachments
factorio.0.17.12.raw.txt
(6.77 MiB) Downloaded 80 times
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Unexpected results with data.raw

Post by eradicator »

Qon wrote: Sun Jun 09, 2019 1:59 pm If you want the entire thing as a searchable text file then I'll attach the dump that used to be available there for you. I'm using it because it's quick to search through in a text editor
I highly recommend using a text editor that can search through multiple files at once (like Notepad++, etcpp). Once the data is "dumped" it no longer contains information of how it got created. I.e. you lose all information about functions used to create wire connections, barrel recipes, etcpp. And even simple things like "x = 2/32" being converted to "x = 0.625", losing the meaning of "two pixels" and becoming a mere number. Ofc there are usecases where you want exactly this, but most of the time the original files will have better readability.
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.
Bilka
Factorio Staff
Factorio Staff
Posts: 3310
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Unexpected results with data.raw

Post by Bilka »

Qon wrote: Sun Jun 09, 2019 1:59 pm
sinropa wrote: Sun Jun 09, 2019 3:40 am Is there a better dump of the games structures available or should I expect to do my own export?
There used to be one at the wiki for prototype definitions. You can still use that page of course. That's what you should use. It's just the raw dump that is missing from that page now.

If you want the entire thing as a searchable text file then I'll attach the dump that used to be available there for you.
Huh? There was never a data raw dump on that page. It has always been, and is still, linked on https://wiki.factorio.com/Data.raw.
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
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Unexpected results with data.raw

Post by eradicator »

Bilka wrote: Sun Jun 09, 2019 2:52 pm Huh? There was never a data raw dump on that page. It has always been, and is still, linked on https://wiki.factorio.com/Data.raw.

Code: Select all

filename = "C:/Program Files (x86)/Steam/steamapps/common/Factorio/data/core/
Huh? Why are there absolute paths in a data.raw dump?
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.
Bilka
Factorio Staff
Factorio Staff
Posts: 3310
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Unexpected results with data.raw

Post by Bilka »

eradicator wrote: Sun Jun 09, 2019 3:16 pm
Bilka wrote: Sun Jun 09, 2019 2:52 pm Huh? There was never a data raw dump on that page. It has always been, and is still, linked on https://wiki.factorio.com/Data.raw.

Code: Select all

filename = "C:/Program Files (x86)/Steam/steamapps/common/Factorio/data/core/
Huh? Why are there absolute paths in a data.raw dump?
Noise expressions. We had the same problem in the control stage, it was literally dumping full file paths into lua state. I'll look into getting it fixed, thank you for finding it.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: Unexpected results with data.raw

Post by Qon »

eradicator wrote: Sun Jun 09, 2019 2:20 pm I highly recommend using a text editor that can search through multiple files at once
I do. Sublime text 3. But it's Qonvenient to use the raw file if you know its structure. Obviously I would use the multifile search feature for anything that requires it :)
Bilka wrote: Sun Jun 09, 2019 2:52 pm Huh? There was never a data raw dump on that page. It has always been, and is still, linked on https://wiki.factorio.com/Data.raw.
I got Qonfused. :D
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
sinropa
Inserter
Inserter
Posts: 24
Joined: Sun Jun 09, 2019 12:36 am
Contact:

Re: Unexpected results with data.raw

Post by sinropa »

Yeah what I meant is that the online reference to data.raw did not mention the nested 'normal' and 'expensive' properties causing my loop to fail.

A complete dump, I would have seen that.
sinropa
Inserter
Inserter
Posts: 24
Joined: Sun Jun 09, 2019 12:36 am
Contact:

Re: Unexpected results with data.raw

Post by sinropa »

Oh and thanks for the text dump, that should help if I need to dig up any more oddities.

Since its a total conversion, I'll be stomping on everything anyway
Bilka
Factorio Staff
Factorio Staff
Posts: 3310
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Unexpected results with data.raw

Post by Bilka »

sinropa wrote: Sun Jun 09, 2019 10:04 pm Yeah what I meant is that the online reference to data.raw did not mention the nested 'normal' and 'expensive' properties causing my loop to fail.

A complete dump, I would have seen that.
What reference are you using?
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
sinropa
Inserter
Inserter
Posts: 24
Joined: Sun Jun 09, 2019 12:36 am
Contact:

Re: Unexpected results with data.raw

Post by sinropa »

In theory, normal and expensive should have been defined here, no?

https://lua-api.factorio.com/latest/Lua ... otype.html
Bilka
Factorio Staff
Factorio Staff
Posts: 3310
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Unexpected results with data.raw

Post by Bilka »

That's for runtime scripting. You should be looking at the data stage documentation for changing things in the data stage: https://wiki.factorio.com/Prototype/Recipe
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
sinropa
Inserter
Inserter
Posts: 24
Joined: Sun Jun 09, 2019 12:36 am
Contact:

Re: Unexpected results with data.raw

Post by sinropa »

Thanks for the info. Those pages should help.
sinropa
Inserter
Inserter
Posts: 24
Joined: Sun Jun 09, 2019 12:36 am
Contact:

Re: Unexpected results with data.raw

Post by sinropa »

Well I finally got a chance last night to spend a night in the factorio modding sandbox.

Just wanted to come back and thank you all again for getting me started.

I've posted a day 1 beta of the playground project I started to poke at the API. Maybe someone will find it interesting as it changes the game problem a bit.

https://mods.factorio.com/mod/Singistics
Post Reply

Return to “Modding help”