NS2: School of LUA
Italianmagic
Join Date: 2008-12-13 Member: 65755Members
I am curious to see if anyone is willing to meet online (via Adobe Connect or something similar) to learn and develop one's skill with LUA. I was thinking something along the lines of a bi-weekly meet up for about an half-an-hour to a hour and see how it goes from there.
Is anyone interested? :O!
end;
Is anyone interested? :O!
end;
Comments
Here's another (old) thread on the subject: <a href='index.php?showtopic=106572'>Learning LUA in anticipation for NS2</a>
Learning another programming language is always worth doing. Learning your first even more so.
I was going into a long rant about scheduling meetings here, but I'll leave it at 'I might pop in once in a while'. I think actually having a scheduled meeting and people to talk to will make it harder to quit.
That being said, I think it's inherently non-internet-esque to organize into actual classes. I think a Lua subforum (to the much anticipated NS2 Creation subforum) will be more likely to work in the long run. A couple of good 'getting started' tutorials, a friendly attitude, and constructive criticism goes a long way?
I would recommend taking tutorials to learn Python as a starter while you wait. It is a very forgiving language and does not have all the weird eccentricities that make programming really unintuitive for a lot of people. I learned to program starting from Java and ActionScript, so I can't personally comment on its effectiveness; but I know a good number of people who did start with Python. They did fairly well.
<a href="http://www.lua.org/download.html" target="_blank">http://www.lua.org/download.html</a>
Try <b>Lua for Windows</b> if you want an installable solution on Windows.
Lua has two methods of input, Direct and from a File.
To type things into the Lua interpreter directly, just start <b>lua.exe</b>. In my case, its lua5.1.exe, but you may have downloaded a different version. Some distributions of lua don't have the version number in the exe, some do. Whats important is that you don't try to run lua<b>c</b>.exe as its a bytecode compiler for Lua scripts and doesn't do anything with the scripts aside from compiling them.
NOTE: If you didn't install a Lua version for Windows (i.e. has DLLs), you'll probably need to run lua.exe directly from the command console.
When Lua starts, you can type something in and hit enter. What you type will be directly interpreted and executed, and everything you write will remain in effect until the end of your sessions (until you close Lua.exe).
To print "HELLO WORLD" onto the screen, you simply type print("HELLO WORLD").
The second method of input, through a File, is a lot more flexible. You simply write your script in a file, save it, and pass the filepath and filename to the Lua interpreter (lua.exe) when you execute it.
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->lua.exe "C:\Projects\MyLua.lua"<!--c2--></div><!--ec2-->
This is extremely useful if the text editor you use supports the command line, where you can bind a key to execute an executable (such as Lua)
Aside from that, there is a list of <a href="http://lua-users.org/wiki/TutorialDirectory" target="_blank">tutorials by the Lua-Users</a> which seemed good as well as the <a href="http://www.lua.org/manual/5.1/" target="_blank">reference guide</a> from the Lua website.
If you already know a programming language, though, it's unlikely you'll need to spend much time "learning" Lua. In fact, unless you just want to learn Lua for the sake of learning, you'd be better off waiting until NS2 releases its documentation to start learning anything. Lua itself isn't really what you need to learn for NS2 purposes; the specifics of whatever interface Lua has with the Spark Engine are more important.
Don't get me wrong: if you don't know anything about programming and you're interested in modding for NS2, by all means, get a head start. But if you already know a programming language, you're probably jumping the gun a bit if you're only interested in Lua for NS2's sake. Wait for some documentation or you'll be wasting time.
fyi, Lua is not an acronym, but a word in Portuguese, I think it means "moon." I say this, because it sort of a pet peeve in the Lua community to refer to it as "LUA" because that sort of implies that it stands for something, plus it looks kind of silly.
<a href="http://www.lua.org/download.html" target="_blank">http://www.lua.org/download.html</a>
Try <b>Lua for Windows</b> if you want an installable solution on Windows.
Lua has two methods of input, Direct and from a File.
To type things into the Lua interpreter directly, just start <b>lua.exe</b>. In my case, its lua5.1.exe, but you may have downloaded a different version. Some distributions of lua don't have the version number in the exe, some do. Whats important is that you don't try to run lua<b>c</b>.exe as its a bytecode compiler for Lua scripts and doesn't do anything with the scripts aside from compiling them.
NOTE: If you didn't install a Lua version for Windows (i.e. has DLLs), you'll probably need to run lua.exe directly from the command console.
When Lua starts, you can type something in and hit enter. What you type will be directly interpreted and executed, and everything you write will remain in effect until the end of your sessions (until you close Lua.exe).
To print "HELLO WORLD" onto the screen, you simply type print("HELLO WORLD").
The second method of input, through a File, is a lot more flexible. You simply write your script in a file, save it, and pass the filepath and filename to the Lua interpreter (lua.exe) when you execute it.
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->lua.exe "C:\Projects\MyLua.lua"<!--c2--></div><!--ec2-->
This is extremely useful if the text editor you use supports the command line, where you can bind a key to execute an executable (such as Lua)
Aside from that, there is a list of <a href="http://lua-users.org/wiki/TutorialDirectory" target="_blank">tutorials by the Lua-Users</a> which seemed good as well as the <a href="http://www.lua.org/manual/5.1/" target="_blank">reference guide</a> from the Lua website.<!--QuoteEnd--></div><!--QuoteEEnd-->
Quoting this post because it has quality information.
Sorry Italianmagic - I got caught up with "Someone is wrong on the internet" and forgot to actually answer your question...
In actual response to the original post, then Yes, I would like to meet up online with fellow developers and what not, but it depends on the format. I haven't used Adobe Connect or anything, and I'm not sure what sort of format would even work. I think a format where one person broadcasts their desktop might work (like the Microsoft demonstration videos from talks) but that would require a schedule of who's demonstrating what and what are they talking about, which might not work out so well. I think a place to meet-up and discuss in real time Lua techniques, projects, etc. would be a great idea, starting with the NSTR2 sub-forum being unlocked (<b>AHEM</b>) and IRC is a bit impractical I think, as it would require somethlng like Pastebin to communicate effectively, which can be a bit annoying.
I think the problem with forums for this sort of thing is the Elitest and sometimes just annoyed responses that go along the lines of "This has been answered 9001 times before. Do a damn search." When sometimes, doing a search isn't very practical, especially if the person looking for answers is new to programming and doesn't know exactly what he should be searching for in the first place. And it doesn't help when the Search functionality isn't very... impressive?
//Protects against zombies
if !User:Alive() then return print("No zombies allowed.") end
//What to do if user wants to learn Lua
if User:Wants(Learn(Language)) == "Lua" then
//Let's direct user to a helpful site
local Site = "http://www.lua.org/"
User:Visit(Site)
end
end<!--c2--></div><!--ec2-->
The bare basics of Lua can probably be explained in a couple of sentences, but I'm not really sure if there's any site that offers any such digest. I'm hoping the NS2 team will somehow cover it before going into detail on the specific functions and so on.
//Protects against zombies
if !User:Alive() then return print("No zombies allowed.") end
//What to do if user wants to learn Lua
if User:Wants(Learn(Language)) == "Lua" then
//Let's direct user to a helpful site
local Site = "http://www.lua.org/"
User:Visit(Site)
end
end<!--c2--></div><!--ec2-->
The bare basics of Lua can probably be explained in a couple of sentences, but I'm not really sure if there's any site that offers any such digest. I'm hoping the NS2 team will somehow cover it before going into detail on the specific functions and so on.<!--QuoteEnd--></div><!--QuoteEEnd-->
Try the lua user's wiki from the official site. It goes into plenty of detail on basics.
Maybe I'm missing something, but I wouldn't call what's in there "basics". I was thinking more in terms of "How do you make a basic function and what for." At least that's what perplexed me the most when I started out.
<a href="http://lua-users.org/wiki/FunctionsTutorial" target="_blank">http://lua-users.org/wiki/FunctionsTutorial</a>
Correct me if I'm wrong, but this pretty much is definitively "How to make a basic function." If you don't know what a function is used for, that's a general programming tutorial you need, not Lua-specific.
Correct me if I'm wrong, but this pretty much is definitively "How to make a basic function." If you don't know what a function is used for, that's a general programming tutorial you need, not Lua-specific.<!--QuoteEnd--></div><!--QuoteEEnd-->
That... Is very mid-way between friendly and completely baffling.
Well, yes, general programming would do. The thing is, it's all fine and dandy if you have a lick of understanding of what's going, but there's no guarantee that a new-comer will even be able to connect the dots, nevermind NS2-specific implementations. Like I said, the general structure can probably be described in few sentences, and that would probably be the first stepping stone on the road to mod-friendliness.
I learned to code in Lua from making some addons back when I played WoW. Now I find Lua to be one of the easiest to read languages because of its simple syntax. Its tables also makes it very easy to work with, at least when you understand them.
If anyone has some more specific questions about Lua, that you have trouble understanding through the manual, feel free to ask me.
No documentation or word on specific functions yet. However, they have stated that the Engine written in C++ only handles low-level rendering techniques which can be made into any sort of "game" for modification purposes. Nothing NS2 specific is in the low-level engine code. This means that the Lua interface will, at its lowest levels, be an abstraction on top of calls for drawing, lighting, texture mapping, etc.
The NS2-specific functions will have been built into a Lua library of sorts abstracted to such a high level that you won't have to deal with any of that, of course. And there's no word on any of the specifics yet. I'm sure some first-draft documentation will come out with the alpha (at least I hope).
I'm fairly sure that once the alpha is released, UWE will provide docs just like any good API. A tutorial wiki of sorts would be a useful long-term resource to have, though.
Python for life
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->def LearnLanguage(user,language):
if (user.Alive() == False):
print("No Zombies!")
if (language == "Lua"):
print("Get out!")
if (language == "Python"):
site = "http://www.python.org"
user.visit(site)<!--c2--></div><!--ec2-->
But alas, embedding/extending python into an application is a pain in the ass compared to Lua.
When we get more official information/an alpha, I'll be more than willing to start writing Lua tutorials/explanations on the language, though.
site = "http://www.python.org"
user.visit(site)<!--c2--></div><!--ec2--><!--QuoteEnd--></div><!--QuoteEEnd-->
I hope Python handles this like most modern languages do!
(CRAAAASH! - or at least if user.visit does anything with that string...)
Edit: Oh wait... Python is all about that indentation... so the user.visit line -is- in that if statement? Silly Python -_-
Python for life
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->def LearnLanguage(user,language):
if (user.Alive() == False):
print("No Zombies!")
if (language == "Lua"):
print("Get out!")
if (language == "Python"):
site = "http://www.python.org"
user.visit(site)<!--c2--></div><!--ec2-->
But alas, embedding/extending python into an application is a pain in the ass compared to Lua.
When we get more official information/an alpha, I'll be more than willing to start writing Lua tutorials/explanations on the language, though.<!--QuoteEnd--></div><!--QuoteEEnd-->
Personally I love Lua. I haven't gotten seriously in depth with the language, but at least starting out, I find it really awesome. Especially coming from C++ & php. It seems to me that most of the people I know who knew python before lua are fairly 'meh' about it. Me on the other hand, I started on C++ and from there have only seriously worked with web scripting like PHP and a little perl, so Lua is like a dream come true compared to the violent torture that C++ is sometimes. I'd be willing to either aid in writing Lua tutorials once we get some official info about the specific NS2 Lua, or even work on getting such a ns2-lua site up and running
(also... first post. glad to finally join the forum i've been lurking around for the past few months
1. knows the topic.
2. experienced all the headaches.
3. wants to teach you.
And please stop all-capping Lua.
(also... first post. glad to finally join the forum i've been lurking around for the past few months<!--QuoteEnd--></div><!--QuoteEEnd-->
Guess what? I did C++ programming for 5 years and I did Lua for 1.2~ years with Gmod 10, I also played with php a lot, I've used ruby and perl (for linux shell scripting)! I hated Lua more than I hated Python at first. Then I had a friend convince me to use Python for a few things I was needing to do (small utilities, I had to make a few scripts for things that used Python), and slowly learned to REALLY LOVE how the syntax works.
Pretty much the only two things against Python are that it's
+ Hard to embed
+ It has a "different" syntax than the normal white-space insensitive programming languages we're all used to (C/++/Lua/Php etc)
But once you start to use it it's quickly apparent why Python is as huge as it is. You don't have to think about the syntax, at all. There are like 3 basic rules to follow with using the Python syntax, and after that you'll never be making weird subtle syntax errors (Something I still do after years of C++, just really tiny things), and the way objects work in the environment is really intuitive (duck typing makes everything nice and magical). It's also efficient for what it is, and with the advent of Python variants such as StacklessIO and Stackless it'self, it's quite the powerhouse.
It's such a pure and clean way of programming once you really dig into it, I don't think I'll enjoy another scripting language ever again :(
I honestly don't HATE Lua, I just dont enjoy the syntax or using it, after lots of experience (even before I realized Python was decent). I'm not a big enough baby to not use a language because of the syntax so it's not like I'm rejecting Lua in this context, the developers have every need and reason to use Lua, I just secretly wish Python were just like Lua as far as how easy it is to embed into things. I'll end up using Lua either way for NS2 and probably helping people by making tutorials.
<!--quoteo(post=1752322:date=Feb 10 2010, 04:40 PM:name=cmc5788)--><div class='quotetop'>QUOTE (cmc5788 @ Feb 10 2010, 04:40 PM) <a href="index.php?act=findpost&pid=1752322"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Yeah, Python, I just <i>love</i> languages with significant whitespace.<!--QuoteEnd--></div><!--QuoteEEnd-->
Hahahahaha look at you hahaha
I've also done quite a few things with Python, spent a few years getting into the intricacies of it along with a few other scripting languages including Lua. That said, I've never seen a really coherent justification of the whitespace sensitivity. The closest thing to a good explanation is that it makes code somewhat more standardized, so when you're reading other peoples' code you don't have to spend time adjusting to their indentation style or what have you.
On the other hand, I'm the sort of person who really needs to be able to format things in a way that's readable for me. Once I get past a few hundred lines of code, Python-whitespace just starts to make my eyes bleed. It's bad enough that I put in comment markers as faux-braces just to maintain sanity.
So yeah. ###### Python's whitespace conventions.
Edit: Oh, yeah, and also its difficulty of embedding. I think it's because the Python developers fancy it as a "high-level language" and feel that the term "scripting language" is derogatory in light of Python's awesomeness. Shooting themselves in the foot.
Edit #2: Then again, I haven't really looked into Boost.Python. That might be a good solution.
Not to get offtopic too much but Vhdl has always be one of those languages that impressed the hell out of me for how elegantly it permits parallel asynchronous design, although it really is just good for making hardware so... still cool though :P
So ya... C# ftw... i've programmed tons of useful applications in it... runs fast like C++ (or so the advertisements say), with java syntax, love it... xaml is sexy too.
If Ns2 had embedded C#... well it'd probably be a memory hog (compared to LUA) but the syntax would be so much more powerful IMHO... And it can even stay multi-platform (although it'd be better if it used straight up .net framework imho lol) <a href="http://www.mono-project.com/Embedding_Mono" target="_blank">http://www.mono-project.com/Embedding_Mono</a>
I'd be funny if we had the head coding developer do a "School of LUA" to teach all of us lol.
If Ns2 had embedded C#... well it'd probably be a memory hog (compared to LUA) but the syntax would be so much more powerful IMHO... And it can even stay multi-platform (although it'd be better if it used straight up .net framework imho lol) <a href="http://www.mono-project.com/Embedding_Mono" target="_blank">http://www.mono-project.com/Embedding_Mono</a>
I'd be funny if we had the head coding developer do a "School of LUA" to teach all of us lol.<!--QuoteEnd--></div><!--QuoteEEnd-->
C# can't be as fast as C/C++. It's not designed to be and it doesn't try to be.
"Embedded C#" in the sense that Lua or Python are embedded in a game doesn't make a lot of sense; it's not designed to be a scripting language.