About the lua command, I'd prefer not to add it to War3Api, since it's not wc3 related. IMO to use lua code it's better to import .lua files (similar to how you import CSharpLua's CoreSystem) and create an API in C# using CSharpLua.Template. I don't like the #if __CSLua__ approach, and your suggestion feels kinda similar to that (just without abusing #if and multiline comments). Of course using .lua files is kinda poorly supported right now, since the user needs to manually import them, and the dependency is added to the launcher project instead of the source project. I was thinking of supporting contentfiles/lua for this (in addition to contentfiles/cs that is currently used for .Sources packages).
I'll try your approach in a bit, but let me just reply to this first.
The thing is, I'm not a Lua guy, I'm just using it as a way to save some time for the most part. Like instead of implementing my own Base64, I just imported
lua-users wiki: Base Sixty Four. Same with rxi.json. Figured it'd also be faster to execute code that was written natively for Lua instead of transpiled, so it kills two birds with one stone as far as I'm concerned.
Frankly I'm deeply regretting that by now for all these headaches, but even if I hadn't done that I'd sooner or later have ran into this issue with my DateTime functionality which simply demands that I do some stuff to access os.time/os.date. Maybe I could've shoved that to the user by just having a note to tell them to supply the date themselves to the WcDateTime class via a __CSharpLua__ section.
Anyways, the point being, I'm really not that into Lua. I don't really understand the code structure that CSharp.Lua creates. But with your suggestion I'm guessing that it'd require me to essentially build a class in Lua, then provide an extern class with CSharpLua.Templates in C# so people can use it? This like raises the bar for me immensely, I don't know how to do that. I think a lot of people wouldn't know how to do that.
On the other hand, what about inserting some Lua into an existing transpilation structure? Like so:
C#:
public static float Clock()
{
var value = 0;
#if __CSharpLua__
/*[[
value = os.clock()
]]*/
#endif
return value;
}
Well, this is easy! I don't leave my C# structure, all I'm doing is just pulling some information out of Lua and pretending like I'm still a normal method. I don't have to know anything about CSharp.Lua's structure to be able to do this. And for the record, I'm sure this would survive the DLL/Decompile process if I just disable optimisations and rename value to int1, or even easier just turn it into an out var.
Yes, it's hacky, but it works, and it's easy to understand! I just don't think there is a reason to cling so hard onto what is the "proper" way of doing it when that just makes it so much harder for people trying to use this amazing setup to actually make something. The fact is that we're already hacking in a transpiled C# into Lua. Everyone working on this knows that. I don't see what is improper about a Lua method within that context, everyone will understand exactly what it's for and why it's there. Why raise the bar on knowledge required to create something when that just isn't necessary at all? There's no technical debt being created here either.
I'm sorry for being so critical on this, let me just say again that I really think this project is awesome, but I think that accepting the hack here is better than insisting on the long, clean way. A lot of mapmakers aren't programmers, which is exactly why I've gone the long way to create things like powerful missile systems with 3D rotational math that I had to bash my skull against, or a reflection based Save/Load system that removes the need to (de)serialize information for the user.
All of it is me taking the burden of implementing complex stuff upon myself, so that other people don't have to figure that out themselves, so they won't get potentially scared by it. So that they can have it easy.
Yet even I am starting to crumble from how I just can't get my damn projects uploaded in a way that actually works. I've literally had a freaking week off that I've spent on just trying to wrap up this stupid release and, ignoring vast improvement to the systems and WCSharp wiki, it feels like I'm barely any closer to release than I was a week ago, since at the end of the day I just can't seem to release a multi-package structure that actually works.
Christ I'm barely awake and already frustrated again. Frankly I just don't know if I'm prepared to go down another goddamned rabbit hole of trying to figure out how to set up a .lua/.cs structure that interacts with each other in a clean way.
EDIT: Also I just realised that that clock method could also just be created by a CSharpLua.Template, I guess this would be preserved since XML documentation is preserved? Maybe I can even just do a for loop in that manner. This sounds like my new favourite approach. It may sound dumb that I'm only coming up with this idea now but there's just so much to this CSharp.Lua thing that it's easy to lose sight of stuff.
EDIT2: It works boys. I'll still see real quick if I can get it working using the stuff you linked but I'm ready to max sin by putting the entirety of rxi.json as a single line CSharpLua.Template. God help me I will do it if it ends this shit.