Unsolved Wendover cylinder-deactivation lua errors

Discussion in 'Mod Support' started by ItsTheLittleAcura!, Mar 31, 2021.

  1. ItsTheLittleAcura!

    ItsTheLittleAcura!
    Expand Collapse

    Joined:
    Feb 9, 2018
    Messages:
    116
    From the moment I installed the new update and drove the V8 Wendover, I knew it needed a simulation of GM's cylinder deactivation that they experimented with in the '81 Cadillacs. These vehicles shut down to 6 or 4 cylinders at highway speeds to improve MPG.
    I created a custom lua controller built into the ECU to simulate shutting down half of the engine, and the associated exhaust drone. I receive an error when I load the vehicle, and the system obviously does not work. I notice no change in power, and can't hear the exhaust note change, no matter how light I am on the accelerator.
    Can't load controller 'cylinderCutoff' at '/controller/cylinderCutoff.lua', further info below:
    42.57212|E|libbeamng.lua.V.controller.init|lua/vehicle/main.lua:207: attempt to concatenate local 'path' (a table value).

    The controller file is attached, can someone take a look at it?
     

    Attached Files:

  2. NOCARGO

    NOCARGO
    Expand Collapse

    Joined:
    Apr 1, 2019
    Messages:
    1,514
    You are way too fast in thinking this file is going to take any effect on the action. The biggest mistake in this file is declaring "M.updateGFX = nop". Now everything you wrote in the update(GFX) function is not taking any effect. (nop means "not operating" or the likes)

    But there's a lot more because it isn't that simple. It seems you gave set "M.defaultOrder" to 1000 yourself ? Doesn't really matter imo, at least not in this case.

    engine:setExhaustGainMufflingOffset(-0.5, 2)
    maybe this could work in your custom lua file, but

    engine.ignitionCoef = 0.5
    this certainly won't

    local gear = nil
    okay (?) but

    gear = electrics.values.gearIndex or 2
    then what ? you are not declaring anything after this statement, how does the code supposes to know what to do with it ?

    local engine = powertrain.getDevice(engineName)
    should be local engine = powertrain.getDevice(mainEngine) I guess..

    There's a lot more to say about this file but it's of no use anyway because it's way more complicated than that.
    If you want your engine to behave different from vanilla engines you will have to create your own combustionEngine.lua file and make custom changes to that file. It's also probable that you might have to need a custom vehicleController too.
    --- Post updated ---
    Oh by the way, engineLoad can never be greater than 1, 1 should be regarded as 100% .
     
  3. Diamondback

    Diamondback
    Expand Collapse
    Vehicle Systems Lead
    BeamNG Team

    Joined:
    Apr 8, 2014
    Messages:
    1,957
    Huh, this is a very weird error. Apart from obvious issues in the code itself, the error you are seeing is definitely something you shouldn't get... Investigating.
     
  4. Diamondback

    Diamondback
    Expand Collapse
    Vehicle Systems Lead
    BeamNG Team

    Joined:
    Apr 8, 2014
    Messages:
    1,957
    Ah ok. Well debugging works better if you edit the right file... Anyway :cool:
    So what is happening here is not obvious, but nothing I can really improve either.

    You have this in your code:
    Code:
    M.updateGFX = nop
    M.init = init
    However, you don't have an init function defined. In this specific case, this leads to lua trying to find a global init function (since there is none in the local scope) and it happens to find one, the main vehicle init method. The controller code then proceeds to call that method rather than an actual init method in your controller.

    Just assign a nop to it or create an init in your controller and the error goes away :)
     
  5. ItsTheLittleAcura!

    ItsTheLittleAcura!
    Expand Collapse

    Joined:
    Feb 9, 2018
    Messages:
    116
    Resolved this error by nopping the "init" function and removing the nop from my updateGFX function. Split up the two parts of my code into separate functions. The main updateGFX function gathers all the vehicle data, and then calls a separate function to actually control the cylinder deactivation. The code cuts off half of the ignitionCoef and changes the exhaust muffling to introduce an annoying drone, similar to how actual cylinder deactivation sounds.
    This change has introduced another error, despite me defining the function at the end of the file and it being a local function.
    "Attempt to call global 'setCylinderCount' (a nil value)"
     

    Attached Files:

  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