Thanks heaps to the devs for keeping the random map scripting language fairly close to the original. I’m currently porting some of my old scripts to the new language and it’s a fairly straightforward translation.
Unfortunately they’ve also kept the terrible dev experience from the original, so I’d like to suggest some improvements. My workflow at the moment is that I have AOM open on one screen, and my code window open on another. I have AOM open to the map editor, and I run my script by creating a new map. I flip back and forth, making changes to my script and making new maps. Here are my suggestions:
1) New map dialog: Let’s start with a quick and easy one. The “new map” dialog should remember my settings, at least so long as the editor is open. Currently I have manually choose the level type from a long list, then set the player count and map size I want to test. It’s a little thing, but it gets annoying when I have to do this hundreds of times during script development.
2) Debug mode: The old AoM EE editor had a “debug mode” option for random map scripts. Now, this option was essentially useless, but it was a nice thought. My suggestions below would not be useful to most users, so it’d probably be a good idea to hide them behind a debug mode option. A checkbox in the “new map” dialog would be ideal.
3) Compile errors: This is by far the most important suggestion. If my script doesn’t compile, currently an error message pops up that just says the script failed to load. Compilers for any other language will tell you the line the error is on, and what the error is. If it’s too much effort to explain the error, at least just telling me the line number of the error would be a massive improvement. Otherwise I’m reading a 2000 line script trying to manually spot my mistake. I’ve literally had to resort to commenting out large chunks of the script to systematically narrow down where the error is. It slows down development on both ends, because I’m also hesitant to write more than a few lines of code before re-running the script, otherwise it gets too hard to figure out my mistakes.
4) Stack traces: If the script loads ok, but has an error during execution, the loading screen should print a stack trace of where the error happened (in debug mode). This is a bigger ask, but it should be possible since you guys presumably wrote the VM that runs the script. The old AoM EE scripts would just crash without telling you where. Again I had to resort to commenting out bits of the script. And if the crash was flaky, you’re screwed. On the plus side, script crashes seem to be way more rare in AoMR.
5) Print function: Not sure if this one exists and I just haven’t found it, but a print function would be super useful. It could print to a console that’s only visible in debug mode. I’d like to be able to print the value of variables, as well as just use it to trace control flow. If suggestion 4 is too hard, printing is a good fallback to narrow down where a crash is happening. rmEchoError
etc look promising, but I can’t figure out where they’re supposed to be printing to. There’s no console, no popups, and no log files in my game folder.
6) Breaking changes: Please avoid breaking changes to the scripting language, and if you must publish a breaking change, include specific details in the patch notes (exactly what has changed, and how devs should adapt), or in a forum post or something. Ideally, some sort of proactive notification to mod devs (eg an in-game popup). I sat down to play my random map script tonight, and got the dreaded “failed to load” error. After 15 minutes of debugging (as mentioned before, I’m commenting out lines of code from a 2000 line script until it compiles, just to narrow down where the problem is), I found that the setRandomNatureCiv function no longer existed. After some sleuthing, turns out it was renamed to rmSetNatureCivFromCulture. This is a core function, so literally every random map mod was broken so that a function could be renamed. I couldn’t find any mention of this change in the patch notes. The few hundred people who have installed my mod also don’t really have a way of contacting me, so it’s literally just luck that I noticed, and I have no idea how long it was broken for. How many mods are going to languish in the store because their authors aren’t even aware they’re broken? There should be a very high bar to publishing breaking language changes, because the mod ecosystem relies on the good will of volunteer devs who probably aren’t manually testing their mods regularly. I can understand this sort of thing this early in the game’s life, but hopefully this becomes very rare as the game matures.