Adding new logic to mods

I now in the past you could use LUA to code some logic in the mods, but I wanted to know if there’s a way to add some logic in mods, save from coding this into the main game in C++.

Particularly, I wanted to see if:

  • I could make a vehicle liquid container that heats up (consuming energy) on demand (so, a device that unfreezes your water on winter). I tried to make insulated containers and while they seem to delay the freezing of water, they don’t completely prevent it.
  • I could make two devices that trigger on when a vehicle passes at a point between the line from one to another (like a photodiode), and trigger off when there are no more vehicle tiles between the two sensors. I wanted to make my car test circuit a bit more interactive and make it emit messages when the vehicle crosses the “lap line”.
  • Related to the above: wanted to record lap times on a terminal
  • I wanted to see if the e-ink book scanner could be reimplemented. I love books… but I don’t live on the move. If I did, I would probably move my library to my e-book reader.

I don’t think most of these are needed in the game, so I don’t know how valuable would be to code these effects in C++ with an eye on mainlining them, so…

Is there life after LUA when adding mod logic?

1 Like

If you can code these things in Lua - you can convert this code to C++.

Yes, my main concern is not code this in LUA (I’m not specially fond of the language, and I understand why it was removed), but the fact that if I code this in C++ it needs to be compiled into the game, with the added complexity this task entails.

So I guess, the answer is that there is no way to add logic to a mod, right?

yes it needs to be compiled with the game. what you do is you create the mod, PR it to the main repo, and your mod is included with the game. This is how I did Magiclysm.

1 Like

Well, at least I have a new task for this summer: adding two pluses to my C skills :laughing: