I am working on a "building game" (in the same vein as MineCraft, Roboblox and Dwarf Fortress). Obviously this game will be completely brimming with objects that interact with one another. I'd like to use a scripting language to describe the objects and their behaviours. Since these scripts will be executed in rapid succession, I need to find a scripting language such as lua, python, etc that is both very fast, and easily integrable into a C# program. Bonus points for specific information on how to implement.
-
See stackoverflow.com/questions/3481150/… and stackoverflow.com/questions/191222/…Eugene Mayevski 'Callback– Eugene Mayevski 'Callback2011-02-06 17:04:04 +00:00Commented Feb 6, 2011 at 17:04
-
I know of lua, I know of a lot of options. Only a fool relies on their own opinions to make an important decision. I'm appealing to the internet in hopes that someone can show me something specific that is a better approach, and it seems someone has (see the use C# as script post)acp10bda– acp10bda2011-02-06 20:28:53 +00:00Commented Feb 6, 2011 at 20:28
3 Answers
IronPython http://ironpython.codeplex.com/ is well mantained easy to interop with your application, and you can even compile it programmatically to be faster in your game. A quick start example can be found here: http://www.codeproject.com/KB/cs/C_Sharp_and_Iron_Python.aspx once yoiu read you for sure get the idea on how to start. Other thing, since IronPython is based on the DLR Dynamic Language Runtime MS library, it should be easy to change the engine without changing hyour main program infrastructure. Just for completeness I will cite as well http://boo.codehaus.org/ boo. This language was for sure earlier than the other one, and there is a book about writing DSL's from it ( look over the net for DSL languages in boo I don't want advertise here ), whith I think you can grab from idea to make your game script looking better.
Comments
You can use C# :P It's possible to compile and load .cs files at runtime.
And since C# is statically typed the scripts will be rather fast(just as fast as any other (non ngen-ed) C# code. And of course the compiler is already included with .net.
The main weakness of C# as scripting language is that it needs to compile a whole assembly at a time. So it's not well suited for an interactive command prompt.