|
Page 1 of 1
|
[ 14 posts ] |
|
Author |
Message |
StapledPuppet
Joined: Mon Apr 06, 2009 10:40 am Posts: 25
|
Where to learn Lua
Hey everyone... I have looked around a bit, and I wanna be able to learn Lua so when the next build comes out, and with the current builds, I will be able to make custom scripts. So yeah, what can you do with Lua on CC at the moment? And if anyone has any suggestions on how I can learn Lua, greatly appreciated. Thanks in advance.
|
Mon Apr 06, 2009 5:13 pm |
|
|
Lord Tim
Joined: Fri Apr 27, 2007 4:55 pm Posts: 1178 Location: America!
|
Re: Where to learn Lua
If you've ever used a programming language before, you might be able to jump right in with the documentation: http://www.lua.org/manual/5.1/Otherwise, since I'm assuming you haven't, there are a few resources on the Lua site, and some other Lua projects that you might be interested in, where you can practice. Of course, the best way to learn is to look at some good existing code. Just looking through it and reasoning it out can go a long way towards learning a new programming language. http://www.lua.org/pil/http://love2d.org/http://lua-users.org/wiki/SampleCode
|
Tue Apr 07, 2009 1:35 am |
|
|
StapledPuppet
Joined: Mon Apr 06, 2009 10:40 am Posts: 25
|
Re: Where to learn Lua
Thanks, very helpful resources
|
Tue Apr 07, 2009 10:50 am |
|
|
Miles_T3hR4t
Joined: Mon Jun 04, 2007 5:55 am Posts: 1627 Location: Ohio
|
Re: Where to learn Lua
Lord Tim wrote: If you've ever used a programming language before, you might be able to jump right in with the documentation: http://www.lua.org/manual/5.1/Otherwise, since I'm assuming you haven't, there are a few resources on the Lua site, and some other Lua projects that you might be interested in, where you can practice. Of course, the best way to learn is to look at some good existing code. Just looking through it and reasoning it out can go a long way towards learning a new programming language. http://www.lua.org/pil/http://love2d.org/http://lua-users.org/wiki/SampleCodeI just read all of 1.1 to 4.3.4 and thats when I got confused. It assumes you already know what 4 is. can you explain in english how 'for' works. And also to clairify, lets say I want to make a variable, called bob, and i want bob to be 4, do i just type Bob = 4 and need nothing else? also if I have 2 lua scripts runing, and one defines bob, can the other script check bob?
|
Sat May 16, 2009 3:40 am |
|
|
Daman
Joined: Fri Jan 26, 2007 3:22 am Posts: 1451
|
Re: Where to learn Lua
Miles_T3hR4t wrote: I just read all of 1.1 to 4.3.4 and thats when I got confused.
It assumes you already know what 4 is. can you explain in english how 'for' works.
for <local variable to define as the key>,<local variable to define as the value> in pairs(mytable) do code end pairs/ipairs gets the pairs or iterated pairs of a table, the key and value. That's a generic for. A numeric for works sort of like this-- for <local variable to use as an iterator>=<value to start at>,<value end the for statement at>,<value to increment iterator by each loop> do stuff end kind of similar to [local variable to use as an iterator] = 1 while ([local variable to use as an iterator]<[value to end the for statement at]) do [local variable to use as an iterator] = [local variable to use as an iterator] + [value to increment iterator by each loop] end Quote: And also to clairify, lets say I want to make a variable, called bob, and i want bob to be 4, do i just type Bob = 4 and need nothing else? also if I have 2 lua scripts runing, and one defines bob, can the other script check bob? yes
|
Sat May 16, 2009 4:07 am |
|
|
Miles_T3hR4t
Joined: Mon Jun 04, 2007 5:55 am Posts: 1627 Location: Ohio
|
Re: Where to learn Lua
Daman wrote: Miles_T3hR4t wrote: I just read all of 1.1 to 4.3.4 and thats when I got confused.
It assumes you already know what 4 is. can you explain in english how 'for' works.
for <local variable to define as the key>,<local variable to define as the value> in pairs(mytable) do code end pairs/ipairs gets the pairs or iterated pairs of a table, the key and value. That's a generic for. A numeric for works sort of like this-- for <local variable to use as an iterator>=<value to start at>,<value end the for statement at>,<value to increment iterator by each loop> do stuff end kind of similar to [local variable to use as an iterator] = 1 while ([local variable to use as an iterator]<[value to end the for statement at]) do [local variable to use as an iterator] = [local variable to use as an iterator] + [value to increment iterator by each loop] end so in other words, 'for' is just to take redundant references of a table, and just make a series? I'm not quite sure I follow this... Daman wrote: Quote: And also to clairify, lets say I want to make a variable, called bob, and i want bob to be 4, do i just type Bob = 4 and need nothing else? also if I have 2 lua scripts runing, and one defines bob, can the other script check bob? yes so... If i have lua in an MOSR that says Bob = 1, and then another object says If bob = 1, it will work? from what I read, if bob = nul, then bob doesn't exist, wouldn't an If bob = something statement crash if bob = nul? just to verify. And from what I've seen OMG this is easy, its like Quick basic with better math, and short-hand code. wow.
|
Sat May 16, 2009 4:18 am |
|
|
Daman
Joined: Fri Jan 26, 2007 3:22 am Posts: 1451
|
Re: Where to learn Lua
Miles_T3hR4t wrote: so in other words, 'for' is just to take redundant references of a table, and just make a series? I'm not quite sure I follow this... no drr drr drr wrote: so... If i have lua in an MOSR that says Bob = 1, and then another object says If bob = 1, it will work?
what do you mean will it work Bob will be defined as a global variable, set at 1. Why would you set it again in another object? Quote: from what I read, if bob = nul, then bob doesn't exist wrong Quote: , wouldn't an If bob = something statement crash if bob = nul? just to verify. too bad that's not how you do comparisons if bob == something then return true else return false end would return false if bob was null or you could just do if bob then return true else return false end to check if the variable is true in a boolean sense
|
Sat May 16, 2009 4:23 am |
|
|
Miles_T3hR4t
Joined: Mon Jun 04, 2007 5:55 am Posts: 1627 Location: Ohio
|
Re: Where to learn Lua
for the variable question, in 1.2 it says Quote: In other words, a global variable is existent if (and only if) it has a non-nil value. which is what I was referring to. if its nil, it doesn't exist. if a variable doesn't exist, what happens if you check for it? just variable = nil I'm just trying to make sure I don't crash my comp when I start actually coding. and secondly, could you maybe simplify 'for' because I really don't get it. something about the wording just messes with me. maybe in english without psudo code
|
Sat May 16, 2009 5:51 am |
|
|
whitty
Joined: Sat Jun 16, 2007 2:31 am Posts: 2982 Location: Texas
|
Re: Where to learn Lua
Just because something is nil, doesn't mean it doesn't exist. It's value is just nil, the actual object is still there.
|
Sat May 16, 2009 5:55 am |
|
|
Daman
Joined: Fri Jan 26, 2007 3:22 am Posts: 1451
|
Re: Where to learn Lua
nope wrong whitty Miles_T3hR4t wrote: for the variable question, in 1.2 it says Quote: In other words, a global variable is existent if (and only if) it has a non-nil value. which is what I was referring to. if its nil, it doesn't exist. if a variable doesn't exist, what happens if you check for it? just variable = nil I'm just trying to make sure I don't crash my comp when I start actually coding. and secondly, could you maybe simplify 'for' because I really don't get it. something about the wording just messes with me. maybe in english without psudo code hi guess what you're not going to crash your comp how about you compile Lua 5.1 and start ♥♥♥♥ around if you don't feel like starting CC because the only way you're going to learn anything is by trying over and over and trying to do different things Go make things with for statements until you understand them.
|
Sat May 16, 2009 7:26 am |
|
|
whitty
Joined: Sat Jun 16, 2007 2:31 am Posts: 2982 Location: Texas
|
Re: Where to learn Lua
Eh, shows how little I know about Lua.
|
Sat May 16, 2009 2:12 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Where to learn Lua
Little tip guys:
== != =
== is a check. if bob == 1 then if bob = 1 then wouldn't do anything, because it's setting bob to 1.
|
Sat May 16, 2009 8:10 pm |
|
|
robowurmz
Joined: Thu Aug 16, 2007 10:09 am Posts: 163
|
Re: Where to learn Lua
"For In Layman's Terms" You've got some code. It says this: What this means is, for every occurence of X in the list called Y, do whatever comes next.
|
Sat May 16, 2009 9:59 pm |
|
|
Miles_T3hR4t
Joined: Mon Jun 04, 2007 5:55 am Posts: 1627 Location: Ohio
|
Re: Where to learn Lua
robowurmz wrote: "For In Layman's Terms" You've got some code. It says this: What this means is, for every occurence of X in the list called Y, do whatever comes next. so if I have a list, " a, b, c, d, e, f, g, a, b, c," and that list was called A then ... for a in A do would do whatever do says to do, twice, because there's 2 a's? that doesn't make sense, why would a list contain duplicate entries? or does it just do what every entry says to do... screw it, i just won't use for.
|
Sat May 16, 2009 10:37 pm |
|
|
|
|
Page 1 of 1
|
[ 14 posts ] |
|
Who is online |
Users browsing this forum: No registered users |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|