Hello, I built a simulator using simhub and managed to control the real cluster of a citroen c4 using CAN and arduino.
However I am using ETS2 games and other racing games.
I created a Ncalc text for ets2, where it can control the cluster with rmp, speed, fuel, high and low lights, flashing etc...
and then I managed to make the other games work too, however the other games do not use some functions that ETS2 uses, like high and low lights for example, and since these codes are specific to the ets2 game, the other games cannot handle the code and the cluster does not work.
For that I had to create 2 different texts, one for ets2 and the other putting the ISNULL TAG before the lines that don't exist in the other games, so the other games can work normally, but I always have to change the text to the ets2 version when I want to play ets2 and switch to the other isnull-modified text when I want to play the other games.
I wanted help to be able to join these 2 texts into just one that satisfies the 2 games, considering that the variables that are not found in a game will be disregarded by it and the variables that are found in the game are used because it has them.
below text I use in ets2
format([SpeedKmh],0)+';'
+format([Rpms],0)+';'
+format([DataCorePlugin.Computed.Fuel_Percent],0)+';'
+format([TurnIndicatorLeft],0)+';'
+format([TurnIndicatorright],0)+';'
+([GameRawData.TruckValues.CurrentValues.LightsValues.BeamHigh])/1+';'
+([GameRawData.TruckValues.CurrentValues.LightsValues.BeamLow])/1+';'
+([GameRawData.TruckValues.CurrentValues.LightsValues.DashboardBacklight])/1+';'
+format([EngineIgnitionOn],0)+';'
+([GameRawData.TruckValues.CurrentValues.DashboardValues.WarningValues.AirPressure])/1+';'
+([GameRawData.TruckValues.CurrentValues.DashboardValues.Wipers])/1+';'
+format([EngineIgnitionOn],0)+';'
+([GameRawData.SpecialEventsValues.Refuel])/1+';'
+([GameRawData.TruckValues.CurrentValues.MotorValues.BrakeValues.ParkingBrake])/1+';'
below text I use in other games
format([SpeedKmh],0)+';'
+format([Rpms],0)+';'
+format([DataCorePlugin.Computed.Fuel_Percent],0)+';'
+format([TurnIndicatorLeft],0)+';'
+format([TurnIndicatorright],0)+';'
+isnull([GameRawData.TruckValues.CurrentValues.LightsValues.BeamHigh])+';'
+isnull([GameRawData.TruckValues.CurrentValues.LightsValues.BeamLow])+';'
+isnull([GameRawData.TruckValues.CurrentValues.LightsValues.DashboardBacklight])+';'
+format([EngineIgnitionOn],0)+';'
+isnull([GameRawData.TruckValues.CurrentValues.DashboardValues.WarningValues.AirPressure])+';'
+isnull([GameRawData.TruckValues.CurrentValues.DashboardValues.Wipers])+';'
+format([EngineIgnitionOn],0)+';'
+isnull([GameRawData.SpecialEventsValues.Refuel])+';'
+isnull([GameRawData.TruckValues.CurrentValues.MotorValues.BrakeValues.ParkingBrake])+';'
I advance that both texts are working perfectly in the games I have and tested, I just need to unite the 2 in 1 that satisfies both without failing to meet each variable or ignoring it if the game does not have this variable available.
But that both work fine.
some information, in the text I made for the ets2 game, the line of the variables specific to this game, return false or true, I noticed that putting "/1" it transforms the result into 0 or 1, so I managed to use it on the arduino, but I don't know if I did it correctly, but it works perfectly for me.
Thanks for all the help available.
no one has any idea?
no one has any idea?
Hi there,
This may be too late for you, but you can use the name of the game to branch off for different results.
I’m not on a PC at the moment, but I think the property is something like [current.game]
So, you could use something like:
if ([current.game] = ‘ets2’, {ets2 code} , {other games code})
I will update this post with a better example tomorrow if you still need it.
Here's your code now wrapped in an if statement. If the current game is ETS2 or ATS, then your ets2 code is executed, otherwise your non-ets2 code is executed.
if([DataCorePlugin.CurrentGame] = 'ETS2' or [DataCorePlugin.CurrentGame]='ATS',
format([SpeedKmh],0)+';'
+format([Rpms],0)+';'
+format([DataCorePlugin.Computed.Fuel_Percent],0)+';'
+format([TurnIndicatorLeft],0)+';'
+format([TurnIndicatorright],0)+';'
+([GameRawData.TruckValues.CurrentValues.LightsValues.BeamHigh])/1+';'
+([GameRawData.TruckValues.CurrentValues.LightsValues.BeamLow])/1+';'
+([GameRawData.TruckValues.CurrentValues.LightsValues.DashboardBacklight])/1+';'
+format([EngineIgnitionOn],0)+';'
+([GameRawData.TruckValues.CurrentValues.DashboardValues.WarningValues.AirPressure])/1+';'
+([GameRawData.TruckValues.CurrentValues.DashboardValues.Wipers])/1+';'
+format([EngineIgnitionOn],0)+';'
+([GameRawData.SpecialEventsValues.Refuel])/1+';'
+([GameRawData.TruckValues.CurrentValues.MotorValues.BrakeValues.ParkingBrake])/1+';'
,
format([SpeedKmh],0)+';'
+format([Rpms],0)+';'
+format([DataCorePlugin.Computed.Fuel_Percent],0)+';'
+format([TurnIndicatorLeft],0)+';'
+format([TurnIndicatorright],0)+';'
+isnull([GameRawData.TruckValues.CurrentValues.LightsValues.BeamHigh])+';'
+isnull([GameRawData.TruckValues.CurrentValues.LightsValues.BeamLow])+';'
+isnull([GameRawData.TruckValues.CurrentValues.LightsValues.DashboardBacklight])+';'
+format([EngineIgnitionOn],0)+';'
+isnull([GameRawData.TruckValues.CurrentValues.DashboardValues.WarningValues.AirPressure])+';'
+isnull([GameRawData.TruckValues.CurrentValues.DashboardValues.Wipers])+';'
+format([EngineIgnitionOn],0)+';'
+isnull([GameRawData.SpecialEventsValues.Refuel])+';'
+isnull([GameRawData.TruckValues.CurrentValues.MotorValues.BrakeValues.ParkingBrake])+';')