|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic Page: 1 2 »» |
Last Thread Next Thread ![]() |
| Using Lua with C# |
|
![]() BradSnobar Member since: 9/13/2005 From: Seattle, WA, United States |
||||
|
|
||||
| Thanks, this is awesome and could save me a bunch of work. |
||||
|
||||
![]() BradSnobar Member since: 9/13/2005 From: Seattle, WA, United States |
||||
|
|
||||
| I was looking at Iron Python too though. It is written natively in C# and so might be embedded easily too. Has anyone used python? How easy is it to use compared to lua? |
||||
|
||||
![]() Mite51 Member since: 6/2/2005 From: Vancouver, Canada |
||||
|
|
||||
| Why would you want to use lua in C#? From C# you can use other C# files as scipts and not have to build bridge functions or deal with yet another GC... J |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
Quote: Could you please explain or provide a link to some info? thanks! |
||||
|
||||
![]() jpetrie Moderator - For Beginners Member since: 6/11/2003 From: Redmond, WA, United States |
||||
|
|
||||
| Interoperability with existing code or scripts, perhaps. |
||||
|
||||
![]() Oluseyi Staff Member since: 5/14/2001 From: New York, NY, United States |
||||
|
|
||||
Quote: System.CodeDom.Compiler.CodeDomProvider System.CodeDom.Compiler.ICodeCompiler A Simple C# Compiler Without Using csc.exe |
||||
|
||||
![]() Vexorian Member since: 10/7/2005 From: Ciudad la paz, Bolivia |
||||
|
|
||||
| Yes, but some developers would like to give the users a more flexible language like lua for example. And lua is used by more and more applications for a scripting language. Although I am the kind of person that would preffer c# over lua for scripts, mostly because I am a programmer that feels much more confortable with c like syntax and a strongly typed environment |
||||
|
||||
![]() acid2 Member since: 2/7/2004 |
||||
|
|
||||
| Although this is a nice, well writen article, I also don't see the need for Lua in .NET. I personally use boo to script (woot for boo!) |
||||
|
||||
![]() Oluseyi Staff Member since: 5/14/2001 From: New York, NY, United States |
||||
|
|
||||
Quote: There's no need to "embed" Iron Python; as a first-class .NET language, it can consume assemblies generated by other .NET languages and generate assemblies for consumption by other .NET assemblies seamlessly. Quote: Python is bigger than Lua, though generally slower as well. It has far more functionality, being a standalone language right from its original conception, rather than an extension/data configuration format like Lua. The traditional trade-off has been the feature-richness of Python for a performance hit and difficulty integrating with C++ or the bare-bones simplicity of Lua for a cinch to build. With Iron Python and the CLR, the integration becomes a non-factor, leaving you with robust features, and since your code can be JIT compiled just like C#... By default, though, your code is interpreted, which makes it a very quick way to prototype and/or develop code that requires a lot of hand massaging. |
||||
|
||||
![]() Balaam Member since: 7/20/2002 From: Ashton, United Kingdom |
||||
|
|
||||
| I use Lua and C# together a lot - I think they're a great match :D It's very easy to generate lua code on the fly and use lua's tables for storage. Also the first class nature of the functions makes some stuff much simpler to write. (I also like passing back more than one return value - it's make many things that are usually tricky just dissapear) And I've written a much more basic introduction here. [Edited by - Balaam on February 7, 2006 6:44:41 AM] |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| How about this ? http://www.lua.inf.puc-rio.br/luanet/ "The Lua.NET project integrates Lua with the Common Language Infrastructure, a framework for language interoperability. This integration allows Lua to act both as a "client" language and as a "server" language, although with a limited capacity for the latter. As a client, Lua scripts can access components available through the CLI. As a server, Lua scripts can implement new components accessible by other languages integrated with the CLI." |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
Quote: |
||||
|
||||
![]() Penance Member since: 5/15/2002 |
||||
|
|
||||
| You'd use LUA instead of C# code because you might need to reload the script at some point while the program is still running. In the .NET framework there's no way to unload assemblies unless you create a new application domain and then destroy it when you're done. Very wasteful and hackey. |
||||
|
||||
![]() mascarenhas Member since: 11/10/2005 From: Rio de Janeiro, Brazil |
||||
|
|
||||
| Hi, I am the author of LuaInterface, the library this article uses. Previous releases of LuaInterface have focused on making it easier to use .NET assemblies from Lua, as this is the use case I thought would be more common (building prototypes, using .NET as a GUI for Lua programs, writing computation-intensive code in C# for speed, and calling it from Lua, etc.), but it appears there is a lot of interest in embedding Lua in .NET applications! I am working on the next release, and will include the suggestions in this article, and hopefully make LuaInterface even better for the embedding folks. -- Fabio Mascarenhas, Lablua, PUC-Rio |
||||
|
||||
![]() Penance Member since: 5/15/2002 |
||||
|
|
||||
| I'm using LuaInterface for my .NET game engine project. So far it is working well for me and native <-> lua interactions work great. One thing I found annoying was figuring out the compat library stuff. Documentation on how to get .NET assembly/type importing to work could be better. Right now I just have the compat library in the same directory as my exe and I basically messed with stuff until it worked. Anyway, I'm looking forward to future releases! Don't give up on this project, it has great potential. |
||||
|
||||
![]() SilentDtH Member since: 11/7/2005 From: Auckland, New Zealand |
||||
|
|
||||
| I enjoyed this article - thank you very much. I am a beginner to game development and have been researching thoroughly before i even start my first Tetris clone. I have made a little mod for World Of Warcraft which uses LUA. I guess if these guys use it it's gotta be good ;) |
||||
|
||||
![]() Lantz Member since: 7/12/2001 From: Sweden |
||||
|
|
||||
| Quick comment, having non-stateless stuff static doesnt make for good reusability. What if you want more than one instance of the lua vm? Edit: Also, I would name the attributes the way microsoft's named the ones in the dotnet framework. For example, I'd name AttrLuaFunc LuaFunctionAttribute, which would mean it can be used as [LuaFunction(...)]. A lot more elegant. [Edited by - Lantz on November 14, 2005 7:58:08 AM] |
||||
|
||||
![]() Rob Loach Staff Member since: 12/2/2002 From: Toronto, Canada |
||||
|
|
||||
| Very nice article, well done. I'll have to give it a longer check out once I get the time.... GakScript is my CodeDom wrapper for scripting in C#, VB.NET and other .NET languages. Rob Loach [Website] [Projects] [Contact] |
||||
|
||||
![]() kornman00 GDNet+ Member since: 8/11/2005 From: Mannheim, Germany |
||||
|
|
||||
| Nice article, but you don't really stick with C#\.NET coding standards that are used widely in the .NET community (as someone else pointed out, fulling naming a class with Attribute instead of Attr). Let me guess, you come from a java background ;p. |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| It's one of the dumbest things I've ever read. So, ignoring that Lua is a complete pile of crap language, IMO, what's the point? You can compile and run C# code at run-time, and reload the assemblies at will making C# into a scripting language. Now by using Lua with C# you're using a scripting language within another scripting language. People that have to maintain your crappy code now have to learn two languages one of which is a complete pile of trash. Just because Blizz uses Lua in a hugely popular game doesn't mean that it's a great language; it just means that somebody's experiment got published. Wow! That's smart! |
||||
|
||||
![]() kornman00 GDNet+ Member since: 8/11/2005 From: Mannheim, Germany |
||||
|
|
||||
Quote: First of all, C# isn't a "scripting language". Don't be ignorant and stupid at the same time. C#.NET is compiled into ILasm, which the .NET Virtual Machine then interprets at runtime. VB.NET, C++.NET, etc, all get compiled into the same code, ILasm. Second of all, allowing a game engine have the fuctionality of all of .NET's framework is a security risk. With a scripting language, you get to choose what is compiled and what not. If a game engine is going to allow modding by end users (and not just developers, like 'programmers'), Lua would be an appropriate scripting language to use, since its used in other games (like WoW I believe someone said). Your engine's reply value depends on your players, and if your players know how to create new content, they're going to want to do more with it (assuming your game is actually fun. The guy took some time to at least write a decent tutorial, try giving some constructive criticism next time. |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
| "Just because Blizz uses Lua..." Wow, you're smart! :P WoW isn't the only game using Lua...not by a longshot. When you don't know about a topic, plz don't write at all. Try reading first. http://www.lua.org/uses.html |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
2kornman00:Quote: You have to learn .NET before making such considerations. .NET does NOT inrerpret IL code at runtime !!! Java does, .NET does not. Instead, .NET framework does compile IL code into native machine code with JIT compiler and then execute it. This give a perforance like you write entire code in C++ ! |
||||
|
||||
![]() Arild Fines Member since: 8/20/2001 From: Oslo, Norway |
||||
|
|
||||
| Embedding Ironpython. |
||||
|
||||
|
Page: 1 2 »» All times are ET (US) ![]() |
Last Thread Next Thread ![]() |
|