I want to learn lua

So I want to learn lua for gmod, specifically for perp, custom npc’s etc

Point me in the right direction.

Cheers

-Edit-
Note to self:
Get some sleep.

Personal tip, learn some basic programming in any other language first before going into Lua. There are some fairly good and thorough tutorials on C++. After that, feel free to jump into Lua.

Why should you do this? Lua removes or oversimplifies some of the standard coding conventions, like data types for variables (A variable in Lua can be of any data type), and using a single universal data structure (The table). If you jump into Lua first you won’t understand why many things in the engine itself are the way they are.

Yeah I’m surely suffering from this at the moment. I jumped right in without even researching the language.

AT LEAST read part I of this book before you jump into Garry’s Mod Lua. And read the preface, it gives an important context to the language.

Parts II and III are also a great idea to read.

Edit: I forgot the link http://www.scribd.com/doc/52993973/Programming-in-Lua-2Nd-Edition

Big Bang is right. I did the same as BradenFase and now I’m explaining things in other languages via lua which isn’t good.

Big Bang nailed it on the head. I have been learning to write in C++ recently, the concept of datatypes and typecasting was so strange to me, it was really a set back more then anything. Learn C++, and learn how the lower end works, then learn lua (which will take 1/4th of the time it took you to learn C++).

[editline]9th July 2012[/editline]

If you are a good C++ coder and you understand how everything works, it would take you a few weeks to learn lua.

This is exactly right. I learned Lua about two years ago and never really understood some concepts. I dropped Lua and went into Java. After learning Java, Lua made so much more sense to me.

Would any be able to make c++ classes? i don’t get motivated learning on my own.

Theres this magical thing called Google, you should try it.

Ok, Start off simple and work your way up:

Make a simple Lua script which writes the first ever words you start off with, “Hello World”.



print( "Hello World!" )
or
Msg( "Hello World!" )


From there, explore more complex, but yet still simple scripting; maybe start to work with ConVars, make the text “My first variable” appear when you write var_first into console.



function FirstVariable(client, command, arguments) -- FirstVariable is the name of the new function you just made! You can call it whatever, but this make more sense.
   print( "My First Variable!" )                               -- This tells Source to write the words "My First Variable" to the console.
end                                                                  -- This ends the function. Everything gets called on between function and end
concommand.Add("var_first", FirstVariable)            -- This adds the console command, you could say it ties your function to the command "var_first"


From then on you can play around with new ideas, search the old gmod wiki and get to grips with some of the slightly more advanced stuff.

After that make a CS base SWEP, the RG base is a bit to complex at this stage.

Would knowing basic html be enough to jump into lua

:v: :v: :v:

[sp] No, html isn’t even a programming language, it’s markup. [/sp]

Do you know any good interactive tutorial/ videos to a langue you would recommend I don’t learn very well from just reading and trying. Thanks for the help

I’ve been learning html through http://www.codecademy.com/learn for a bit now and i have a basic understanding of it.

As I tell everyone, wait for code_gs with his nice beautiful sexy post of jolly goodness to appear.

In the mean while, check these places out:

Hey if I can make a suggestion (since you mentioned codecademy): Before you jump into something like GLua, take codecademy’s Python course. Lua is similar to Python in many ways, and since you’re familiar with their tutorial structure, learning a scripting language before programming in one will really help.

[editline]e[/editline]

Since this post has gained so many disagrees, I feel like I should defend my point:
The person replying to this thread says they are experienced in HTML without listing any other languages they know, leaving me to believe they only are experienced in HTML. The logical step before jumping into scripting for a game with no knowledge of scripting is learning a scripting language. Since said person has learned from codecademy in the past, and I can’t think of any interactive Lua learning website, they may be interested in this tactic.

any one else thoughts on this?

You are right I only know the basics of html and I felt like i should start to learn lua because Garry’s mod is what made me want to learn code in the first place so I went on codecademy and started a language. Before I came to this forum I didn’t even know there where Programming and Markup languages. So if you thinks its a good idea ill learn python before jumping into lua.

I dont see the point, Python and Lua are fairly similar. You’d be better off just learning Lua first because thats what you wanted to learn. HTML knowledge means jack