Req: Help needed to update Factorio Planner

Place to get help with not working mods / modding interface.
Post Reply
Ploppy
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Apr 05, 2017 6:17 pm
Contact:

Req: Help needed to update Factorio Planner

Post by Ploppy »

Hello,

I need help regarding https://factorio-planner.firebaseapp.com/

After much trouble regarding my decision to use external tools: https://www.reddit.com/r/factorio/comme ... _exporter/, I decided to create my own mod which will be as basic as possible to extract data from the game in an effort to avoid breaking changes in the future.

My mod currently extract the recipes via

Code: Select all

game.forces.player.recipes
I did not test yet but I expect to extract the expensive recipes by using the same command in a Marathon world.

I would like to know if it is possible to extract the crafting machines (including furnaces) in a similar way?

Thank you very much for you help.
Last edited by Ploppy on Sat Jan 20, 2018 6:58 pm, edited 2 times in total.

User avatar
Aprillion
Inserter
Inserter
Posts: 34
Joined: Sun Apr 16, 2017 10:43 am
Contact:

Re: Req: Help needed to update Factorio Planner

Post by Aprillion »

I was experimenting with JSON export from Factorio for a Recipe explorer - but there was no interest on 56555 so I didn't continue with it, I only have a console command, not a mod yet.

You can look at dump_json.lua which is parsing game.player.force.recipes (and technologies) to JSON (MIT license, feel free to modify and re-distribute).

If I continue, I will export the data directly as JS script instead of JSON, for easier inclusion in html - I would like to support arbitrary mod content, so local html file would be needed (not just published version on the web). Also more fine grained exception handling will be possible than the simple pcall(unwrap_userdata, node) (which was written before fix in 55680).

Please let me know if you would be interested in an interface from my (future) mod for accessing the recipe data - as Lua table, JSON string or as a JS const statement (as Lua string)?

Ploppy
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Apr 05, 2017 6:17 pm
Contact:

Re: Req: Help needed to update Factorio Planner

Post by Ploppy »

I'm confused, as I said, I have access to the recipes (I already parse & export them in JSON).
My question is, if possible, how can I access the crafting machines ?

User avatar
Aprillion
Inserter
Inserter
Posts: 34
Joined: Sun Apr 16, 2017 10:43 am
Contact:

Re: Req: Help needed to update Factorio Planner

Post by Aprillion »

Sorry, I misunderstood. I didn't get that far in coding, but I found crafting machine info in entity prototypes - LuaEntityPrototype.crafting_categories

e.g.:

Code: Select all

["assembling-machine-2"] = {
      crafting_categories = {
        "crafting",
        "advanced-crafting",
        "crafting-with-fluid"
      }, ...

["chemical-plant"] = {
      crafting_categories = {
        "chemistry"
      }, ...

["stone-furnace"] = {
      crafting_categories = {
        "smelting"
      }, ...

Ploppy
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Apr 05, 2017 6:17 pm
Contact:

Re: Req: Help needed to update Factorio Planner

Post by Ploppy »

I will probably try to make the code or even the mod that I created public.

Thank you very much help, I'm not familiar with Lua. What line of code did you use to access these prototypes?

User avatar
Aprillion
Inserter
Inserter
Posts: 34
Joined: Sun Apr 16, 2017 10:43 am
Contact:

Re: Req: Help needed to update Factorio Planner

Post by Aprillion »

As I said, no code yet, I only downloaded https://wiki.factorio.com/Data.raw for research. But I plan to work on it today evening (Prague time zone) if you feel like playing some Factorio before working on your mod :)

Ploppy
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Apr 05, 2017 6:17 pm
Contact:

Re: Req: Help needed to update Factorio Planner

Post by Ploppy »

Ok. All I need is some little help from another mod dev to tell me how to access the machine prototypes with some code, or someone to tell me that it is impossible.

Any help is appreciated.

User avatar
Aprillion
Inserter
Inserter
Posts: 34
Joined: Sun Apr 16, 2017 10:43 am
Contact:

Re: Req: Help needed to update Factorio Planner

Post by Aprillion »

turns out you just need to filter game.entity_prototypes table to extract items with non-nil crafting_categories property.

if it helps, this is how I modified my own lua script to do that:

https://github.com/Aprillion/recipe_exp ... d9b290fb09

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

Re: Req: Help needed to update Factorio Planner

Post by Bilka »

There's a java utility that should also make it possible to extract all the info, though I dont think that's quite what you want: https://github.com/demodude4u/Java-Fact ... ta-Wrapper
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Ploppy
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Apr 05, 2017 6:17 pm
Contact:

Re: Req: Help needed to update Factorio Planner

Post by Ploppy »

Thank you very much @Aprillion, that's exactly what I was looking for. I managed to extract all the crafting machines. Now it's time to re-code the way I load data into the app.

Thank you everyone for helping me.

Ploppy
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Apr 05, 2017 6:17 pm
Contact:

Re: Req: Help needed to update Factorio Planner

Post by Ploppy »

Quick update: Mod is finished as well as the app and github repo is ready.

Problem is: I can't upload the mod, every single time I get this error:
Error in the Title field - Field must be at least 1 character long.
Does anyone knows what's going on? Because there is no title field in the page, and if it is about the title field in the info.json of the mod it's not empty.

Ploppy
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Apr 05, 2017 6:17 pm
Contact:

Re: Req: Help needed to update Factorio Planner

Post by Ploppy »

It was probably a bug on the website, it now works again. Here is the mod https://mods.factorio.com/mod/factorio-data-exporter
Code available on Github: https://github.com/Ploppy3/factorio-data-exporter

Post Reply

Return to “Modding help”