Data Realms Fan Forums
http://45.55.195.193/

Where to learn Lua
http://45.55.195.193/viewtopic.php?f=73&t=14176
Page 1 of 1

Author:  StapledPuppet [ Mon Apr 06, 2009 5:13 pm ]
Post subject:  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.

Author:  Lord Tim [ Tue Apr 07, 2009 1:35 am ]
Post subject:  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

Author:  StapledPuppet [ Tue Apr 07, 2009 10:50 am ]
Post subject:  Re: Where to learn Lua

Thanks, very helpful resources

Author:  Miles_T3hR4t [ Sat May 16, 2009 3:40 am ]
Post subject:  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/SampleCode


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.

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?

Author:  Daman [ Sat May 16, 2009 4:07 am ]
Post subject:  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

Author:  Miles_T3hR4t [ Sat May 16, 2009 4:18 am ]
Post subject:  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.

Author:  Daman [ Sat May 16, 2009 4:23 am ]
Post subject:  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

Author:  Miles_T3hR4t [ Sat May 16, 2009 5:51 am ]
Post subject:  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

Author:  whitty [ Sat May 16, 2009 5:55 am ]
Post subject:  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.

Author:  Daman [ Sat May 16, 2009 7:26 am ]
Post subject:  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.

Author:  whitty [ Sat May 16, 2009 2:12 pm ]
Post subject:  Re: Where to learn Lua

Eh, shows how little I know about Lua.

Author:  Grif [ Sat May 16, 2009 8:10 pm ]
Post subject:  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.

Author:  robowurmz [ Sat May 16, 2009 9:59 pm ]
Post subject:  Re: Where to learn Lua

"For In Layman's Terms"

You've got some code. It says this:
Code:
For X in Y do


What this means is, for every occurence of X in the list called Y, do whatever comes next.

Author:  Miles_T3hR4t [ Sat May 16, 2009 10:37 pm ]
Post subject:  Re: Where to learn Lua

robowurmz wrote:
"For In Layman's Terms"

You've got some code. It says this:
Code:
For X in Y do


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.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/