the errors are red, yes. the rear engine isnt running separately, just starting and stopping, but im now going to add parts into the controller to do them separately. i assume if i only have the covetVehicleController in the main jbeam i dont have to include it in the individual parts? this would solve the duplicate controller error second drivetrain isnt shifting just yet, but i feel like im getting close.
Well , don't forget that the name of your custom vehicle controller ( covetVehicleController ) needs to be called there where needed. By every change you make in it, you need to think where the change takes place, it might be a jbeam file with a "controller" section.. Are you going to try and keep your engines in total sync or will you add extra combustionEngine.lua and then the rest of the "dominos" ?
i added an extra combustionengine lua nad assigned it but i dont think i will do anything with it for now, later i might because the exhaust and engine sound isn't working properly. for now i want to get the gearbox working, and i think the problem currently is that the main controller isnt finding the rear gearboxes shiftlogic, its only finding the front one. the way i thought to get around this would be to change the shiftlogic file to a rearshitlogic file and add in a copy of this line local controlLogicModuleName = "controller/shiftLogic-" .. controlLogicName but change it to local rearControlLogicModuleName = "controller/rearShiftLogic-" .. controlLogicName and then change the local functions to reflect that addition, but it didnt seem to make a difference. any ideas? i know the inputActions are getting to the maincontroller, but they just arent getting to the shiftlogic file
Hold on, you don't need to make changes over there ↑ ↑ because it's already done for you !! That code says for every name you give the gearbox lua , put "shiftLogic-" in front of it and your file will be found. No, you just must have gotten some combination off somewhere. To answer your last question : The main controller 'commands' the shift logic and the shift logic 'commands' the gearbox. In main controller you find : local function shiftUp() controlLogicModule.shiftUp() end clearly pointing out to the shift logic ( controlLogicModule ) In the shift logic you find : local function shiftUp() local prevGearIndex = gearbox.gearIndex local gearIndex = newDesiredGearIndex == 0 and gearbox.gearIndex + 1 or newDesiredGearIndex + 1 gearIndex = min(max(gearIndex, gearbox.minGearIndex), gearbox.maxGearIndex) if M.gearboxHandling.gearboxSafety then local gearRatio = gearbox.gearRatios[newDesiredGearIndex] if gearbox.outputAV1 * gearRatio > engine.maxAV then gearIndex = prevGearIndex end end if gearbox.gearIndex ~= gearIndex then newDesiredGearIndex = gearIndex M.updateGearboxGFX = gearboxLogic.whileShifting end end the local function itself written out at the end the gearbox lua listens : local function setGearIndex(device, index) local oldIndex = device.gearIndex local maxIndex = min(oldIndex + 1, device.maxGearIndex) local minIndex = max(oldIndex - 1, device.minGearIndex) local target = min(max(index, minIndex), maxIndex) if oldIndex ~= 0 then device.targetGearIndex = target else device.gearIndex = target device.gearRatio = device.gearRatios[device.gearIndex] local maxExpectedOutputTorque = device.maxExpectedInputTorque * device.gearRatio device.invMaxExpectedOutputTorque = 1 / maxExpectedOutputTorque if device.gearRatio ~= 0 then powertrain.calculateTreeInertia() end selectUpdates(device) end end That's it in a nutshell, the family of three Same goes for shiftDown and shiftToGearIndex , the first two look differerent but the gearbox lua example serves up down and index of course It's not necessary to completely understand the code from where you stand. It's just important to assign one thing to the other in a way that it works. So, again : Your new gearbox (new means new name) needs a controller (new name). The controller needs its commands from the main controller, your new main controller. New means: different name Only wright a new function (for example : copy function and rename ) there where necessary. I think the two shift logic files are going to listen to the one controlLogicModule name in the main controller. If I was making the mod I would have found out stuff quickly but currently for me this is a training in calculating effectiveness --- Post updated --- edit : about adding that new controlLogicModuleName, that would probably work if you change every controlLogicModule condition by that new name. I think that's too much investment risking no result. Try to keep as simple as possible til result, then expand if needed. --- Post updated --- edit 2 : another take I would consider is : first try to get all renamed parts to work independently from your first drive train. So the rear engine and its gearbox plus drivetrain would drive the vehicle.
ok so with my understanding, this should work in input_actions.json i make a controll called covetRearShiftUp, and bind it to controller.mainController.covetRearShiftUp in covetVehicleController I add in M.covetRearShiftUp = covetRearShiftUp and local function covetRearShiftUp() controlLogicModule.covetRearShiftUp() end (if i make it controlLogicModule.shiftUp it will shift the front gearbox as well which i dont want) in hatch.jbeam i replace vehicleController with covetVehicleController in rearGearbox.jbeam i make powertrain type covetRearSequentialGearbox in the lua/powertrain folder i add in a covetRearSequentialGearbox.lua, which is just a renamed copy of the sequentialGearbox.lua in the lua/controller folder i add in shiftLogic-covetRearSequentialGearbox.lua, which is a copy of shiftLogic-sequentialGearbox.lua in my shiftlogic-covetRearSequentialGearbox.lua i replace M.shiftUp = shiftUp with M.covetRearShiftUp = shiftUp this makes sense to me and looks like it should work however, when im in game and i use my covetRearShiftUp binding, i get this console error *** FATAL LUA ERROR: vehicles/hatch//lua/controller/covetVehicleController.lua:513: attempt to call field 'covetRearShiftUp' (a nil value) =============== Stack Traceback >> START >> (1) Lua field 'covetRearShiftUp' at file 'vehicles/hatch//lua/controller/covetVehicleController.lua:513' Local variables: (*temporary) = nil (*temporary) = nil (*temporary) = string: "attempt to call field 'covetRearShiftUp' (a nil value)" (2) main chunk of string at line 1 --------------- << END << *** while executing this line: controller.mainController.covetRearShiftUp() *** in chunk: string now, i tried a lot of things, so i know when i change the local function for covetRearShiftUp in the main controller to controlLogicModule.shiftUp it shifts the front gearbox, so i at least know that my inputs are getting that far to me it seems like the maincontroller isnt finding my shiftlogic file, but i dont know why. are you seeing anything im missing? saw your edit to make the rear powertrain work when the front is missing, good idea. currently when i do it the gearbox is stuck in neutral, when normally its stuck in first. ill give it some work tomorrow
--- Post updated --- You see ? The function in shift logic needs that new name you gave to it in covetVehicleController ! Also , stay away (for now) from renaming controlLogicModule name(s).
you mean that in the maincontroller local function covetRearShiftUp() controlLogicModule.covetRearShiftUp() end needs to have the same name as the shiftlogic file like this M.covetRearShiftUp = shiftUp because if so, ive done that and it still doesnt work
You're mixing stuff up too much and I understand that. It's very difficult to get something (big) working for the first time. You need to make subtle changes with quick results and then expand from there.. Look, if you want you can pm me your mod and I can take a look at it.
Man you have done an OUTSTANDING job so far ! Can I post a vid of it here in the thread so everyone can see what you are up to ? ( your choice ) There clearly is sound from two engines, they both start and shut down, front one shifts and has a drive, rear one starts while it has drive to the rear wheels. I made no changes before this first test, just selected parts in a specific way. I also haven't tried to assign shift controls to the rear gearbox yet. only assigned the rear engine starter key. Alright, I'm going to engage some further testing now (to get my mind off my CTK-28 mod a bit phew )
ah yeah, i wrote that wrong. what i meant was that the sound from the rear engine is using the same sound files as the front engine. its meant to be using the pigeon sound files, but sounds like a covet. if you deselect the front engine it sounds like a pigeon. its a problem that i will try to tackle some time but is low on the priorities list also you can absolutely post a video, ive been having fun with it just with the direct drive, i love the sound of 2 engines
Alright, here it is Look, you have : 1) mixed up a lot concerning the names of the functions and the M.type stuff I kept warning you about 2) You have done a lot of damage to your second engine and gearbox files by adding 'rear' + capital of next orig word EVERYWHERE About that last point, these changes are taking no effect anywhere, because all the 'rear' 's added to your jbeam files cannot be found by your lua files. I checked all lua files that supposed to be involved with your second engine by simple ctr + f ( find function) on the word 'rear' and none of them contain it ! Meaning that second engine is running on first engine files anyway. I need to think on how to approach that specific problem in particular, first I'm going to see if I can crank your second gear box. --- Post updated --- Oh before I continue I want to clarify that 'rear' does take effect on half of the features, because you adapted the main controller in that way, good job so far.
--- Post updated --- Of course you can, that's not the point The coding to make it work, that's the point..
Ok, what I've got so far is this ↓ 2 complete separate drive trains (from engines to wheels) stemming from one shift logic file BUT.. only one at a time is driveable so far. It's very complicated. Anyway, by changing one detail in the shiftLogic-covetReatSequentialGearbox you switch from front drive train to rear. Both engines and clutches keep functioning all the time though. I'm sending you the files (hopefully I sorted them right) so you can try it out. I'm still working on the problem to solve the lack of combining both drive trains. --- Post updated --- Oh I forgot to mention where to make the change (switch) It's at line 394 = change "rearGearbox" to "gearbox" or the other way around.
doesnt seem to be working for me, i think you might've gotten some files confused or ive fucked something up but ill take your word for it . i see some of the changes youve made, like forcing the vehiclecontroller to use the specific shiftlogic file im feeling like this maybe wasnt the easiest thing to do for my first mod lol, thanks for helping
Not working ? Don't forget to assign your new shift controls, they are still the ones you made and the gearing for both front and rear are controlled by them, not the standard gear controls. I will check again anyway when I've some time. --- Post updated --- Yep, confirmed. Just put zip I've send in mods folder, assign new gear controls and the rear drive train drives. Then put in your user folder under vehicles a map called 'hatch/lua/controller/shiftLogic-covetRearSequentialGearbox.lua (my version of this file of course). Go to local function init() : local function init(jbeamData, sharedFunctionTable) sharedFunctions = sharedFunctionTable engine = powertrain.getDevice("mainEngine") gearbox = powertrain.getDevice("rearGearbox") → → switch between "rearGearbox" and "gearbox" newDesiredGearIndex = 0 "rearGearbox" drives the rear engine and rear drive train. "gearbox" drives the front engine and front drive train. --- Post updated --- Yep, confirmed. Just put zip I've send in mods folder, assign new gear controls and the rear drive train drives. Then put in your user folder under vehicles a map called 'hatch/lua/controller/shiftLogic-covetRearSequentialGearbox.lua (my version of this file of course. Go to local function init() : local function init(jbeamData, sharedFunctionTable) sharedFunctions = sharedFunctionTable engine = powertrain.getDevice("mainEngine") gearbox = powertrain.getDevice("rearGearbox") → → switch between "rearGearbox" and "gearbox" newDesiredGearIndex = 0 "rearGearbox" drives the rear engine and drive train. "rearGearbox" drives the rear engine and drive train. But you where 'quite into it' from the start so that's why I jumped in
yeah i tried it again and it worked perfectly, idk what i did wrong the first time. So to get both drivetrains working at the same time, whats the best way to do it? would it be to make the vehicle controller have a second bit with seperate names to use a second shiftlogic file, or would it be to modify the one shiftlogic file to control both gearboxes? i tried modifying the shiftlogic file to control both but didnt have much luck, probably because i dont know what im doing
You see, that's EXACTLY what I mean ! You are always right on target of the matter (code wise) ! You have an excellent code understanding Well this is exactly the problem I've been trying to tackle for hours and I haven't got time yet to give it second thoughts. In the case of your mod the vehicle controller is the most stubborn of the two to work with. It has very probably to do with the fact that two engines (running at the same time) are involved. My CTK 28 mod accepts more vehicle controllers. It's not possible to achieve through a single main controller, the controller only refers to the functions shiftUp and shiftDown etc... So yes my current vision is writing a combo shift logic file that handles both gearboxes, very complicated thus. I've been trying shortly after I got current result, but I was too tired to stick to the essentials. I even tried to make a double 'M table' shift logic file with the second table named 'rM' ( 'r' for rear ) but that is too far fetched I guess. I think the solution lies in - for every 'currentGearIndex' , 'newDesiredGearIndex' and all other statement conditions related to shifting there needs to be a 'rear' counterpart included. A big problem is also the 'gear.type' statement/condition. It's also difficult to spilt it up into 'two business ends'. And gear.type directly refers to controlLogicModuleName. Maybe if that works the two shift logic files can be used afterall. If things get too complicated I always try to reverse and simplify. So my final thought so far is : The creation of a double gearbox. Gearbox 1 listens to a part of the shift logic file and Gearbox 2 listens to another part of the same shift logic file. Again, I've had no time so far to 'proceed investigation'.
An update i've tried both getting the shiftlogic file to control both gearboxes, and getting the vehicle controller to have 2 shiftlogic files. I think both times ive had problems with this line in the rearShiftUp function in the shiftlogic file M.updateGearboxGFX = gearboxLogic.whileShifting when shifting the rear gearbox in game i get this console error 46099.04343|E|libbeamng.lua.V|*** FATAL LUA ERROR: ...lua/controller/shiftLogic-covetRearSequentialGearbox.lua:97: attempt to index upvalue 'gearboxLogic' (a nil value) 46099.04345|E|libbeamng.lua.V|=============== Stack Traceback >> START >> 46099.04347|E|libbeamng.lua.V|(1) Lua field 'covetRearShiftUp' at file 'vehicles/hatch//lua/controller/shiftLogic-covetRearSequentialGearbox.lua:97' 46099.04348|E|libbeamng.lua.V| Local variables: 46099.04349|E|libbeamng.lua.V| prevGearIndex = number: 0 46099.04350|E|libbeamng.lua.V| gearIndex = number: 1 46099.04351|E|libbeamng.lua.V| (*temporary) = table: 0x01e14d4d0638 {ignition:true, maxGearIndex:6, minGearIndex:1, smoothedAvgAVInput:0, covetRearShiftToGearIndex:function: 0x01e14d4dd5c8 (more...)} 46099.04352|E|libbeamng.lua.V| (*temporary) = nil 46099.04353|E|libbeamng.lua.V| (*temporary) = number: 1 46099.04354|E|libbeamng.lua.V| (*temporary) = number: 6 46099.04355|E|libbeamng.lua.V| (*temporary) = number: 1 46099.04356|E|libbeamng.lua.V| (*temporary) = number: -1 46099.04358|E|libbeamng.lua.V| (*temporary) = string: "attempt to index upvalue 'gearboxLogic' (a nil value)" 46099.04359|E|libbeamng.lua.V|(2) Lua field 'covetRearShiftUp' at file 'vehicles/hatch//lua/controller/covetVehicleController.lua:518' 46099.04360|E|libbeamng.lua.V|(3) main chunk of string at line 1 46099.04361|E|libbeamng.lua.V|--------------- << END << 46099.04364|E|libbeamng.lua.V|*** while executing this line: controller.mainController.covetRearShiftUp() 46099.04366|E|libbeamng.lua.V|*** in chunk: string if i keep shifting the rear gearbox the numbers change, so it seems to me like its getting the table from the jbeam and is changing the gearIndex value, its just not changing the actual state of the gearbox, which i think is controlled by that last part. ive looked over the controller, shiftlogic and gearbox luas and i havent found the problem yet, any ideas?
I'll check this asap Look I found that in the state I send it to you both gearboxes ARE working simultanously. It's just that the rear one can't be controlled so far. Check this out : hang the car, like you saw me doing, go to the rear gearbox jbeam file, and change the value of gearratio '0' (the neutral) to a value. You will find both drivetrains running.