I agree on all points, but having the old AutoSyndrome still active parallel to the new system would allow me to port one industry/workshop/race, then release, test, wait for feedback, do the next. You saw for yourself how long that list is you autogenerated, and I have to test every single reaction, more or less.
Ok. For the next release or two I'll release a version of the old plugins separate from the main repo to help with the transition. Please do switch to the new system and let me know if there's some part of it that can be easily automated. It's surprising how much you can automate, and with the several hundred (!!!) autoSyndrome uses in Masterwork, automation is critical to reduce work when possible.
Just a suggestion but do you have beta testers? The skill level needed for testing individual reactions isn't very high, especially if you include special "cheat" reactions so they can skip prerequisites. With Masterwork's large user base it shouldn't be too hard to find some people. Depending on how many testers you have, each one would only have to do a little work. Maybe give them an incentive with early access / etc. It's what I would do.
Also I'm really quite curious about some of those autoSyndrome uses that don't actually call a command. Things like \AUTO_SYNDROME \LOCATION \UNIT_ID but no actual command following them. Those are placeholders right? If they're supposed to do something then they're broken because autoSyndrome doesn't call a command unless you give it a command name to call.
ExampleI think this is a good change as the SYN_CLASS system can get a little much (it also eliminates all the unnecessary inorganics). My question is, what should I do or change in my scripts to make it easier/better/correct for this new system?
That is an excellent question and I've been meaning to contact you about that. I'm in the middle of standardizing everything within reach, but I haven't 100% defined the conventions yet. Give me another two days to work on updating itemsyndrome and a few other scripts then I'll point you at the new scripts as examples and let you know what the conventions are. I'm glad that I don't have to convince you to switch over. (Secretly I would have rewritten them all myself if you didn't. Shh...don't tell you.)
In general, I think that arguments should be organized in a way so that even someone not familiar with the command should be able to understand roughly what's going on. Special syntax like @ and ; can help separate arguments, but it's confusing to read and can be hard to memorize, especially if everyone has their own syntax for their own command. If autoSyndrome used ; to separate args and itemsyndrome used @ and your stuff used % and ^ then that would be unnecessarily confusing. I strongly believe that all mods of all games should be open source so that the rest of the modding community can learn from everyone else's stuff. Part of that is making your code as clear as possible so people can understand it and extend it. Some languages optimize for having short easy to type syntax, but that makes code hard to read (cough Perl cough). It's not an awful way of doing things, but it's better to have more clarity, even if it means more typing.
Normally the way I group arguments is by making the command go last so that I don't have to actually group them. This isn't the best solution, but the only alternative I like that I can think of right now is something like
reaction-trigger -command [ reaction-trigger -reaction REACT_2 -command printArgs "only after running REACT_1" ] -reaction REACT_1
Take a look at the link I posted for reaction-trigger.lua to get a rough idea of how arguments should be grouped.
One thing I have decided on (or rather, angavrilov decided and I don't care strongly enough to get in a fight with him about it) is that scripts are now going to be named in lower-case-with-words-separated-by-dashes. That's an easy thing you can do now. It'll help people remember script names so they don't have to keep looking up the capitalization/etc. Plugins are going to be FormattedLikeThis so that you can tell by looking if something is a script or a plugin, which is a mildly important distinction if you care about how fast it is (plugin fast script slow, of course). Scripters are gently encouraged to follow this convention, but they're free to name their scripts however they want. Scripts in the main repo will all follow the conventions.
If anything, your scripts provide too much functionality. I realize that the point of them is to be called from within things like autoSyndrome but we don't want to reinvent Lua inside that context. Making computer languages is hard and it's very easy to do it very wrong. I'm not sure where the line is. Maybe some of them could be replaced by something like
reaction-trigger -reaction REACTION_NAME -command substituteThenRunLua "df.unit.find(<unitId>).flags1.dead = 1" unitId \UNIT_ID
Of course, the simplest way would be just
reaction-trigger -reaction UPGRADE_ROBOT -command reaction-triggers/upgrade-robot \UNIT_ID
--reaction-triggers/upgrade-robot.lua
local args = {...}
df.unit.find(tonumber(args[1])).flags1.dead = 1 --I don't know why killing a unit would upgrade a robot but this is just an example
since there is a cost to doing a find-replace and parsing an lua script, blah blah blah. It's complicated and there are a lot of tradeoffs. For one-liners it should be fine.
Things like "call this script on everyone within range" are slightly awkward since you have to iterate through all units in order to find the ones in range, but the only way around that is to implement octrees in C++ every frame you want to make such queries and it would only save you time if you're going to be doing a lot of those on the same frame, but then again maybe you can use octree from a few frames ago and widen the search a bit so you get units that moved in the meantime...I'm rambling. Main problem is I'm being too much of a perfectionist. The substitution thing is every-so-slightly better than having special scripts for every one-liner, and having special scripts for every reaction that requires lua stuff is ever-so-slightly better than doing the substitution thing since (assuming Lua is sensible, which is not necessarily true) Lua "preprocesses" each script file at most once but if you give it the source code in runtime in quotes instead of with a file then it has to reprocess the command every time, which is fast but not free. But then AGAIN I'm probably wrong about that since it properly updates scripts that change even if you don't reboot DF so in that case the substitution thing is probably roughly the same as having special script files for each reaction.
Maybe something like:
reaction-trigger -reaction UPGRADE_ROBOT -command InvokeAnonymousLuaScript "local args = {...}; df.unit.find(tonumber(args[1])).flags1.bits.dead = 1" \UNIT_ID
At the moment I like that best but I'm open to suggestions. I want to encourage raw modders to move into light Lua/Ruby scripting, and having too many scripts that do simple one-liner things that raw modders should be able to handle would enable the problem in a slightly-less-efficient way.
That was way too long. Sorry.