Foreman 0.1.9 - A factory optimisation tool.

Calculate optimal ratios for feeding recipes, search through the research-tree, specialized tools to view game-information.
Degraine
Filter Inserter
Filter Inserter
Posts: 282
Joined: Wed Aug 13, 2014 10:49 am
Contact:

Re: A tool to help you optimise your production lines.

Post by Degraine »

The downloadable works well for me (1.5 on Windows 7-64bit) but...only with vanilla recipes. It doesn't seem to load mod content at all, and the 0.11.1 version of the game doesn't work at all, obviously.
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by ssilk »

Hm. The loading has changed. The problem is eventually, that the java seems to emulate the loader. In long term it will work only, if the loader is executed in lua and the lib can load a standardized format like XML.

See http://github.com/alexaulbach/FactorioLoaderLib.git
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Blackence
Fast Inserter
Fast Inserter
Posts: 109
Joined: Thu Jun 05, 2014 4:03 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by Blackence »

The fix for this issue appears to be quite easy: Change "smelting_speed" in DataCache.cs, line ~465, to "crafting_speed" and "smelting_categories" to "crafting_categories". There was some work to unify assembling machines and furnaces for 0.11, so these names have changed.

However, the "attempt to call global 'module' (a nil value)" problem is now much worse compared to 0.10. entities.lua now fails to load, and that means most furnaces and assembling machines are missing from the Foreman tool even after applying the fix. Pretty much only entities which are available in the Factorio demo (i.e. Assembling Machine 1 and Stone Furnaces) are used for calculation.

I tried to fix this when I originally ported Foreman to Ubuntu, but didn't succeed. It's related to a lua version mismatch between Factorio and Foreman (that is, NLua). NLua uses its own fork of some Lua release, and Factorio probably embeds and uses an older version of Lua.
Psycix
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Nov 08, 2014 3:51 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by Psycix »

I created an issue on the bitbucket and I sent Nicksaurus a PM.
https://bitbucket.org/Nicksaurus/forema ... patibility
angus
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Oct 18, 2014 6:47 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by angus »

Amazing stuff!
elliotpotts
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Nov 15, 2014 11:53 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by elliotpotts »

micomico wrote:
Nicksaurus wrote:?
My post falls on your 'untempered vitriol' category.

Why would I try to install something made in a framework, whose developer doesn't even try to cater to the platform I use? Surely I'm not expected to install a 3rd party framework implementation that may or may not be able to run the stuff. 20th century called, it wants all its non-cross-platform stuff back.

That being said, the resulting flowcharts look nice and the application has a useful purpose.
.Net framework is open source.
JackGruff
Fast Inserter
Fast Inserter
Posts: 134
Joined: Tue Oct 15, 2013 4:44 pm
Contact:

Unhandled exception

Post by JackGruff »

Windows 8.1 Enterprise x64
Factorio 0.11.3
Foreman 0.1.5

Details
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by ssilk »

<watching the debug output>
Hmmmmmm. I'll come back to this:
ssilk wrote:Hm. The loading has changed. The problem is eventually, that the java seems to emulate the loader. In long term it will work only, if the loader is executed in lua and the lib can load a standardized format like XML.
I guess: Java tries to load/interpret foreman, but has no module for that.

If I'm true with this, all my senses as software developer says, this way of interpretation leads directly into a dead end.
:)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
dable
Manual Inserter
Manual Inserter
Posts: 1
Joined: Tue Dec 02, 2014 7:55 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by dable »

I have pretty much the same error as JackGruff.
When I ignore the error, the program is loading, but I get to see this:
Image
omagaalpha
Inserter
Inserter
Posts: 23
Joined: Mon Apr 29, 2013 4:49 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by omagaalpha »

When will this be able work with 11.3 with mods?
mclean25
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Dec 06, 2014 3:21 am
Contact:

Re: A tool to help you optimise your production lines.

Post by mclean25 »

Cool? What application did you build that flow chart on?
ares0027
Long Handed Inserter
Long Handed Inserter
Posts: 65
Joined: Sun May 04, 2014 6:48 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by ares0027 »

this is the second best "mod" (app) i use(d)/love and an update with a little bit more functions would be awesome. any news on that part? i think source is also available can someone else use that?
Blackence
Fast Inserter
Fast Inserter
Posts: 109
Joined: Thu Jun 05, 2014 4:03 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by Blackence »

As I said on the previous page, there are 2 issues: One is easy to fix (adapt to 0.11 format of some lua files), but I don't know how to fix the other one. The source code doesn't help in this case. This tool does not use the same version of lua as Factorio does to load game files. Maybe there is some setting to make them behave the same, but I couldn't find one. The issue is that lua game files are formatted to work with the factorio version of lua, but since 0.11 one major lua file changed somehow so that it no longer works with this tool and is ignored by the tool.

It's also not as easy as replacing one lua.dll with a different one, because the lua version that is used by factorio is embedded in the factorio.exe file (static linking), while the lua version that is used by this tool needs special modifications so it works with C#. (Actually, the NLua developers probably were to lazy to adapt their NLua wrapper to changes made in upstream lua, and decided to "fork" lua so they can undo those changes.)
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by ssilk »

Hm. Lua is lua. (A bit simplistic view, I know :) ) The differences in interpretation can come only from including different other lua programs, that change stuff (My opinion). I remember, that the internal loader has been changed to load now in three stages.

So I haven't till now any problems with my loader lib, cause it includes those other includes in the same way as Factorio. No need to change anything between 0.9 and 0.11. https://github.com/wube/factorio-lua-tools or https://github.com/alexaulbach/FactorioLoaderLib to see how it works.

But well, as already said, under windows it might look differently.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
ares0027
Long Handed Inserter
Long Handed Inserter
Posts: 65
Joined: Sun May 04, 2014 6:48 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by ares0027 »

Blackence wrote:As I said on the previous page, there are 2 issues: One is easy to fix (adapt to 0.11 format of some lua files), but I don't know how to fix the other one. The source code doesn't help in this case. This tool does not use the same version of lua as Factorio does to load game files. Maybe there is some setting to make them behave the same, but I couldn't find one. The issue is that lua game files are formatted to work with the factorio version of lua, but since 0.11 one major lua file changed somehow so that it no longer works with this tool and is ignored by the tool.

It's also not as easy as replacing one lua.dll with a different one, because the lua version that is used by factorio is embedded in the factorio.exe file (static linking), while the lua version that is used by this tool needs special modifications so it works with C#. (Actually, the NLua developers probably were to lazy to adapt their NLua wrapper to changes made in upstream lua, and decided to "fork" lua so they can undo those changes.)

cant we do something web based or something like that? like;

it is a form that includes all the items of vanilla.
with some work (like wiki, or official modders) we can add some big mod information and user can enable/disable those mods
and a "custom" section that a use can edit/change/add new items or the items that were added already.


since i have absolutely no knowledge of any form of scripting this seems at least a bit more possible to create (yet it cannot "find" all the items/mods installed but it is still something) isnt it?
Blackence
Fast Inserter
Fast Inserter
Posts: 109
Joined: Thu Jun 05, 2014 4:03 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by Blackence »

ssilk wrote:Hm. Lua is lua. (A bit simplistic view, I know :) )
Of course :) However, as you can see from this git repo and its history (it's the lua version used in the Foreman tool), there are a lot of API breaking changes between the "NLua-lua" and official lua. Just one example here. They add a lot of functions that no longer exist in official lua. And NLua needs those functions to work. Now the problem is that we can't simply replace the lua version used by NLua for the Foreman tool with the lua version used by Factorio (I'm not sure, maybe 5.1 or 5.0?), because the factorio version doesn't have the modifications required for NLua.
The differences in interpretation can come only from including different other lua programs,
There are not actually differences in interpretation (i.e. wrong values etc.) as far as I can tell. It's simply that NLua-lua completely fails to interpret some .lua files supplied by factorio. Instead, we get this error:

Code: Select all

/home/xxx/factorio/data/base/prototypes/entity/entities.lua(/home/xxx/factorio/data/core/lualib/util.lua:2: attempt to call global 'module' (a nil value))
If anyone knows how to fix this error without reverting to an older/different lua version, we might be able to get Foreman working with 0.11. I found something about a compile-time compatibility switch, but that didn't seem to work.
So I haven't till now any problems with my loader lib, cause it includes those other includes in the same way as Factorio. No need to change anything between 0.9 and 0.11. https://github.com/wube/factorio-lua-tools or https://github.com/alexaulbach/FactorioLoaderLib to see how it works.
The only thing that needs changing for 0.11 inside the foreman tool is that factorio now stores furnaces as assembler machines, or something like that. It's a simple key name change. The other problem with lua failing to interpret files is not new in 0.11, it just happened that entities.lua is no longer working in 0.11, while in 0.9 only unimportant files failed to work.
n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: A tool to help you optimise your production lines.

Post by n9103 »

Well, I don't know about NLua's implementation, but factorio gives that error anytime you try to call methods or functions or variables that aren't present in the context used, regardless of if they're used within a parent or child object of the context referenced.
Just pointing that out, not saying it's relevant in this case.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by ssilk »

Blackence wrote: If anyone knows how to fix this error without reverting to an older/different lua version, we might be able to get Foreman working with 0.11. I found something about a compile-time compatibility switch, but that didn't seem to work.
I didn't look much into Foreman, so, stupid question, why does it need an own lua interpreter?
The only thing that needs changing for 0.11 inside the foreman tool is that factorio now stores furnaces as assembler machines, or something like that. It's a simple key name change. The other problem with lua failing to interpret files is not new in 0.11, it just happened that entities.lua is no longer working in 0.11, while in 0.9 only unimportant files failed to work.
Hm. So it seems, that I had luck till now? I don't think!
n9103 wrote:Well, I don't know about NLua's implementation, but factorio gives that error anytime you try to call methods or functions or variables that aren't present in the context used, regardless of if they're used within a parent or child object of the context referenced.
Just pointing that out, not saying it's relevant in this case.
I solve this problem normally by making a variable global or define it locally.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Blackence
Fast Inserter
Fast Inserter
Posts: 109
Joined: Thu Jun 05, 2014 4:03 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by Blackence »

@n9103: Okay, thanks – that's a hint. Now the problem is that this error occurs in a file that is part of Factorio, and it works with Factorio, but fails when trying to use that file with Lua 5.2 (i.e. Foreman). Maybe the "module" variable no longer exists in 5.2, or at least it doesn't exist under some circumstances.

@ssilk: I think Nicksaurus evaluated two approaches.
1) To parse the various lua files using standard C# file parsing techniques. This is error-prone, because programming languages offer a lot of (infinte) ways to express the same thing, so if Factorio devs decide that they want to change the way the game data structures are built in Lua, this Foreman code would fail and needs an update.
2) To embed the lua scripting engine into the Foreman tool and "execute" the lua game data files, then extract the game data structures from the lua engine. This is probably the same approach Factorio uses. This is less error-prone, because the files can always be interpreted as long as they are correct lua. It's just a matter of extracting the correct data structuers. So Foreman now only needs updates when variable names or table key names change.

Nicksaurus picked approach #2. As far as I know, there's only 1 third-party project that allows embedding Lua into .NET projects, and it's NLua. And the version of lua that is used by NLua appears to miss the global "module" variable in some cases, while that variable exists in the Factorio lua version. Maybe a third approach would be better:
3) Implement a factorio mod that extracts all the relevant game data, formats it in a well-defined (CSV, JSON, whatever) way, and stores that info in a .txt file. Then Foreman and similar tools could use that file to load game data. No problem with Lua incompatible version changes, and no problem with hard to parse (too flexible) programming language syntax.

And this is where your lua loader lib might come in very handy to export the game data to JSON. I'd prefer to build a Factorio mod out of it instead of running it stand-alone, because that guarantees that there are no lua version related issues. Just not sure if it's allowed to modify/redistribute that code, since it has no license attached (and wube's repo has no license as well). :cry:
ssilk wrote:Hm. So it seems, that I had luck till now? I don't think!
Me neither, reproducible errors (or lack thereof) can't be attributed to luck :)

The lua loader lib is 100% lua, right? Maybe it works because you use the same Lua version that is used by Factorio, maybe 5.0 or 5.1? Out of interest, have you tried running the lua lib using lua 5.2? If that works, there must be some way to get Foreman running again without a lot of changes. Otherwise, I'll try and see how difficult it'd be to load a lualib-exported JSON file instead of native lua files.



Update:
I'm now taking a look at the factorio loader lib using lua 5.2, and so far no errors (it's still working though). Maybe it's related to the order in which lua files are loaded. I seem to remember that foreman just loads lua files in the order in which they are found. The loader lib probably loads "data.lua" from the root dir only, which includes all lua files in a specific/correct order. Maybe I can use that to fix foreman?
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: A tool to help you optimise your production lines.

Post by ssilk »

Blackence wrote:And this is where your lua loader lib might come in very handy to export the game data to JSON. I'd prefer to build a Factorio mod out of it instead of running it stand-alone, because that guarantees that there are no lua version related issues. Just not sure if it's allowed to modify/redistribute that code, since it has no license attached (and wube's repo has no license as well). :cry:
Hm, you can use the code, if you want, I've added a licence. (https://github.com/alexaulbach/FactorioLoaderLib)
But my opinion is, that this should be really split in an extra mod. And I'm a bit ambiguous about making it a mod at all; you need to test, if there is really comming out the same.
The lua loader lib is 100% lua, right? Maybe it works because you use the same Lua version that is used by Factorio, maybe 5.0 or 5.1? Out of interest, have you tried running the lua lib using lua 5.2? If that works, there must be some way to get Foreman running again without a lot of changes. Otherwise, I'll try and see how difficult it'd be to load a lualib-exported JSON file instead of native lua files.
Just tested it, it works. I've added the conversions for 0.11.6 https://github.com/alexaulbach/Factorio ... er/tmpdata
Update:
I'm now taking a look at the factorio loader lib using lua 5.2, and so far no errors (it's still working though). Maybe it's related to the order in which lua files are loaded. I seem to remember that foreman just loads lua files in the order in which they are found. The loader lib probably loads "data.lua" from the root dir only, which includes all lua files in a specific/correct order. Maybe I can use that to fix foreman?
Yes, this doesn't work. The loader takes very much care about loading the mods in the right order and tries to watch about the dependencies.
The "heart" of this code is https://github.com/alexaulbach/Factorio ... ary/loader funkction dependenciesOrder
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Post Reply

Return to “Cheatsheets / Calculators / Viewers”