Lua file formatting

Hi
Is it possible to make it so when the game saves the lua file, it saves each section in a fixed order? That way we can compare the differences between two cars easily. Quite often I have two revisions of a car, but I forgot what I changed but cannot use a file comparison app because the sections are saved in what appears to be a somewhat random order…

I haven’t dug deep into the LUA files yet, but if this is true, this might pose a problem for AutomationHub. We are looking to allow users to upload their LUA file instead of making a statistics screenshot.
Looking forward to an answer from the devs for this one and see what is possible. To me it sounded normal that it saved everything in the same order.

I thought file sections were saved in the same order, but table numbers will not correspond to each other, because the size of each section depends on what you put in there. In particular, each fixture occupies a table, so if you have heaps of fixtures on your car, expect the engine power info (I think) to be pushed way down the order!

It’s going to be a pain to move my fixtures over to the steam release, because the files will definitely not be compatible!

I read in .lua files automatically for the CTC and BRC challenges with a script, so it is possible. It requires some workarounds because of the different length of the files, but if you handle the content properly (i.e. search for strings and not for line numbers), it’s not a big problem.

That’s what my thought was for the LUA script for AutomationHub. I would search for something like Reliability for example and put that number in a variable and then display it on the website.
Will look into it further later on. I’ll contact you through PM later.

Does this mean Reliability comes for both engine and car, and has a different tag? or is it both called reliability or EngineReliability and CarReliability?

The table system is pretty simple, but tough to read in an editor. For reliability settings, you’ll have to find the table of contents to determine which table it will be found in. Table 4, in the example below, is the place to find it. Looking at the table, you’ll see “Results” are on Table: {9}.

– Table: {x} denotes the beginning of a table. Table: {4}
“item”] denotes an item within the table. “Results”]
If the item contains an integer without brackets, then it is data. “Revision”]=0,
If it contains an integer contained within curly brackets, it is referencing another table. “Results”]={9}

-- Table: {4} { "UID"]="3adfa088-3887-11e4-aa7d-f79c88d3b09d", "Downforce"]=1, "EnginePoint"]={6}, "SuspensionDetails"]={7}, "Revision"]=0, "Entertainment"]={8}, "CoolingAirflowFraction"]=0.18, "Results"]={9}, "SoundInsulation"]=0.5, "EngineInfo"]={10}, "TyreDetails"]={11}, "InclinationRear"]=0.22, "Brakes"]={12}, "BrakeCoolingFraction"]=1, ... }

If we move to Table 9, as indicated by the previous information, we can find what we’re looking for. Some will reference other tables, while others will give us integer data. Some integer data is simple to read, while others are more cryptic. For example, the weight of this car is 1602.9kg. The top speed is 244.6km/h. Tameness will be shown on Table: {44}. The 0-62 mph time is 6.7s. You get the idea. Average reliability for this car is 60.8.

-- Table: {9} { "Weight"]=1602.9138298396, "TopSpeed"]=244.54816343949, "Tameness"]={44}, "HundredTime"]=6.6649999999999, "Offroad"]=27.514675401094, "KilometerSpeed"]=202.20807699553, "LargeCircleTest"]={45}, "SixtyTime"]=3.7999999999999, "HighSpeedcg"]={46}, "BrakingDistance"]=40.897647118499, "TwoHundredTime"]=25.805, "EffArea"]=0.93500599864047, "TotalCosts"]=9520.4427653345, "PassengerVolume"]=3837.4151981849, "Comfort"]={47}, "Prestige"]={48}, "Reliability"]=60.845412614576, "QuarterMileSpeed"]=163.54816415596, "Safety"]={49}, "cg"]={50}, "Sportiness"]={51}, "KilometerTime"]=26.555, "HundredAndTwentyTime"]=9.0649999999998, "EightyTime"]=5.2249999999999, "Cost"]=7013.8812877232, "Utility"]=46.662585761657, "SuperTyresBrakingDistance"]=33.613746326759, "EnvironmentalResistance"]=77.829948967516, "ManHours"]=143.23208443493, "EightyToHundredAndTwentyTime"]=3.8399999999999, "CargoVolume"]=495.6184387207, "QuarterMileTime"]=14.945, "SmallCircleTest"]={52}, "Failures"]={53}, "ServiceCosts"]=2184.4359684765, "Stiffness"]=3457.1428571429, "Economy"]=13.842777269086, "WheelSpinFraction"]=0.446, },

The keyword “Reliability” is listed for multiple items used on the car, so it would be tough to search for by itself. Here is the reliability for the Rear Suspension:

-- Table: {34} { "LiveAxle"]=true, "MaxInsideWidth"]=50, "Comfort"]="VeryLow", "Production"]={140}, "RollCentre"]=-0, "UnsprungWeight"]=70, "Sportiness"]="VeryLow", "OneMesh"]=true, "PosData"]={141}, "Offroad"]="High", "Weight"]="High", "MeshPart2"]="LIVELEAF", "MeshPart"]="LIVELEAF", "Name"]="Suspend_SolAxLeaf_Name", "MidEngine"]=false, "ManHours"]="VeryLow", "Compactness"]="High", "Section"]="Chassis", "Tameness"]="VeryLow", "CanBeDriven"]=true, "Reliability"]=95, "CamberChange"]={142}, "LoadCapacity"]="ExtremelyHigh", },

After looking through the LUA files for a bit, you can start to understand how to find things, and what is located where. They are not the same for every LUA file, as the order depends on the items used. I’m sure this is probably way more than you wanted to know. :wink:

My suggestion was would it be possible to always have the contents of table 4 (in this case looks like overall car info) in table 4, and within that table, always have those items in the same order. For example the file may look like this initially:

-- Table: {4}
{
   "UID"]="3adfa088-3887-11e4-aa7d-f79c88d3b09d",
   "Downforce"]=1,
   "EnginePoint"]={6},
   "SuspensionDetails"]={7},

If I make a change, it may look like this after:

-- Table: {4}
{
   "UID"]="3adfa088-3887-11e4-aa7d-f79c88d3b09d",
   "EnginePoint"]={6},
   "Downforce"]=1,
   "SuspensionDetails"]={7},

If diff the files, it will say they are different, even though they are the ‘same’.

[quote=“utopian201”]My suggestion was would it be possible to always have the contents of table 4 (in this case looks like overall car info) in table 4, and within that table, always have those items in the same order. For example the file may look like this initially:
[/quote]

But you don’t need that if you parse the LUA correctly. Try not to compare the Text but the contents of the tables.

I’m not doing anything to parse the lua files, I’m just literally loading them up into a file comparison program.

But you don’t need that if you parse the LUA correctly. Try not to compare the Text but the contents of the tables.[/quote]

I know this. But that’s why my question was there. I was wondering if certain names would re occur, like reliability. Reliability comes with both car and engine, so if both are named the same but somewhere it says that the engine is in Table[x] and car reliability in another, it wouldn’t work.

For utopian, it would be best if they reserved the first 20 tables for all specs, and anything that has to do with changing numbers, like the amount of fixtures, always come after the spec tables.
This would be great for us too, in my opinion. Much easier to understand without the changing tables.

Off topic, but when you’re parsing the table, for each field in the table, wouldn’t you know which table you’re parsing? In which case, even if you saw two identical tags, you would see one as for engine because it was in the engine table, and the one in the car table would be reliability for the car?

I didnt dig into the LUAs yet. If the tables have a name, that wouldnt be a problem. But as far as I saw they are named Table 1 2 3 4 5… etc. This got me wondering…

Anyway, looking forward to a reply from the devs to clear some things up and see what is possible and what not.

Tables don’t have a name, as 07CobaltGirl mentioned, the tables are referenced like
“EngineInfo”]={10},
“TyreDetails”]={11},

So you know table 11 is TyreDetails. As you read in the lua file, you could build up a dictionary or lookup table so when you have read in the file, you know which table is at which number.

I don’t want to cover all of the LUA file for models, but here are some simple basics.

Table: {1} always remains the same. It defines Tables 2-5 and tells you QualityBase.

-- Table: {1} { "TechPool"]={2}, "TechPoolUsed"]={3}, "ModelInfo"]={4}, "PlatformInfo"]={5}, "QualityBase"]=0.94, },

Table 2-5 always remain the same information, but not necessarily organized the same within each table. This means: Table 2 is always TechPool. Table 3 is always TechPoolUsed. Table 4 is always ModelInfo. Table 5 is always PlatformInfo. Items within any given table beyond this (other than Table 1 which is constant order/content) can vary in content and order, depending on the car and the user.

-- Table: {4} { "UID"]="3adfa088-3887-11e4-aa7d-f79c88d3b09d", "Downforce"]=1, "EnginePoint"]={6}, "SuspensionDetails"]={7}, "Revision"]=0, "Entertainment"]={8}, "CoolingAirflowFraction"]=0.18, "Results"]={9}, "SoundInsulation"]=0.5, "EngineInfo"]={10}, "TyreDetails"]={11}, "InclinationRear"]=0.22, "Brakes"]={12}, "BrakeCoolingFraction"]=1, "Seats"]={13}, "Undertray"]={14}, "Springs"]={15}, "Dampers"]={16}, "InclinationFront"]=0.78, "GameVersion"]=1417, "FakeWeightFraction"]=0, "Name"]="07CobaltGirl-CTC2 Entry", "Gearbox"]={17}, "Tyres"]={18}, "Interior"]={19}, "ActiveAero"]={20}, "QualitySettings"]={21}, "Safety"]={22}, "GearboxPoint"]={23}, "FakeWeightDistributionFraction"]=0.5, "Assists"]={24}, },

EngineInfo Table Reference will always be in Table 4. The table reference can change, but will always be referenced here. The file I am currently using references EngineInfo as being located on Table 10.

-- Table: {10} { "RPMLimitSetting"]=0.3, "ExhaustDiameterSetting"]=0.2, "BoostCutOffFraction"]=0.26666666666667, "BlockType"]={54}, "EngineBayBounds"]={27}, "FlyWheelWeight"]=15, "ExhaustBypassValves"]={55}, "Valves"]={56}, "Intercooler"]={57}, "GameVersion"]=1417, "ARRatioFraction"]=0.5, "StrokeSetting"]=0.64714285714286, "RPMLimit"]=5000, "VVT"]={58}, "VVLCamProfileSetting"]=0.6, "AspirationType"]={59}, "FuelSystemType"]={60}, "TechPoolUsed"]={61}, "Aspiration"]={62}, "EngineBounds"]={63}, "TurboMode"]="Custom", "VVL"]={64}, "IntakeManifold"]={65}, "AFR"]=14, "Bore"]=104.8, "Scales"]={66}, "Intake"]={67}, "FactoryInfo"]={68}, "ExhaustCount"]={69}, "UID"]="39ab8829-3881-11e4-aa7d-f79c88d3b09d", "RockerColour"]=52, "BoreSetting"]=0.78285714285714, "ExhaustDiameter"]=2, "Muffler1"]={70}, "Crank"]={71}, "BlockConfig"]={72}, "Pistons"]={73}, "CamProfileSetting"]=0.64, "Name"]="6.6L FP 16V OHV", "Headers"]={74}, "CompressionSetting"]=0.38888888888889, "Conrods"]={75}, "QualitySettings"]={76}, "Display"]={77}, "VisualScale"]=1.473533070669, "BlockMaterial"]={78}, "Capacity"]=6.5765077129878, "Revision"]=0, "CoolingCapacity"]=239.21087171315, "TurbineFraction"]=0.5, "RockerCount"]=4, "ARRatio"]=0.8, "IgnitionTimingSetting"]=0.81, "Cat"]={79}, "BoostCutOff"]=0.8, "FuelType"]={80}, "CompressorSize"]=68.5, "Stroke"]=95.3, "AFRSetting"]=0.8, "Compression"]=9.5, "Muffler2"]={81}, "TurbineSize"]=67.5, "FlyWheelSetting"]=0.5, "EngineSize"]={82}, "FuelSystem"]={83}, "GeneratedNameUsed"]=true, "TechPool"]={84}, "AspirationOption"]={85}, "Results"]={86}, "HeadMaterial"]={87}, "AFRLean"]=15.17421875, "QualityBase"]=0.45, "CompressorFraction"]=0.5, "Head"]={88}, },

If you scroll through Table 10, you’ll find Results referenced on Table 86.

-- Table: {86} { "PartsFailureInfo"]={164}, "Weight"]=315.59829810483, "Emissions"]=317773.65644946, "BaseEcon"]=319.49524371429, "FlyWheelWeight"]=15, "peakTorque"]=4100, "PeakPower"]=246.67801046144, "WorstEcon"]=828.6899063111, "GameVersion"]=1417, "Idle"]=500, "PartsMaxRPM"]=6313.8409106904, "Smoothness"]=42.674399914099, "RON"]=97.984529532943, "MinEconRPM"]=3700, "BaseVE"]=0.8968, "TotalCost"]=2545.7109997842, "ManHours"]=46.835546875, "MaterialCost"]=1726.0889294717, "ServiceCost"]=2731.83227379, "MTTF"]=41.481658750923, "Econ"]=495.91023346403, "EconEff"]=15.511492147632, "CoolingRequired"]=232.32572643509, "PeakBoost"]=0, "Responsiveness"]=28.958428556906, "PeakPowerRPM"]=4500, "rpm"]=5000, "ExhaustNoise"]=52.4533, "Curves"]={165}, "IntakeNoise"]=22.5, "LowestRON"]=98, "MTTFIssues"]={166}, "AdjustedAFR"]=13.25, "Restrictions"]={167}, "BaseTorque"]=783.78818923389, "torque"]=541.94205834764, "Noise"]=59.820649, "AverageCruiseEcon"]=495.91023346403, "IntakeKWRestriction"]=733.09350515416, "MinEcon"]=444.2513591792, "TurboCurves"]={168}, "PeakBoostRPM"]=0, },

“MTTF”]=41.481658750923, located on Table 86 above, is the only line I can find which could reference Engine Reliability.