Help needed for creating a shiftLogic mod that improve the upshift/downshift reaction speed. That involves modifying the vehicleController.lua The expected behaviors are as shown Stopped aggression is 0.5 instead of 0.75. When driving non-aggressively(low throttle slow throttle movement), the S mode is very similiar to D with the same low upshifting RPM. When driving aggressively(high throttle fast throttle movement), the D mode will upshift very quickly right after throttle reduction while S mode will delay upshift. In order to prevent mod conflict, the lua have to be renamed If no rename then 758.79725|E|libbeamng.lua.V.controller.init|Found duplicate controller of name "vehicleController", please make sure there are no name overlaps. 758.79729|E|libbeamng.lua.V.controller.init|By default controller names are the type, specify unique names if you use multiple controllers of the same type. But the mod itself is still working as expected(explained above) However, if rename, for example vehicleControllerLogictest.lua then 5187.14136|W|libbeamng.lua.V.controller.init|Found more than one main controller, 1: 'vehicleControllerLogictest', 2: 'vehicleController', unloading the first one... The modded lua won't load. The renames are In the \vehicles\common\etk\etk_dct_logicmod_test.jbeam Code: "controller": [ ["filename"], ["vehicleController",{}], ], rename the "vehicleController" in the "controller" to "vehicleControllerLogictest" Code: "vehicleController": { "shiftLogicName":"automaticGearboxLogictest" "automaticModes":"PRNDSM", "aggressionSmoothingUp":1, "aggressionSmoothingDown":0.5, "aggressionSmoothingUpSport":2, "aggressionSmoothingDownSport":0.1, "aggressionSportMinimum":0.25, "aggressionStopped":0.50, }, rename the "vehicleController" to "vehicleControllerLogictest" and rename the file \lua\vehicle\controller\vehicleController.lua to vehicleControllerLogictest.lua Please drive the ETK 800-Series and select these parts for mod testing "test 8-Speed Automatic Transmission (700T1400LM3)" and "test 8-Speed Dual Clutch Transmission (M3)"
I don't know anything, but would it be possible to do something like this: if sportmode { "aggressionSmoothingUp":2 "aggressionSmoothingDown":0.1 } So what I'm thinking here is that instead of giving new variable, you would just change existing one, but is that even possible, would it need jbeam reload then? Anyway my understanding is very little about this subject, so you might just be better of ignoring above if it does not make any sense
So what I found is that right now you are basically playing the lottery. What I mean is that there is a random chance that it will actually use your custom vehicleController. The culprit is with BeamNG's code and not yours: (from "lua/vehicle/controller.lua" @ line 260) Code: local controllers = {} for _, v in pairs(jbeamControllers) do if v.fileName and not blacklistLookup[v.fileName] then local name = v.name or v.fileName ... controllers[name] = v end end controllers = adjustControllersPreInit(controllers) local directory = "controller/" for k, c in pairs(controllers) do ... if controller.type == "main" then if not M.mainController then M.mainController = controller else log("W", "controller.init", string.format("Found more than one main controller, 1: '%s', 2: '%s', unloading the first one...", M.mainController.name, controller.name)) loadedControllers[M.mainController.name] = nil M.mainController = controller end end end end ... end This is because the "controllers" table is an associative array and the problem with that is the order of the "controller" elements is arbitrary (restarting Lua Ctrl + L changes the order of the elements). Because of the random order, if your custom controller happens to appear before the default controller in the "controllers" table, it will first be set as the "mainController" when iterating over the "controllers" table. But later when the default vehicle controller element is of the current iteration, it overwrites the "mainController". And this also allows your controller to become the "mainController" if it happens to appear after the default controller in the "controllers" table by chance. So to fix this, the "controllers" table needs to be indexed by controllers' "cid" (controller ID), which looks to hold a fixed value.
Well, according to vehicleController.lua, the aggression smoothing calculation in both D and S are using the same, the only difference is S has a minimum 0.5 aggression cap. Therefore it's not possible to separate the aggression calculation without modifying the lua. I'm unable to find "cid" in the lua. And if M.type = "main" set to auxiliary instead then vehicleController.lua will always load instead of vehicleControllerLogictest.lua Is there any way to not loading the vehicleController.lua and load the vehicleControllerwhateveryounamed.lua instead?
This is to access "cid": Code: v.data.controller[index].cid Controller's "M.type" needs to be set to "main" in order to be set to the "M.mainController" according to the code in "controller.lua", but like I said above this is by random chance whether it uses yours or the default one. You need to modify the "controller.lua" code if you want it to work, or maybe its possible to set "M.mainController" after the vehicle initializes to your custom controller but I'm not sure if this will work.
That's not how stuff works. If you want to overwrite a controller file, you need to do that at the filesystem level.
I tried editing the lua and renamed it to "controller2.lua", and in the jbeam Code: "controller2": [ ["filename"], ["vehicleControllerLogictest",{}], ], Then nothing happened, still loads the BeamNG original vehicleController.lua So I have to name the modified lua to vehicleController.lua? Then vanilla vehicle will be affected as well?
In my opinion it used to work like this: "controller": [ ["filename"], ["awesomevehicleController",{}], ], Then put your controller to yourbnguserfolder\lua\vehicle\controller\awesomevehicleController.lua But it's ages since I played with those. Controller2 probably is why it is not working, because code excepts keyword controller, not controller2. So essentially you would tell vehicle controller is awesomevehicleController instead of default vehicleController. I don't know if it works inside yourbnguserfolder\vehicles\etk800\lua\controller\ though, but that and above are possible paths, I think. Then again my memory is pretty hazy and it has been a while since I tampered with AT and TC logics, but I remember implementing winter mode and custom AT shift pattern in my T75 drift truck mod, but that was really long time ago, more than 10 game versions ago I think. E: Oh yes, I don't think you can override that on vanilla vehicles without new .jbeam too, so adding new etk800 jbeam that tells new logic is this awesomvehiclecontroller. So you need to provide etk800.jbeam as etk800awesomeVC.jbeam with renames in line 2 and 5 as well as your new controller name in file and then it should work, but not straight from the box, however that should be fairly simple to do, unless I'm mistaken here.
I tried using this, the vehiclecontrollerlogictest.zip in OP is the same method as you said. But the result is Also Modifying the TC logic does not involve modifying the vehicleController.lua Simply modify the shiftLogic-automaticGearbox.lua and rename it to shiftLogic-awesomeAutomaticGearbox.lua, then in the jbam file Code: "vehicleController": { "shiftLogicName":"awesomeAutomaticGearbox", }, You can extract this mod to see the inner working.
Oh man, give me an hour, I see if I can figure this out, I test now... --- Post updated --- So, my thought of putting new etk800vc.jbeam in obviously did not work, but I modified etk800.jbeam and put that in userfolder/vehicles/etk800, on that file I changed vehicle controller to be awesomevehicleController. Placed awesomevehicleController.lua into userfolder\lua\vehicle\controller\ and modified that to print awesome to console. Then I have constantly awesome printing to console as I reload vehicle. There is only one little problem with this, now it is always using awesomevehicleController, but I can't see how to make that selectable really as otherwise you end up into lottery... Anyway, what Diamondback says would be that you would just put vehicleController.lua to userfolder\lua\vehicle\controller without defining new controller if I understood correctly, but wouldn't that change all the mods and content too as long as mod is active? I did place modified vehicle controller as vehicleController.lua into userfolder\vehicles\etk800\lua\controller\ and that made change only to all etk800 vehicles, but that did change all of them, even manual ones. Also I did not define vehicle controller in jbeam files, just replaced the file. So I'm not sure if it is possible to affect only your own transmission mod, for me it appears as it is change all or nothing with these methods. Creating copy of etk800 as etk800awc or something would then limit change to that mod vehicle, but it would not reach the goal of altering vanilla vehicles.
"Always" means that vanilla vehicle is affected as well. Thanks for your help anyways Guess I'll have to stick to shiftLogic-automaticGearboxLogictest if without modifying vanilla vehicles, thanks for your explanation.
Only affect the very ETK800 with the "test 8-Speed Automatic Transmission (700T1400LM3)", when change the transmission back to vanilla automatic/manual, the vehicle will change back to BeamNG original control behavior
Ah ok, yea, replacing the full mainController on just a specific car is not supported and will lead to issues in some way or another.
You could technically make it a separate vehicle and implement the change there. Not sure if it's really worth it, it would increase the mod file size and would look messy in the selector.
I found that in the vehicleController.lua line 334 there is a Code: smoothedValues.drivingAggression = aggressionOverride or smoothedValues.drivingAggression How can I use the "aggressionOverride" to override the aggression value?
You can do that by calling "setAggressionOverride()" like so: Code: local aggression = 1 controller.getControllerSafe("vehicleController").setAggressionOverride(aggression)
It doesn't work apparently, at least not when placed on other lua. I guess at the end of the day I have to edit the vehicleController.lua if I want to modify further, and release a forum(non-repo) mod instead. Thank you anyway.