How to edit saved engines by modifying the .lua file?

Is it possible to use a C++ program to edit the save files of an engine to give the same effects of changing the parts and values. If it is possible then if someone could point me towards what I would need to edit then I would very much appreciate it. Also, a bit of digging made me think that at least some stats of the engine are kept in the save file, so if someone knows where all of those are it would be fantastic.

The reason I’m asking is that I have some coursework coming up where I have to make a “novel application” that uses aspects of swarm intelligence or artificial life. One idea I had was to make some sort of swarm intelligence based optimiser (evolutionary computing or particle swarm optimiser probably), and I figured a novel and relevant thing to apply it to would be engine design (albeit in automation rather than real life, and probably only demo compatible engines so that the university can try the code out themselves).
However, there is no way I would even contemplate making one right now unless it was possible to at least edit the parts and values of the engine by using a C++ program to edit the .lua text file for the engine, because it would take hours to do all that by hand. I would also like to be able to grab some stats from the engine, such as fuel economy, reliability, cost, man hours or power.
What I had in mind was to get the c++ program to edit a small population of engine files that I had created myself, then I would test them all and save them, then the program would grab the results if possible (or I would manually grab the results if not). that cycle would keep happening until the engines became good enough, or I became bored enough, and then I would stop the program and grab the stats of the best engine.

So if anyone can point me to which lines I would have to edit I would be most grateful

Hi, Reaper392

You can use the standard Notepad program to edit the .lua files (or get Notepad++ if you don’t have Notepad) Just right click on the file and click ‘Open with…’ and click Notepad. Then scroll down until you find the followung text. These will be where you edit the engine stats
Size: Table: {1} “Capacity”]
Version: Table: {1} “GameVersion”]
Power in kW: Table: {21} “PeakPower”]
Torque in Nm: Table: {21} “torque”]
Cost: Table: {21} “MaterialCost”]
Man Hrs: Table: {21} “ManHours”]

Hope this helps,
Aaron

You just copied and pasted my post from another forum. At least use the quote function…

Thanks for finding my thread and letting me know about that. I had seen Jakgoe’s post in the other thread but I do appreciate it because knowing where the stats are all saved in the .lua file will be very helpful if i ever get round to doing this project.

Since the thread has been bumped and may be seen by some fresh faces, here is a breakdown of exactly what I was asking (because it is about as clear as mud in the OP) and what I have learned so far from chatting with the devs in live chat and through my own testing:

1. Can a C++ program written in visual studios edit .lua files as if they were text files
I haven’t checked yet so I still don’t know. This involves me finding out how to do file editing in C++ because I haven’t done it before. Any advice on this point would be very much appreciated

2. Can I get the stats of the engine from the .lua file?
Yes (thanks Jakgoe and pleb for the location)

3. Can I edit the parts of the engine in the .lua file by changing a sensible amount of text
Yes. While there is a large amount of stats for each part, I only need to change one or two lines in the file to a known name and then resave that .lua file. the part will then be switched in the game

4. Can I isolate the text I need to edit with very basic text searching
Yes. While there isn’t a unique identifier just before the bits I need to edit, I can probably find the correct table to edit and then find the identifier I need. Also, the bits I need to edit are all within quotes, which will probably help a lot.

5. Do i get the correct stats from the switched part?
Yes, but only after the engine has been reloaded (and possibly retested?). Thankfully there don’t seem to be any fail safes that look at more than just the name of the part before choosing the part to load.

6. Can i change the values of sliders by editing the values in the .lua file?
Possibly. From my digging around in the .lua files there are some values that seem to correspond to what the sliders control, but the scale on the slider doesn’t seem to fit with the scale in the file very obviously for the values I had a quick look at. Some more information on this would be great

From that, it looks like it should be possible to have my program edit the parts of the program, wait for me to retest them, and then read the scores in preparation for the next iteration of testing. Given an engine with a suitable setup with the sliders it should be enough to let me get some interesting results from the program (such as balancing cost, man hours and one or two other stats), but if I could get the program to adjust the sliders as well that would be fantastic

[quote=“Reaper392”]
6. Can i change the values of sliders by editing the values in the .lua file?
Possibly. From my digging around in the .lua files there are some values that seem to correspond to what the sliders control, but the scale on the slider doesn’t seem to fit with the scale in the file very obviously for the values I had a quick look at. Some more information on this would be great[/quote]

From what I know, the slider settings are saved in 0-1 scale, so, for an instance “BoreSetting”] in table one corresponds to 0 for 50 mm bore, 100 for 120 mm bore, and (n-50)/70 for n mm bore. They are pretty scattered though, so you may need to spend some time on finding them all.

Thanks, that makes a lot of sense actually and explains some of the horrible looking decimal values I found.