I have tried to do this before, and am still struggling with it. As you can see in some plane mods, there is a way to change "N" (or whatever gear the ui thinks the gearbox is in) to show the throttle percentage. I have tried doing this in a lua file in xp67(the name of the folder)/lua and in one that is a controller in xp67/lua/controller (i dont know if this matters) but no matter what I do, I not only cant get it to display throttle percentage, I cant get it to display anything. I have tried copying over the code from the strato hmx and the b25, both of which use the same code that I can find to do this, but that same code simply breaks the vehicle, with the error "attempt to compare string to number". Changing some things, I have managed to get it to not break the vehicle, but this doesnt work and also does not give any errors in the console. If anyone knows how to do this, it would be very apreciated! (lua file is attached below if anyone wants to look at it)
I haven't made vehicle mods so I might be wrong here but just looking at your code, I think the problem is that you set the electrics.values.gear variable to nil which is probably why the tacho app doesn't show anything. The use of tonumber() on a string that isn't a valid number gives nil. Your throttle_percent variable is already a number so you don't need tonumber() at all for this. Try this instead: Code: electrics.values.gear = string.format("%d%%", throttle_percent)
thanks for telling me to number doesnt work for what im doing, the code you sent doesnt work unfortunately. I do have a system for gui messages displaying throttle percentage so for now i can work with that.
The Gear display in the UI is generated from one of the "ShiftLogic" Lua files based on the transmission selected(lua/vehicle/controller/vehicleController/shiftLogic). The value is a return from the function getGearName() So in order to get custom values there you need a custom "ShiftLogic" file to for the UI to pull values from And in order to get the game to select your custom shiftLogic file despite not having an appropriate transmission you can define this variable to the vehicle controller in Jbeam. "vehicleController": { "shiftLogicName": "customFakeGeabox1", },
is "customFakeGearbox1" the name of the function in the lua? and by "custom shiftLogic" file do I just use an existing lua file or create a new one? sorry for asking, I haven't done much with lua in years so im very confused haha.
"customFakeGearbox1" is in this case it's the name of the lua file for that you want to use for shiftlogic. So if you make a lua file lua/vehicle/controller/vehicleController/shiftLogic/customFakeGearbox1.lua it would run that.