Solved Attempt to index a nil value

Discussion in 'Mod Support' started by ItsTheLittleAcura!, May 22, 2019.

  1. ItsTheLittleAcura!

    ItsTheLittleAcura!
    Expand Collapse

    Joined:
    Feb 9, 2018
    Messages:
    116
    I have been trying to simulate the infamous V8-6-4 fuel injection engine from Cadillac for a while. I have revised my code several times, trying to get it to work. Here is my latest problem.
    213.07904|E|libbeamng.Lua.Exception|vehicles/oldsfullsize//lua/powertrain/CombustionEngine.lua:1193: attempt to index global 'device' (a nil value). My code has nothing to do with this line, I just had to edit something above it. What's wrong with my code?
     

    Attached Files:

  2. fufsgfen

    fufsgfen
    Expand Collapse

    Joined:
    Jan 10, 2017
    Messages:
    6,782
    If something prevents engine to be loaded or some part of powertrain fails, it can then cause nil happening on some other line that request what was missing because fail to load because of edit.

    It is like domino effect, comma in wrong place causes something not to load and you get error from completely different that is not finding part not loading because some other error.

    Do have line numbers of which you have edited, I did try to look, but having to go trough thousand or so of lines is not exactly easy on time department?
     
  3. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    not sure what IDE you are using but line 1192 is outside a function,
    It will get executed while parsing.

    just move the last 'end' from line 1190 after line 1200
     
    • Like Like x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice