New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why do you use lua instead of C# itself as script language? #15795

Open
rolandwu777 opened this Issue Nov 6, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@rolandwu777

rolandwu777 commented Nov 6, 2018

Hi,
I am a non-gaming software engineer. I am doing a softswitch (VoIP phone) system running on Windows . My main language is C++. I use a little bit of C#. I downloaded OpenRA and built it with/without Visual Studio 2013. I was debugging and reading through the code. This is really a impressive project. The code is nice and clean. Compile it just takes less than 30 seconds on my old Windows PC. It is really nice project.
I saw many lua files. Later I figured these are something called "lua" scripts. I was wondering why you don't just use C# directly by replacing these lua script files with C# files. I was surprised why I could build OpenRA without downloading Visual Studio 2013, but then I realized there is a built-in csc.exe in .net framework. You could use the built-in csc.exe to compile these C# 'script' to different .dlls and load into openra. It is much easier to debug and read code using Visual Studio.

Thanks,
Roland

@abcdefg30

This comment has been minimized.

Member

abcdefg30 commented Nov 7, 2018

I think the idea was to use a language that does not need to be compiled, so scripts can easily be distributed together with custom maps. Allowing anyone to add their own dlls and reference/execute them from maps sounds like a security risk to me.

(Looking it up I just found #2292 (comment), #2067 and https://forum.openra.net/viewtopic.php?f=83&t=15510 if anyone is interested in digging around in OpenRA's history. ^^)

@rolandwu777

This comment has been minimized.

rolandwu777 commented Nov 7, 2018

Thanks for kindly show me the OpenRA's history. I read through the threads you sent me.
Security is a concern. It would not be easy to overcome. The other thing it is fun to integrate a script engine to a program. Many years ago, I was thinking how to integrate a javascript engine to our VoIP phone system at work. However, that never be a high priority project for us. In OpenRA's source code, it demonstrates how to accomplish it. It took me a couple hours of debugging and finally I slowly understand the logic and the linkage between the C# object and lua engine.

On the other hand, I think the distribution for the script files in OpenRa can be just .cs along with the custom map files. When OpenRa about to load the map, it could invoke .net runtime's csc.exe to compile .cs file to dll on demand and load to memory.

I was trying to demonstrate to my son (who is a 10th grader) how to modify these lua files to add multiple Tanya(s) in the game. I was thinking if the script were in C#, it would be much easier to create a more complicated game rules. After all, visual studio's debugger is very powerful compare to other script language. I could also teach my son some C# programming. He is very interested on creating his own map, but don't want to learn computer languages. LOL.

Anyway, OpenRa is really a nice and fun project. Great job for everyone on this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment