Home » Community » Forums » » Using Lua with C#
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

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#
Post Reply 
Thanks, this is awesome and could save me a bunch of work.

 User Rating: 1081   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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?

 User Rating: 1081   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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

 User Rating: 1024   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Quote:
Original post by Mite51
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


Could you please explain or provide a link to some info?

thanks!



 User Rating: 1015    Report this Post to a Moderator | Link

Interoperability with existing code or scripts, perhaps.

 User Rating: 1946   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Quote:
Original post by Anonymous Poster
Could you please explain or provide a link to some info?

System.CodeDom.Compiler.CodeDomProvider
System.CodeDom.Compiler.ICodeCompiler

A Simple C# Compiler Without Using csc.exe

 User Rating: 2027   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

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

 User Rating: 1035   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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!)

 User Rating: 1234   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Quote:
Original post by BradSnobar
I was looking at Iron Python too though. It is written natively in C# and so might be embedded easily too.

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:
Has anyone used python? How easy is it to use compared to lua?

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.

 User Rating: 2027   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

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]

 User Rating: 1091   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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."

 User Rating: 1015    Report this Post to a Moderator | Link

Quote:
Original post by acid2
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!)




 User Rating: 1015    Report this Post to a Moderator | Link

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.

 User Rating: 1060   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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


 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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.



 User Rating: 1060   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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 ;)

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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]

 User Rating: 1028   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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]

 User Rating: 1932   |  Rate This User  Send Private MessageView ProfileView JournalView GD Showcase Entries Report this Post to a Moderator | Link

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.

 User Rating: 1030   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

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!



 User Rating: 1015    Report this Post to a Moderator | Link

Quote:
Original post by 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!


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.

 User Rating: 1030   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

"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

 User Rating: 1015    Report this Post to a Moderator | Link

2kornman00:
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.

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++ !

 User Rating: 1015    Report this Post to a Moderator | Link

Embedding Ironpython.

 User Rating: 1579   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link
Page:   1 2 »»
All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: