c# script???
Community Forums/General Help/c# script???
| ||
Hi all, The script for C++ is usually Lua. How about C#? Thanks in advance |
| ||
I wouldn't say theres any specific scripting language. For c#, or c++ for that matter. It all comes down to your requirements/preferences. Anyways, for .NET there's IronPython and IronRuby. And AFAIK theres a javascript implementation. And the Tao framework includes native bindings to Lua. Boo is so close to python in spirit, that it might as well be considered a scripting language. But lots of little things about it annoy me, and I haven't found a good IDE so I don't use it currently. I would absolutely love to use IronPython, but its start up time is atrocius, which kills one of the big advantages of python. |
| ||
Its possible to use C# for scripts. |
| ||
Yep, Unity3D can use Mono C# as a scripting language. But since you're aiming at Xbox 360 development, you should really fist look at the possible limitations of that target platform. For example, although it is possible to write XNA apps with Visual Basic.NET, you won't be able to deploy VB.NET apps to the Xbox 360 because that target platforms does not have the required runtime libraries for VB.NET and you cannot upload them manually either. You might find similar problems with IronPython or IronRuby. But, really, you should definitely ask some guys over at the XNA and Xbox forums about that. And you won't get around learning C# (if you don't want to learn C++). |
| ||
You can use c# as a scripting language for .net apps, but for Bmax or B3d its not really suitable. .Net cannot share any data by ref with a non .Net language. However I have used Bmax combined with Mono. Its pretty easy to call c# from Bmax, instantiate c# objects and invoke methods at runtime. You can also bind Bmax functions to C# and let a script call them dynamically. The downside is that the mono runtime is huge! |
| ||
However I have used Bmax combined with Mono. Its pretty easy to call c# from Bmax, instantiate c# objects and invoke methods at runtime. You can also bind Bmax functions to C# and let a script call them dynamically. The downside is that the mono runtime is huge! That is actually very interesting and potentially very useful. I would love to see some code that utilizes the Mono library. |
| ||
Here a an example. It creates a class instance from a compiled exe and instantiates it, calling the default constructor. [sorry for the fixed paths] If you have some Console.WriteLine's in the constructor, you'll see them in the Bmax output. SuperStrict Import "c:\dev\mono-2.2\lib\libmono.dll.a" Extern Function Mono_Config_Parse ( file$z ) = "mono_config_parse" '= getprocaddress(handle,"mono_config_parse") Function mono_jit_init@ Ptr (file$z) = "mono_jit_init" Function mono_set_dirs (asmdir$z, cfgdir$z) = "mono_set_dirs" Function mono_domain_assembly_open@ Ptr (domain@ Ptr, file$z) = "mono_domain_assembly_open" Function mono_jit_exec (domain@ Ptr, assembly@ Ptr, argv%, argc$z) = "mono_jit_exec" Function mono_assembly_get_image@ Ptr (assembly@ Ptr) = "mono_assembly_get_image" Function mono_class_from_name@ Ptr ( image@ Ptr, namespace$z, name$z) = "mono_class_from_name" Function mono_object_new@ Ptr (domain@Ptr ,class@ Ptr) = "mono_object_new" Function mono_runtime_object_init(obj@ Ptr) = "mono_runtime_object_init" EndExtern Global MonoDomain@ Ptr Global MonoAssembly@ Ptr Global Image@ Ptr Global Class@ Ptr Global Obj@ Ptr Global AsmFile$ = "TestEmbed.exe" '// can also be a dll. mono_config_parse( Null ) mono_set_dirs("C:\Dev\Mono-2.2\lib", "C:\Dev\Mono-2.2\etc") MonoDomain= mono_jit_init (AsmFile) MonoAssembly = mono_domain_assembly_open(MonoDomain,Asmfile) image = mono_assembly_get_image(MonoAssembly) class = mono_class_from_name(image, "Embed", "MyType") '// Namespace 'Embed' Class 'MyType' obj = mono_object_new(MonoDomain, class) '// create mem space for object mono_runtime_object_init(obj) '// instantiate the class and call Ctor. |
| ||
Very interesting. I'll be looking into this soon. Do you know if it is possible to get methods and other class pointers for class manipulation? |
| ||
Ya, that's what i said in my first post. This has more info. http://mono-project.com/Scripting_With_Mono and http://mono-project.com/Embedding_Mono |
| ||
You can safelly use codedom both in mono and .net to provide script-like functionality while allowing compiled-code execution speed. It's interesting to take a look to it. |
| ||
Excellent. This is most impressive. Sorry about that question, I just found the docs, I will use the function prototypes from there. |
| ||
Thanks a lot. |
| ||
Hey GW, I made a whole wrapper for Mono. http://github.com/komiga/mono.max/tree/master |