Begin Lua-scripting

Spread the love

Question Description

I’m at a stage where I am forced to learn Lua, so do you have any suggestions on how I do this? I don’t have a lot of experience with any other scripting languages than PHP.

So, some suggestions on “head start Lua”-pages?

EDIT

As an addition to the wonderful tutorial pages, could you please suggest any “programs” I could make that will help me learn Lua? Imagine I would want to learn Pointers in C++, I’d make a Linked List. I want to touch the basics in Lua but meanwhile be open to pretty advanced stuff.

Practice As Follows

First of all work your way through the Programming in Lua, it should take you a day or two to get the gist of Lua.

However I can tell you right away on your first time through ignore coroutines and metatables, they are very powerful, but take a while to grasp. First learn the syntax, scoping (same as PHP luckily for you) and the standard libraries.

After that go back to coroutines and metatables, read them try them and by the third time through you might get it. Unless you have a very good CS background these are complex topics

Edit: The book is free online == website. Besides it is the best tutorial out there on Lua, everyone learns Lua with it.

Also: If you’re purpose is Lua for World of Warcraft (probably not but just in case) you can check out this tutorial

And: Here is a tips and tricks thread on StackOverflow, might help give you some ideas of what to expect from Lua

Suggested Programs/Exercises:

Since you’re initially looking at Lua for web development try to understand and improve the Data Description example in PIL. It’ll give you a few good ideas and a nice feel for the power or Lua.

Then you might want to try out playing with the Data Structures chapter, although Lua has a single complex data-type, the Table, that chapter will show you Lua-like ways to make a table do anything you need.

Finally once you begin to grok metatables you should design a class system (yes with Lua you decide how your class system works). I’m sure everyone that knows Lua has made a dozen class systems, a good chapter to get you started on a class system is Object-Oriented Programming

And if you got time and know C or something like that (C# and Java included) try extending an application with Lua, but that’ll take a week or two to do

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.