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

Error: [string <mod_file_name>]:<n>: attempt to index a nil value (field 'startup') #8

Open
eduran84 opened this issue Apr 12, 2019 · 2 comments

Comments

@eduran84
Copy link

I really love your calculator! I've just discovered the offline version which imports local mod data and would like to use it.

If I do, I see error messages like:
[string "bobassembly_0.17.2/prototypes/assembly-electr..."]:1: attempt to index a nil value (field 'startup')
or
[string "BigDrills_0.5.4/prototypes/tech/tech.lua"]:47: attempt to call a nil value (global 'unpack')

The relevant lua code from said mods looks like this:
if settings.startup["bobmods-assembly-electronicmachines"].value == true then
and
prerequisites = {"logistics-2", "bucket-wheel-excavator", "advanced-material-processing-2", unpack(preMK2 or {})},

If I start the calculator with an empty mod dir everything works fine. As do most mods, except those that reference settings.startup or try to call unpack.

Factorio version: 0.17.28
Calculator version: 0.3 binary for windows
Mods causing error messages: bobassembly_0.17.2.zip, BigDrills_0.5.4.zip

Is there anything I can do to fix this issue on my end?

@RustyBlade64
Copy link
Contributor

The first of these two problems should be resolved by KirkMcDonald/FactorioLoaderLib#7.

The second one I cannot reproduce. Given that unpack has been moved to table.unpack in Lua 5.2 and the fact that there is a backward compatibility flag that can be enabled somewhere I suspect this might be a platform dependent issue:

Function unpack was moved into the table library and therefore must be called as table.unpack.

https://www.lua.org/manual/5.2/manual.html#8.2

You're probably embedding Lua as source, not as a pre-built library. In this case, you have probably not enabled backward compatibility.

By default, the command line interpreter is built with backward compatibility, hence the difference you see

https://stackoverflow.com/questions/25794364/lua-trouble-attempt-to-call-global-unpack-a-nil-value

I would guess Factorio has this backward compatibility flag set, but KirkMcDonald/golua in the windows binary probably has not.

@Magos
Copy link

Magos commented Feb 29, 2020

I'm also experiencing the startup issue and it does indeed appear to be an issue with load order. The minimal setup to reproduce that I've found:

  1. Clear all mods from Factorio mod manager.
  2. Install AngelBob and its transitive dependencies.
  3. Open factoriocalc 0.3
  4. attempt to index nil error happens in [boblibrary_0.17.5/resource-generator.lua]. Editing this file shows it's masking similar errors further along in the dependency graph.

This is on Windows.
I really love this calculator and having the option to use it to manage the sheer complexity of Angels + Bob's would be a great help.
factorio-current.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants