02 Apr, 2010, JohnnyStarr wrote in the 1st comment:
Votes: 0
So I stumbled upon a dll out there that allows you to add Lua as a reference in C#.
I'm pretty excited about how amazingly easy this is to use compared to C / C++.
Check it out :)

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using LuaInterface;


namespace Test
{
class Player {
private string _name;
public Lua L;

public Player(string name)
{
_name = name;
L = new Lua();
}

public void send(string txt)
{
Console.WriteLine(_name + " Says " + txt);
}
}


class Program {
static void Main(string[] args)
{
Player ch = new Player("Aragorn");
ch.L.RegisterFunction("send", ch, ch.GetType().GetMethod("send"));
ch.L.DoString("send('Hello Mudtown!')");
Console.ReadLine();
}
}
}

// OUTPUT: > Aragorn Says Hello Mudtown!


You can of course use L.DoFile() as well. I'm considering how fun it would be to take advantage of this dll to create a
mud driver in C# and write the mudlib in Lua. This would take a ton of work, and I'm not sure how the mono conversion
would work (if at all) but maybe it would just be good practice.
04 Apr, 2010, JohnnyStarr wrote in the 2nd comment:
Votes: 0
Gee, I guess this is only interesting to me :sad:
04 Apr, 2010, David Haley wrote in the 3rd comment:
Votes: 0
Well personally, I have basically no interest in C#. :tongue: And I don't really see why this is so different and easier, when compared to Lua bindings in other languages?
04 Apr, 2010, Runter wrote in the 4th comment:
Votes: 0
David Haley said:
Well personally, I have basically no interest in C#. :tongue: And I don't really see why this is so different and easier, when compared to Lua bindings in other languages?


^ Truth.

This is where I'd point out that C# doesn't fit into the blank here: C/C++/???
So I'm not entirely sure why you'd compared it to C/C++.
04 Apr, 2010, flumpy wrote in the 5th comment:
Votes: 0
C# is basically MS Java with activex extras, so really why not just use Java here on the server side?

I suppose it's good to know about this tho'

… In case oracle shut down Java entirely :S
04 Apr, 2010, kiasyn wrote in the 6th comment:
Votes: 0
c# is an excellent language when developing windows apps, far better than java IMHO.
04 Apr, 2010, flumpy wrote in the 7th comment:
Votes: 0
Well, that's a subjective viewpoint.

I did say server side ;)
04 Apr, 2010, kiasyn wrote in the 8th comment:
Votes: 0
:grinning:

and i did say windows apps ;P
04 Apr, 2010, flumpy wrote in the 9th comment:
Votes: 0
kiasyn said:
:grinning:

and i did say windows apps ;P

Oh, I guess I assumed we were talking about server side stuff. My bad.

Anyhew, java has at least one decent windows native gui: SWT.

You can now harness this far more easily than ever before using Griffon :)
04 Apr, 2010, JohnnyStarr wrote in the 10th comment:
Votes: 0
David Haley said:
Well personally, I have basically no interest in C#. :tongue: And I don't really see why this is so different and easier, when compared to Lua bindings in other languages?


Runter said:
So I'm not entirely sure why you'd compared it to C/C++.


If you read my lua interface post in the Lua section, it's easy to see that I was working with C / C++.
A lot of work was put into the luaInterface.dll compared of course to raw C, which requires you to write
everything from scratch. The reason I mentioned C++ is because my project was a Rom base, in which I added C++
support and a few upgrades.

Obviously C# is an original language / environment, and is not derived from C++.

I guess I should have just added a post to my original thread for continuity.
04 Apr, 2010, Runter wrote in the 11th comment:
Votes: 0
kiasyn said:
c# is an excellent language when developing windows apps, far better than java IMHO.


No, everyone knows you use the MFCL or nothing.
04 Apr, 2010, JohnnyStarr wrote in the 12th comment:
Votes: 0
Runter, I must have bugged you somewhere along the way, because lately you only seem to criticize.
Curious.
04 Apr, 2010, Runter wrote in the 13th comment:
Votes: 0
Quote
Obviously C# is an original language / environment, and is not derived from C++.



Someone needs to write C3p0. Then I'll make comparisons on how it's more awesome than C and C++.

All joking aside, I don't think that's obvious to everyone. I suspect the reason MS chose the name was to confuse the issue. Well, I more than suspect. Even if it wasn't intentional (and I don't see how it couldn't have been.) it resulted in that very confusion. Some years ago when the hype on C# was greater in the university circuit I recall a lot of misinformation going out from various CS staff on this issue. That led to a lot of early adoption of C#. They could have named it Windows Programming Language. I'm sure just as many people would have been happy to learn WPL. I'm just a strong supporting of being very transparent about these things and I consider the entire naming convention in the first place to have been a shady business practice.
04 Apr, 2010, JohnnyStarr wrote in the 14th comment:
Votes: 0
I think the overall OP was to show a quick example of how one might use some Lua within C# without a ton of extra work.
Sure there is also SWIG and other libraries for this, but you might consider that C# is popular for game programming, and
right now Lua is all the rage on XNA sites. So it seems to me, that the forum could gain from constructive criticism, if it
is at least pertinent to the OP :rolleyes:
04 Apr, 2010, Kardon wrote in the 15th comment:
Votes: 0
In response to the OP:
I've used LuaInterface with C# in earlier versions and I concur that it is extremely easy to use compared to using the C API. Keep playing with it and I believe you'll quickly find yourself using it for a future project. I would be very interested if you were to actually start writing a MUD driver in C# using LuaInterface and lua to write the mudlib.

In response to the C# vs. Java vs. whatever posters:
On the outside C# does transparently look like Java, however there are a few differences between the two(Those interested should visit C# From a Java Developer's Perspective). Unfortunately however many people compare the language and not the .NET framework that powers the applications written with it. I invite those curious to visit the .NET Framework Class Library Reference and see just how massive it is. I'm not going to choose preference over one or the other personally, as both have their merits and I don't solely develop in either. The Java platform is equally impressive. My advice is to choose the best tool for the job and use that rather than get caught up in finding the language/framework that does it all.
0.0/15