Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua file scraper (for mods) #72

Closed
dcbroad3 opened this issue May 14, 2020 · 77 comments · Fixed by #163
Closed

Lua file scraper (for mods) #72

dcbroad3 opened this issue May 14, 2020 · 77 comments · Fixed by #163
Labels
mods Related to mod support
Projects
Milestone

Comments

@dcbroad3
Copy link
Collaborator

Need to build a utility that scrapes the Lua game data and builds it into the JSON format this app expects. This would be the first step towards supporting mods.

@dcbroad3
Copy link
Collaborator Author

@dcbroad3 dcbroad3 changed the title Lua file scraper Lua file scraper (for mods) May 14, 2020
@hhrhhr
Copy link

hhrhhr commented May 14, 2020

I recently forked a calculator from KirkMcDonald, the goal was to rewrite all the code on Go in pure Lua. Result — https://bitbucket.org/hhrhhr/factorio-tools-lua

Since Lua 5.3 was used, some mods that actively use modified Lua 5.2 cannot be loaded yet (for example, angelsrefining_0.11.10). However, the rest of the mods are imported without problems, more precisely, they work the same way as in the original factorio-web-calc.

The developers shared the source code of modified Lua, so I can update this repository. I can also try to provide data.raw and a file with icons in the format you need.

@hhrhhr
Copy link

hhrhhr commented May 22, 2020

Here is the test result from vanilla. Obtained completely automatically from game files, the code for using most mods is almost ready. There are some rough edges (like displaying empty / full barrels), but all the data and values are correct.

In the near future I will publish the source code of the parser, but maybe there will already be some comments?

For my part, I want to note that the calculator really needs the ability to load external data (textures with sprites, a css file and, of course, a data file).

0-18-25

0-18-25_css.json.txt
0-18-25.json.txt

@hhrhhr
Copy link

hhrhhr commented May 23, 2020

P. S.

Аnd here I tried to "render" how sprites will be arranged using the sort order from the game.

0-18_inventory

@hhrhhr
Copy link

hhrhhr commented May 25, 2020

So, I represent a completely (almost) workable parser - https://bitbucket.org/hhrhhr/factorio-lab-tools

The downloads have a ready-made set of all the libraries in the archive (unfortunately, only for Windows x64). In fact, GNU/Linux requires Lua, lua-zzip, lua-gd, and several other modules in pure Lua.

After starting the utility, the following files will appear in the current directory:

  • 0-18.html, 0-18.css — demo page. rename css it to icons.scss (and delete the first few lines with demo ... classes)
  • 0-18.json, * 0-18.png — need to copy to the appropriate directories

There are several difficulties.

I don’t know yet how to use the available tools to “color” the icons of the barrels of liquids (now they are all the same).

I also had to forcibly remove the "burner-mining-drill", since it consumes coal, which it itself produces, which leads to a loop and an error. I don’t know yet, is this the result of incorrect export or a feature of Factorio Lab :)

I enclose ready-made files from 0.18.26. if everything is fine with them, it remains only to connect the processing of mods (in archives and unpacked).

icons.scss.txt
0-18.json.txt
0-18

@dcbroad3
Copy link
Collaborator Author

Thanks for your effort! I haven't had the time to work on this very much in the past few days, I'll check it out asap.
Calculations for burner mining drills are extremely complicated. You end up in a loop where you might be using the drills to produce coal but consume solid fuel, then if you're using coal liquefaction that also requires coal but also the added complexity of oil recipes. In Factorio Lab itself I don't allow using burner mining drills to produce raw ores, I only allow electric mining drills. This is generally ok (and the Kirk McDonald calculator has the same limitation) because it's extremely unusual to use burner mining drills at the stage you would be using a calculator like this.

@Rybadour
Copy link

Btw, if anyone is having trouble dealing with some of the more complicated mods feel free to reach out to me. I helped update Foreman to support the larger mods like Bobs. There a few things that are hard to anticipate...

Foreman: https://github.com/Rybadour/Foreman

@Rybadour
Copy link

So I've been kicking this idea in my head lately... Since there are now a few different tools that use item and recipe data from mods. We should try to focus all our attention on solidifying this scaper tool. One addition to that is instead of us parsing mods at runtime we could also ask mod owners to run this tool to generate a JSON file they publish along side the mod.

@dcbroad3
Copy link
Collaborator Author

@Rybadour, now you have me imagining a scenario where mods could even build-in an SVG representation of the icons as part of the JSON itself, rendering the sprite sheets unnecessary. And if there were a hosted repository of these mod JSON files, apps like Factorio Lab could run against those at runtime rather than requiring them to be built in. Imagine if mods.factorio.com had a public API that could return the types of items, recipes, and icons that the mods added.

@Rybadour
Copy link

Yes! Maybe we can ask the Factorio devs for this. It would save us a ton of effort...

@hhrhhr
Copy link

hhrhhr commented May 26, 2020

64px version from 0.18.27 ;)

icons.scss.txt
0-18

@hhrhhr
Copy link

hhrhhr commented May 26, 2020

@Rybadour,

we could also ask mod owners to run this tool to generate a JSON file they publish along side the mod.

Some mods have their own settings. For example, you can choose to use water in recipes or change the color of the ore to blue.

In this case, you need to ask the authors of the mods to generate all possible variants of their configurations, which will lead to a power-law increase in the number of these configurations depending on the number of settings...

Therefore, I believe that "parsing mods at runtime" is indispensable.

@Rybadour
Copy link

I mean if some items are conditional then that could be incorporated into the tool that generates these settings. Another mechanism could be to generate the 99% that are static and a separate file that describes the configurable 1% or the describes all that encompasses the 1% variants.

@dcbroad3
Copy link
Collaborator Author

@hhrhhr I think you are most likely correct, but obviously it'd be much nicer if we could handle mods at runtime instead of build time. In my opinion the best case is a hybrid where you have to use a tool like yours to generate files for your mod set, then you can load those into the app at runtime instead of build time. That's what I plan to work towards for now.

@dcbroad3 dcbroad3 added mods Related to mod support and removed community labels May 26, 2020
@dcbroad3 dcbroad3 added this to the 1.2 (Mods) milestone May 28, 2020
@dcbroad3 dcbroad3 added this to To do in 1.2 (Mods) May 29, 2020
@hhrhhr
Copy link

hhrhhr commented May 29, 2020

factorio_lab_tools_thumb

Big update. Added parser support for mods (so far only unpacked), icon painting (using tint), support for arbitrary scaling (48px, for example), the ability to disable mod loading or texture generation.

Examples (as on the top image) — https://hhrhhr.bitbucket.io/

Issue: tthe technology tree is not scanned; all possible recipes and products are displayed.

Sorry, but the endless technology and the new json file format are still at work ;) But the resulting data.raw almost perfectly matches what can be pulled out by the mod when loading the game. I saw the difference only in the 8-10th digit of numbers with double precision.

@dcbroad3
Copy link
Collaborator Author

Current planned strategy for mod support:

  • mods folder inside assets folder
  • Subfolder for each built in supported mod
  • Supported mods provide json with items, recipes, and icons for the mod, same basic schema as current json
  • When support is requested for a new or updated mod, new branch/fork is created by me or by community, and a tool like @hhrhhr 's is used to generate new files and tested for support
  • Provide a guide on how to build new files/support for mods
  • When ready, fork/branch is merged into master and deployed to live site
  • UI will provide options to enable/disable supported mods

Thoughts?

@Rybadour
Copy link

Sounds like you don't plan to read mods dynamically? Foreman has had great success reading the mods directly from the mod directory. The biggest mods only take several seconds to parse everything.

@dcbroad3
Copy link
Collaborator Author

I would love to but I don't see how it could be done. The browser doesn't have permission to directly read files from the local machine, and doesn't have lua language support. If you know of a way then I agree it would be far better to read dynamically.

@bbarry
Copy link
Contributor

bbarry commented May 31, 2020

I think you could load the json file via a request and then consider a setting that lets you provide a new json file. The json file would need to change slightly to contain a url to the sprite file but otherwise it should be able to load everything at runtime.

Obviously all the compile time dependencies to the json file would need to be removed (certainly non-trivial)...


Parsing the mods directly out of the mods directory is probably a step too far. I think that might actually be possible with file apis though some day? For now it is probably good enough to expect the mod data is available at a http get url which allows basic unauthenticated CORS requests with no additional headers (raw static json/image files at public urls).

@dcbroad3
Copy link
Collaborator Author

dcbroad3 commented Jun 1, 2020

Where would this mod data be hosted? As far as I know no mod data like this currently exists. If there were a public REST API for mods that'd be simple but I think we have to start at square one.

@bbarry
Copy link
Contributor

bbarry commented Jun 1, 2020

Github pages seems like a good enough place to me to host these files. Some of them could even be static assets in the https://factoriolab.github.io site published as part of the build.

Anybody who wants to load a mod could put a repo with a json file and image up and then put the url to the json file in a setting.

And you are correct it doesn't exist right now.

@dcbroad3
Copy link
Collaborator Author

dcbroad3 commented Jun 1, 2020

I think we are largely on the same track, then. The plan I outlined just exclusively has the files hosted inside factoriolab.github.io. In order to read from other sources either Factorio Lab would need to recognize those sources or there would need to be a way to specify external sources in the UI, which is feasible, just doesn't seem as user friendly.

@Rybadour
Copy link

Rybadour commented Jun 1, 2020

Ah sorry I misunderstood. I thought we were talking about a script the user runs on their computer to generate mod data as a JSON file. I guess that's one advantage Foreman has if we want to parse mods we simply find the mod directory and extract some zip files.

So FYI, working with Foreman has taught me mods are very complicated. For example, many of their Lua only work when they can import other mods they depend on. Some imports modules from core or base so those would have to be available as well.

@dcbroad3
Copy link
Collaborator Author

dcbroad3 commented Jun 1, 2020

I thought we were talking about a script the user runs on their computer to generate mod data as a JSON file.

To be fair, yes, that is what I'm talking about. However, I don't intend that every user has to do that, only if you are using a mod that is not yet supported. In that case the user would run a script, generate the files, and create a PR to merge them into the repository, and after that the next person that wants to use that mod should be able to use the built in files.

Using generated JSON at runtime should help us avoid Lua confusion. If we can generate the files, then we have a manual step to make sure they're valid, then they have to go through a PR before they're available for anyone to use, then the tool to generate the data files doesn't have to be 100% perfect.

Dependencies will be complicated to handle, if a recipe from one mod requires ingredients from another mod it will either have to automatically enable the other mod, or will have to be handled like wood where there is no recognized recipe for the item until the dependency mod is enabled as well.

@hhrhhr
Copy link

hhrhhr commented Jul 21, 2020

If the sources and compiler are exactly the same, then the difference can only be in the system dynamic library msvcrt.dll. Although I also have no idea what exactly this difference could be :((

@dcbroad3
Copy link
Collaborator Author

I'm not 100% sure what I did differently, but I got it working as expected this morning. A few things I cleaned up: I had to re-add the lcc directory to my PATH (apparently it was missing), I was able to rebuild using mass_make_tcc without any local modifications (previously I'd had to tweak floorf.c). Then, the export worked without modifying gd_image, so it's working using copyResampled!

Minor update: It seemed bad to me that your app had to include the time and empty module icons just to get my app to work. I've refactored so that those icons are provided directly by the app no matter what (as well as all the other icons that are explicitly used, mostly in the settings panel).

I'm going to try to see if I can build data for 0.16, 0.17, and 0.18 using your tool and include that in my latest branch. Main thing is that I want to get it to include the space-science-pack.

@hhrhhr
Copy link

hhrhhr commented Jul 23, 2020

After updating the def files for TCC, the hacks for floorf are no longer needed. It would be necessary to remove them altogether from the source, somehow I will do it.

About previous versions of the game. I don't remember exactly, but they used slightly different calculations for the speed and volume of conveyors and something else.

t.belt = belt and {speed = 480.0 * belt.speed}

It will be necessary to somehow determine the version of the game.

@dcbroad3
Copy link
Collaborator Author

they used slightly different calculations for the speed and volume of conveyors

That's true, I hadn't really considered that. I think that was true in 0.16 and hasn't been true since 0.17+ though, so a manual tweak to the numbers for belts in the 0.16 json shouldn't be a major issue, as long as it's not necessary to support a wide variety of 0.16 mods as well.

@dcbroad3
Copy link
Collaborator Author

@hhrhhr Thanks for all of your help so far, Factorio Lab now supports 0.16, 0.17, and 0.18 thanks to you!
I did attempt to take the next step and start to include mods, but it seems as though mods are not loaded by your tool? I went all in and tried Krastorio 2, it threw an error regarding a missing dependency, I ignored it and it rebuilt normal 0.18 base data. I tried doing the simplest possible and simply used base game with the waterfill mod, I no longer got any errors about missing dependencies, but it still didn't load the data from the mod. Do you expect it to work with mods yet?

@hhrhhr
Copy link

hhrhhr commented Jul 25, 2020

error regarding a missing dependency

This was easy ) https://bitbucket.org/hhrhhr/factorio-lab-tools/commits/b2ab43da649ea6b19670bb0c8cdde9447221b0c9

However, the problem remained. I expected that mods will use a call like require ("__mod_name__/...") only after this mod_name is initialized. However, Krastorio does this during its initialization, which results in an error. Now I decide what to do...

@hhrhhr
Copy link

hhrhhr commented Jul 25, 2020

Krastorio is now exported seemingly without errors (apart from those that are present in the game's log).
When processing images, ignore warnings like:
libpng warning: Interlace handling should be turned on when using png_read_image
This is due to the deprecated png-library in Adobe ImageReady that the author of the mod used.

p.s.
Or hide stderr output with 2>NUL at end of command line.

@dcbroad3
Copy link
Collaborator Author

So I synced with your changes and I still don't see any mod data generated when I run the tool. I tried again with both Waterfill and Krastorio 2, in both cases the output is the base 0.18 game data with no mods. With Krastorio 2:

C:\Git\factorio-lab-tools\lua_lab>..\dist53\bin\lua53 factorio_data_dump.lua --gamedir "%factorio%" --iconsize 64 --clear export
[INFO] mods settins loaded
[INFO] mods load order received
[INFO] load order applied
[INFO] core and data load...
[INFO] exporting data.raw...
[INFO] process all items... found 162 with type="item", 78 with other type
[INFO] process technologies... enabled 181 recipes
[INFO] process recipes... found 199 normal, 18 expensive, 15 hidden
[INFO] sort recipes...
[INFO]  found 82 ingridients and 195 products
[INFO] clear items...
[INFO] icon's canvas 16x15 (|xx| show number of layers)...
row   1 | 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1|
row   2 | 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1|
row   3 | 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1|
row   4 | 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1|
row   5 | 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1|
row   6 | 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1|
row   7 | 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 4|
row   8 | 4| 4| 4| 4| 4| 4| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1|
row   9 | 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1|
row  10 | 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1|
row  11 | 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1|
row  12 | 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1|
row  13 | 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1| 1|
row  14 | 1| 1| 3| 3| 3| 3| 3| 3| 3| 1| 1| 1| 1| 1| 1| 1|
row  15 | 1| 1| 1| 1|
[INFO]
all done

I do have some local tweaks to factorio_data_export.lua, but I tried reverting everything and running the scripts from your master branch against Krastorio 2, and I still don't get any mod data in the output.

Is it possible you tested against Krastorio and not Krastorio 2? I haven't tried with Krastorio since it's not compatible with 0.18.

@hhrhhr
Copy link

hhrhhr commented Jul 27, 2020

Only unpacked modifications are supported.

So, you need unpack Krastorio2_0.9.99.zip to mods directory or in any another directory ( in this case set option --moddir and copy mod-list.json and mod-settings.dat too).

...
[INFO] mods settins loaded
[INFO] mods load order received:
        core <- base <- Krastorio2
[INFO] load order applied
[INFO] core and data load...
[NOTE]  loaded core.dataloader
[NOTE]  loaded core.data
[NOTE]  loaded base.data
[NOTE]  loaded Krastorio2.data
[NOTE]  loaded base.data-updates
[NOTE]  loaded Krastorio2.data-updates
[LOG]   Krastorio 2|LogLevel:WARNING
[LOG]   From Krastorio 2->file:..._u/Krastorio2_0.9.99/lib/private/data-stages/recipes.lua->function:findNotUnlockableRecipes->line:1883
[LOG]   Called in->file:...anilla-changes/optional/modify-science-packs-recipes.lua->function:func->line:17
[LOG]   Message: 'This recipes are not unlockable, maybe is an error: { "uranium-rounds-magazine", "nuclear-fuel", "imersite-rounds-magazine" } [from findNotUnlockableRecipes()]'
[NOTE]  loaded Krastorio2.data-final-fixes
...

@dcbroad3
Copy link
Collaborator Author

Ohh, OK. Sorry I'm blundering around here, I will try that the next chance I get.

@dcbroad3
Copy link
Collaborator Author

I'm making fairly steady progress with the Krastorio 2 mod, largely the issues I've been encountering is for producers in Krastorio, there are multiple unexpected combinations of group and subgroup (smelting producers that are actually assembling machines, assembling machines that are actually furnaces). I'm currently stuck on item names, as it seems loc_name isn't filled in for many items (it's using the entity name instead of the item name, and entity name looks more like a coded id).

I think many of the recipes are also going to pose problems because there are many that, for example, output "0" of a "void product". But I haven't gotten to those yet.

If you have any ideas on that I'd love to hear it, otherwise I'll keep playing with it later.

@hhrhhr
Copy link

hhrhhr commented Jul 28, 2020

I've added fix to handle strings like __ITEM__kr-medium-container__: https://bitbucket.org/hhrhhr/factorio-lab-tools/commits/517679df3cbf69306b034ea095695df0c96150cb

Recipes with zero result, as I understand it, apply to some kind of machine that heats liquid. but I could not determine what these machines are. Can it be simple to exclude such "zero" recipes?

@hhrhhr
Copy link

hhrhhr commented Jul 28, 2020

Аdded a json based demo page for 0.18.36 + Krastorio2, I think it will be a little more clearer.

https://hhrhhr.bitbucket.io/factorio_lab_tools/0.18.36_krastorio2.html

p.s.
click on recipes icon for more info.

@dcbroad3
Copy link
Collaborator Author

That's pretty cool! Do you know what the deal is with the smelting-crafting category? Everything under that tab also appears under intermediate products, and when I ran the app, that tab ended up showing as empty (I don't currently support showing things in two tabs).

Would it make more sense for me to convert the "row" number field in the data to something like "subgroup", since that's a more direct correlation to what's in the data? I don't think it would be a major effort.

I haven't tried out your fixes for the __ITEM__kr-medium-container__ string names yet, but your demo page still seems to show the incorrect names.

I was also thinking it might be easiest to simply exclude the zero-result recipes. The end result is they show something like:

"out": {
  "kr-void": 0
}

It doesn't make any sense to me to include recipes like that.

@hhrhhr
Copy link

hhrhhr commented Jul 29, 2020

Recipes from group smelting-crafting shown in kr-advanced-assembling-machine (Advanced assembling machine):

smelting-crafting

And, judging by the recipe ID, these are different recipes from the point of view of the game. Using a "Iron beam" as an example (quoted from data.raw):

    ["kr-s-c-iron-beam"] = {
      type = "recipe",
      name = "kr-s-c-iron-beam",
      subgroup = "smelting-crafting",
      hide_from_player_crafting = true, -- <-- !!!
-- skipped
    },
-- skipped
    ["iron-beam"] = {
      type = "recipe",
      name = "iron-beam",
--      subgroup = "intermediate-product", -- get from "iron-beam" item
-- skipped
    },

Option hide_from_player_crafting control how the recipe is displayed (or not) in the player's inventory, but is not exported to a json file. I think it's worth adding this option to the json file and ignoring such a recipe when parsing. When completely ignore such recipes, then the ingredients (icons, names) from that recipes can be excluded from the general list of items.

I should probably try to fix the --factorio_lab_hacks option to disable the export of recipes with zero product and recipes exclusively for machines.

__ITEM__kr-medium-container__
oh, loaded an old version of the page. I will try to update soon.

@hhrhhr
Copy link

hhrhhr commented Jul 29, 2020

Now recipes with hide_from_player_crafting=true is skipped with --factorio_lab_hacks option. Example: https://hhrhhr.bitbucket.io/ (0.18.36 with Krastorio2 and 0.18.36 with Krastorio2 (--factorio_lab_hacks)).

something like "subgroup"...

subgroup for items also exported to json.

@dcbroad3
Copy link
Collaborator Author

Help me out here, it's still missing names for energy-shield-mk3-equipment and energy-shield-mk4-equipment, but as best I can tell, there are no localized names for those items inside the mod? At least, I can't find the names? I can fill them in manually but it seems odd to me.

@hhrhhr
Copy link

hhrhhr commented Jul 29, 2020

Yes, there is some weirdness with this equipment. Localised strings from game:

energy-shield-equipment=Shield generator
energy-shield-mk2-equipment=Shield generator MK2
energy-shield-mk3-equipment=Shield generator MK3
energy-shield-mk4-equipment=Shield generator MK4

But I get it:

energy-shield-equipment=Energy shield
energy-shield-mk2-equipment=Energy shield MK2
energy-shield-mk3-equipment=__ITEM__shield-generator-mk3__
energy-shield-mk4-equipment=__ITEM__shield-generator-mk4__

As I understand it, this is due to the fact that in the mod localized strings are described in the data.raw ["energy-shield-equipment"] section, and not in data.raw.recipe or data.raw.item, where the script looks for such strings.

I will think about how to determine the correct sequence for extracting localized strings.

@dcbroad3
Copy link
Collaborator Author

Thanks. It seems like it may have something to do with possibly changing the ids of those items as well, there are localized strings for shield-generator-mk1 through shield-generator-mk4, and I think that's essentially what the mod is wanting to call them, "Shield Generator" instead of "Energy Shield." I can't tell how it pulls that off but I think for now I'm manually just going to call them "Shield Generator MK1" thru "Shield Generator MK4".

@dcbroad3
Copy link
Collaborator Author

@hhrhhr are you able to build for Bob's & Angel's? I'm running into problems left and right. I had to copy mod-settings.dat, then ran into a problem in angelsaddons-cab_0.2.3\prototypes\entities\equipment.lua, then logs started to flood with errors after I hacked past that problem.

@hhrhhr
Copy link

hhrhhr commented Aug 14, 2020

angelsaddons-cab_0.2.3 only — no problem:

[INFO] mods load order received:
        core <- base <- angelsaddons-cab
[INFO] load order applied
[INFO] core and data load...
[NOTE]  loaded core.dataloader
[NOTE]  loaded core.data
[NOTE]  loaded base.data
[NOTE]  loaded angelsaddons-cab.data
[NOTE]  loaded base.data-updates
[NOTE]  loaded angelsaddons-cab.data-updates
[INFO] exporting data.raw...
[INFO] process all items... found 164 with type="item", 83 with other type
[INFO] process technologies... enabled 185 recipes
[INFO] process recipes... found 209 normal, 18 expensive, 9 hidden
[INFO] sort recipes...
[INFO]  found 91 ingridients and 199 products
[INFO] clear items...
[NOTE]  23 ingridients and 15 products left
...

Without a specific error log, it is difficult to identify the cause. There are no errors when using Lua with patches from Factorio developers. But the usual Lua 5.3 gives me this error:
..\dist\bin\lua53.exe: ...angelsaddons-cab_0.2.3/prototypes/entities/equipment.lua:31: bad argument #2 to 'format' (number has no integer representation)

I suppose this is because in Lua 5.3 by default all numbers are of type double, and the mod author is trying to format them as integers.

@dcbroad3
Copy link
Collaborator Author

Sorry, that's fair. The error you ran into I worked around by setting roundPresicion to 0 if it's nil before using it. The log I get is:

C:\Git\factorio-lab-tools\lua_lab>..\dist53\bin\lua53 factorio_data_dump.lua --gamedir "%factorio%" --iconsize 64 --clear --moddir mods export
[INFO] mods settins loaded
[INFO] mods load order received
[INFO] load order applied
[INFO] core and data load...
[LOG]   reset
[LOG]   stack traceback:
        mods/boblibrary_0.18.10/recipe-functions.lua:94: in field 'replace_ingredient'
        ...lates_0.18.9/prototypes/recipe/entity-recipe-updates.lua:19: in local 'func'
        factorio_data_dump.lua:251: in global 'require'
        mods/bobplates_0.18.9/data-updates.lua:1: in local 'func'
        factorio_data_dump.lua:251: in local '_require'
        factorio_data_dump.lua:528: in main chunk
        [C]: in ?
[LOG]   Recipe chemical-furnace does not exist.
[LOG]   stack traceback:
        mods/boblibrary_0.18.10/recipe-functions.lua:94: in field 'replace_ingredient'
        ...lates_0.18.9/prototypes/recipe/entity-recipe-updates.lua:35: in local 'func'
        factorio_data_dump.lua:251: in global 'require'
        mods/bobplates_0.18.9/data-updates.lua:1: in local 'func'
        factorio_data_dump.lua:251: in local '_require'
        factorio_data_dump.lua:528: in main chunk
        [C]: in ?
[LOG]   Recipe chemical-steel-furnace-from-steel-furnace does not exist.
[LOG]   stack traceback:
        mods/boblibrary_0.18.10/recipe-functions.lua:326: in field 'remove_result'
        ...lates_0.18.9/prototypes/recipe/entity-recipe-updates.lua:38: in local 'func'
        factorio_data_dump.lua:251: in global 'require'
        mods/bobplates_0.18.9/data-updates.lua:1: in local 'func'
        factorio_data_dump.lua:251: in local '_require'
        factorio_data_dump.lua:528: in main chunk
        [C]: in ?
[LOG]   Recipe steel-furnace-from-chemical-steel-furnace does not exist.
[LOG]   stack traceback:
        mods/boblibrary_0.18.10/recipe-functions.lua:265: in field 'add_result'
        ...lates_0.18.9/prototypes/recipe/entity-recipe-updates.lua:39: in local 'func'
        factorio_data_dump.lua:251: in global 'require'
        mods/bobplates_0.18.9/data-updates.lua:1: in local 'func'
        factorio_data_dump.lua:251: in local '_require'
        factorio_data_dump.lua:528: in main chunk
        [C]: in ?
[LOG]   Recipe steel-furnace-from-chemical-steel-furnace does not exist.
[LOG]   Running technology prerequisite cleanup...
[LOG]   Recipe 'fermentation-fruit' does not have a crafting_machine_tint set!
[LOG]   Recipe 'air-separation' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-glycerol' does not have a crafting_machine_tint set!
[LOG]   Recipe 'carbon-from-charcoal' does not have a crafting_machine_tint set!
[LOG]   Recipe 'petroleum-jelly' does not have a crafting_machine_tint set!
[LOG]   Recipe 'pellet-platinum-smelting' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-dinitrogen-tetroxide' does not have a crafting_machine_tint set!
[LOG]   Recipe 'geode-red-liquify' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-hydrazine' does not have a crafting_machine_tint set!
[LOG]   Recipe 'tungsten-ore-smelting' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-sulfur' does not have a crafting_machine_tint set!
[LOG]   Recipe 'paste-cellulose' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-toluene-from-benzene' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-acetate-mixture' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-sodium-hypochlorite' does not have a crafting_machine_tint set!
[LOG]   Recipe 'condensates-refining' does not have a crafting_machine_tint set!
[LOG]   Recipe 'algae-brown-burning-wash' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-aqueous-sodium-hydroxide' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-nitrogen-dioxide' does not have a crafting_machine_tint set!
[LOG]   Recipe 'bob-fertiliser' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-nitroglycerin' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-epichlorhydrin' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-sulfur-dioxide-calcium-sulfate' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-nitrogen-monoxide' does not have a crafting_machine_tint set!
[LOG]   Recipe 'angels-electrode-used' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-synthesis-methanol' does not have a crafting_machine_tint set!
[LOG]   Recipe 'crystal-dust-liquify' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-perchloric-acid' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-cupric-chloride-solution' does not have a crafting_machine_tint set!
[LOG]   Recipe 'angels-water-enrichment-2' does not have a crafting_machine_tint set!
[LOG]   Recipe 'sulfuric-nitric-acid' does not have a crafting_machine_tint set!
[LOG]   Recipe 'alien-goo' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-resin-2' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-chromate-smelting' does not have a crafting_machine_tint set!
[LOG]   Recipe 'paper-bleaching-2' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-sulfur-dioxide' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-chlorauric-acid' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-fuel-fuel-oil' does not have a crafting_machine_tint set!
[LOG]   Recipe 'pellet-cobalt-smelting' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-dimethylamine' does not have a crafting_machine_tint set!
[LOG]   Recipe 'bio-plastic-2' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-phenol-catalyst' does not have a crafting_machine_tint set!
[LOG]   Recipe 'sodium-nitrate-acid-processing' does not have a crafting_machine_tint set!
[LOG]   Recipe 'geode-blue-liquify' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-pulping-liquor' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-tungsten-oxide-smelting' does not have a crafting_machine_tint set!
[LOG]   Recipe 'glycerol' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-acetic-anhydride' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-fuel-hydrazine' does not have a crafting_machine_tint set!
[LOG]   Recipe 'mineral-oil-lubricant' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-mineral-oil-catalyst' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-styrene-catalyst' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-methanol-from-wood' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-sodium-perchlorate' does not have a crafting_machine_tint set!
[LOG]   Recipe 'hydrogen-sulfide' does not have a crafting_machine_tint set!
[LOG]   Recipe 'ethanol-to-ethylene-synthesis' does not have a crafting_machine_tint set!
[LOG]   Recipe 'kraft-recovery' does not have a crafting_machine_tint set!
[LOG]   Recipe 'coolant' does not have a crafting_machine_tint set!
[LOG]   Recipe 'silver-nitrate' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-nitric-acid' does not have a crafting_machine_tint set!
[LOG]   Recipe 'sulfite-pulping' does not have a crafting_machine_tint set!
[LOG]   Recipe 'geode-purple-liquify' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-ammonium-perchlorate' does not have a crafting_machine_tint set!
[LOG]   Recipe 'stone-crushed-dissolution' does not have a crafting_machine_tint set!
[LOG]   Recipe 'crystal-powder-slurry' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-acid-catalyst' does not have a crafting_machine_tint set!
[LOG]   Recipe 'kraft-cooking-washing' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-chlor-methane' does not have a crafting_machine_tint set!
[LOG]   Recipe 'silver-oxide' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-white-liquor' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-fish-atmosphere' does not have a crafting_machine_tint set!
[LOG]   Recipe 'nitroglycerin' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-sodium-hydroxide' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-ethylbenzene-catalyst' does not have a crafting_machine_tint set!
[LOG]   Recipe 'lead-oxide-2' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-sodium-nitrate-processing' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-propionic-acid-catalyst' does not have a crafting_machine_tint set!
[LOG]   Recipe 'angelsore8-sludge' does not have a crafting_machine_tint set!
[LOG]   Recipe 'anaerobic-fermentation' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-ammonium-nitrate' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-sulfuric-acid' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-synthesis-methanation' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-plastic-1' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-toluene-from-naphtha' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-synthesis-reforming' does not have a crafting_machine_tint set!
[LOG]   Recipe 'kraft-causting' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-polyehtylene-catalyst' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-methanol-catalyst' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-allylchlorid' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-hydrochloric-acid' does not have a crafting_machine_tint set!
[LOG]   Recipe 'processed-silver-smelting' does not have a crafting_machine_tint set!
[LOG]   Recipe 'slag-processing-dissolution' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-sodium-cyanide' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-urea' does not have a crafting_machine_tint set!
[LOG]   Recipe 'paper-bleaching-3' does not have a crafting_machine_tint set!
[LOG]   Recipe 'bio-rubber' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-sodium-chlorate' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-hydrogen-fluoride' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-resin-3' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-hydrofluoric-acid' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-sodium-hydroxide-solid-sodium-sulfate' does not have a crafting_machine_tint set!
[LOG]   Recipe 'geode-yellow-liquify' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-phosgene' does not have a crafting_machine_tint set!
[LOG]   Recipe 'bio-resin-resin-liquification' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-fuel-methane' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-benzene-catalyst' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-hydrogen-chloride' does not have a crafting_machine_tint set!
[LOG]   Recipe 'geode-lightgreen-liquify' does not have a crafting_machine_tint set!
[LOG]   Recipe 'filter-lime-used' does not have a crafting_machine_tint set!
[LOG]   Recipe 'angels-atomic-bomb-2' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-aqueous-sodium-hydroxide-reverse' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-plastic-3' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-hydrochloric-acid-solid-sodium-sulfate' does not have a crafting_machine_tint set!
[LOG]   Recipe 'angelsore9-sludge' does not have a crafting_machine_tint set!
[LOG]   Recipe 'angels-water-enrichment-1' does not have a crafting_machine_tint set!
[LOG]   Recipe 'geode-cyan-liquify' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-trinitrotoluene' does not have a crafting_machine_tint set!
[LOG]   Recipe 'rocket-oxidizer-capsule' does not have a crafting_machine_tint set!
[LOG]   Recipe 'angels-water-enrichment-3' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-puffer-atmosphere' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-sodium-carbonate' does not have a crafting_machine_tint set!
[LOG]   Recipe 'bio-plastic-1' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-polluted-fish-atmosphere' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-cellulose-acetate' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-acetic-acid-catalyst' does not have a crafting_machine_tint set!
[LOG]   Recipe 'aerobic-fermentation' does not have a crafting_machine_tint set!
[LOG]   Recipe 'fermentation-corn' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-melamine' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-fuel-naphtha' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-calcium-carbonate' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-synthesis-separation' does not have a crafting_machine_tint set!
[LOG]   Recipe 'bio-plastic' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-resin-1' does not have a crafting_machine_tint set!
[LOG]   Recipe 'solid-fuel-synthesis' does not have a crafting_machine_tint set!
[LOG]   Recipe 'brown-liquor-recovery' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-ammonia' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-methylamine' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-ammonia-from-blue-fiber' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-ferric-chloride-solution' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-bisphenol-a' does not have a crafting_machine_tint set!
[LOG]   Recipe 'cumene-process' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-hydrogen-fluoride' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-rubber-1' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-monochloramine' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-dimethylhydrazine' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-hydrogen-chloride-separation' does not have a crafting_machine_tint set!
[LOG]   Recipe 'lead-oxide' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-ammonium-chloride' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-hexafluorosilicic-acid' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-plastic-2' does not have a crafting_machine_tint set!
[LOG]   Recipe 'bio-resin' does not have a crafting_machine_tint set!
[LOG]   Recipe 'water-mineralized' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-carbon-dioxide-from-wood' does not have a crafting_machine_tint set!
[LOG]   Recipe 'liquid-naphtha-catalyst' does not have a crafting_machine_tint set!
[LOG]   Recipe 'gas-formaldehyde-catalyst' does not have a crafting_machine_tint set!
[LOG]   Recipe 'water-viscous-mud' does not have a crafting_machine_tint set!
[LOG]   Recipe 'rocket-fuel-capsule' does not have a crafting_machine_tint set!
[INFO] exporting data.raw...
[INFO] process all items... found 1588 with type="item", 262 with other type
[INFO] process technologies... enabled 2344 recipes
[INFO] process recipes...[INFO] missed loc string: ...angels-plate-glass-3 (called from L():84)
[INFO] missed loc string: ...angels-plate-glass-3 (called from L():84)
[INFO] missed loc string: ...nil (called from gsub():-1)
..\dist53\bin\lua53: factorio_data_dump.lua:625: .\factorio\locale.lua:67: attempt to concatenate a nil value (local 'id')
stack traceback:
        [C]: in function 'error'
        factorio_data_dump.lua:625: in main chunk
        [C]: in ?

@hhrhhr
Copy link

hhrhhr commented Aug 14, 2020

Try to use -v flag and show mod load order like this:

[INFO] mods load order received:
        core <- base <- mod1 <- mod2 <- ...

p.s.
Also prefer to use Lua 5.2f (from the dist_0.4.zip archive), as many mod writers don't care about their scripts being compatible with pure Lua.

@dcbroad3
Copy link
Collaborator Author

Hey @hhrhhr, I've actually been able to make a lot of progress with Bob's and Angel's, at this point it seems like the only issue is that some of the icons don't get resized the way they should, which is odd to me. You can see the current sprite sheet here.

It looks like some of the Angel's sprites are messed up in row 43. I checked the output of your tool and it didn't list any problems in that row, although for a lot of the icons I get different messages like:

  • libpng warning: iCCP: known incorrect sRGB profile
  • libpng warning: Interlace handling should be turned on when using png_read_image
  • libpng warning: iCCP: cHRM chunk does not match sRGB

I know some of these don't matter but some seem new to me. I did use the -v flag with this run.
I did have to make some modifications to gd_image.lua to avoid errors.

local function apply_tint(ico, tint)
    local X, Y = ico:sizeXY() -- gd func
    for y = 0, X-1 do
        for x = 0, Y-1 do
            local c = ico:getPixel(x, y)
            if tint.r ~= nil and tint.g ~= nil and tint.b ~= nil then
                local r = math.floor(ico:red(c)   * tint.r)
                local g = math.floor(ico:green(c) * tint.g)
                local b = math.floor(ico:blue(c)  * tint.b)
    --            local a = math.floor(ico:alpha(c) * tint.a)
                local a = ico:alpha(c)
                c = ico:colorAllocateAlpha(r, g, b, a)
                if not c then
                    local orig = ico:getPixel(x, y)
                    if orig ~= nil then
                        c = orig
                    end
                end
            end
            ico:setPixel(x, y, c)
        end
    end
end

Sadly it takes like 30 minutes to generate this sprite sheet also :(

@hhrhhr
Copy link

hhrhhr commented Aug 30, 2020

I have not found a way to disable such warnings other than modifying the libpng sources (this is wrong way). If there are many such warnings, then it is best to warn the author of the modification about using outdated tools. Or you can just redirect the stderr output to a file and hide it )

Regarding improperly scalable icons - what mod are they from?

I can also see that the overlay icons at this scale are rendered too small too. Probably, there is an error somewhere due to 128px icons from the mod, while all calculations are based on the fact that icons can be at most 64px. So I'm waiting for the name of the mod )

@dcbroad3
Copy link
Collaborator Author

It seems to be some of angel's, angel's refining is one with a problem and i can duplicate the issue with just that mod. I think you're on the right track suspecting the 128px but haven't had enough time to troubleshoot.

@dcbroad3 dcbroad3 linked a pull request Sep 3, 2020 that will close this issue
dcbroad3 pushed a commit that referenced this issue Sep 5, 2020
@dcbroad3 dcbroad3 moved this from In progress to Done in 1.2 (Mods) Sep 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mods Related to mod support
Projects
No open projects
1.2 (Mods)
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants