|
| 02 Oct 2012 12:30 AM |
You might find this helpful!
Learning LUA
Day 1 Print("Enter message") = makes a message io.read(): - reads what you type
There are different numbers, as 1 Print ("Hello, World!") - Basic starting LUA 2 Print ("Hello, universe!") 3 Print ("Hello, everything!") ^ You can use "While 2 do" That will make it do the function while on line 2. + Adds - Subtracts / Devides * Multiplies
Numbers examples (Today's program)
Number 1 = 5 Number2 = 10 Print("Enter a number") Number3 = io.read(): Print("Enter a value as + - / or *") Value = io.read():
Print("5 x 10 + Your number = " Number 1 * Number2, Value, Number3)
Enter a number 25 5 x 10 + Your number = 75
Day 2 You can make values such as true and false. You can find the value by having a == and set a value by an = You can also use else for if neither of the are true. Example
LUA = true
If LUA==true then Print("LUA is true") Elseif LUA==false then Print("LUA is false") Else Print(Hello, World!") end
<= means less than >= means higher than You can also use < or > < is less > is more There's also ~= which means if it isn't. You can use these values on numbers. Example
Number = 32
If Number<=5 then Print("Number is less than 5") Elseif Number>=5 then Print("Number is higher than 5") Elseif Number~=5 Print("Number isn't 5") end
Number isn't 5 Number is higher than 5
Operator Print("Enter code") Code = io.read(): Pint("Enter code2") Code2 = io.read(): Print("Processing")
If Code==382732 and Code2==39232 then Print("Access Granted") Else Print("Access Denied") end
Enter code 382732 Enter code2 39232 Access Granted
You can use "or" as or. Example If code==382732 or code2==39232 then
Loops You can use "Repeat until" for a loop. Example
q = io.read():
repeat print("Hello") until q>=1 end
Or you can use
While q<=1 then
Something cool You can make it count too!
While q=1,5 do Print(q) end
1 2 3 4 5
FUNCTIONS!!!!!!!! A function is basically like, making, you know, a function
Example
Function Talk() Print("Hello, what is your name") Name = io.read(): Print("Hello, Name, How was your day?") end
Talk() -- this makes the function run. Put 2 of these and it will run 2 times!
You can also put something inside the () Example
function eat(what) print(what*what) end
eat(3) This will multiply 3x3
You can also put 2 things
function eat(what, what2) print(what*what2) print(what2*what2) end
eat(3, 5) This will multiply 3x5 then, multiply 5x5
Arrays You can use
ArrayName[1]=12
And then, you can use print, and it will show up in the outpost.
Print(ArrayName[1])
12
You can also use ArrayName{12, 3} for 2 numbers, and it will count as 2
Example
ArrayName{12, 3} Print(ArrayName[1]) Print(ArrayName[2])
12 3
Types of math math.abs math.ceil math.floor math.pow math.random
math.abs(-1) will make that 1. Example
Print(math.abs(-5))
5
math.ciel rounds the number to the next. Example
Print(math.ciel(1.01))
2
Math.floor is the opposite of math.ciel. It rounds it to the lower number, making 1.01 into 1.
math.pow uses power. For example
print(math.pow(3, 3))
27
math.random makes a random number Example
print("math.random(1,5))
3
It chooses a random number between 1 and 5 in this case. |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Oct 2012 06:48 AM |
Well, my post is pointless. |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2012 08:11 AM |
| To many errors. This is what the wiki is for. |
|
|
| Report Abuse |
|
|
usama8800
|
  |
| Joined: 29 Dec 2009 |
| Total Posts: 225 |
|
|
| 02 Oct 2012 08:25 AM |
| I suggest you learn lua before making a tutorial |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2012 08:30 AM |
| Agreed, and Scripting Helpers is not the proper place for a tutorial, put it in the regular scripting forum. |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2012 09:23 AM |
| First thing the OP needs to learn is that Lua isn't an acronym. It's a noun. So LUA is an acronym and Lua is the scripting language. |
|
|
| Report Abuse |
|
|
jobro13
|
  |
| Joined: 05 Aug 2009 |
| Total Posts: 2865 |
|
|
| 02 Oct 2012 09:38 AM |
| First thing OP needs to say CLEARLY its about Lua, not Rbx.Lua. Rbx.Lua doesnt have io.read(). |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2012 09:39 AM |
| No, this is the ACTUAL LUA, not roblox's simplified version |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2012 09:40 AM |
| @indy, if you're gonna disgrace the name of Lua, you should leave. |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Oct 2012 09:42 AM |
| Are you in like 1st grade? |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2012 09:50 AM |
"Are you in like 1st grade?" ___________^ c0mm4 pl0xz
Ok, this might prove I'm not in 1st grade -7 pages of HW
And here's what I'm doing in math 3.052 x 6.193 = 4.926836 Decimals |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2012 10:11 AM |
Indyracoon: "Ok, this might prove I'm not in 1st grade -7 pages of HW
And here's what I'm doing in math 3.052 x 6.193 = 4.926836 Decimals"
False, 3.052 x 6.193 = 18.901036 |
|
|
| Report Abuse |
|
|
jobro13
|
  |
| Joined: 05 Aug 2009 |
| Total Posts: 2865 |
|
|
| 02 Oct 2012 10:14 AM |
Lolwut u think thats hard?
Given is the function fp(x) = (1/4 sin(xp) + 3xp)/2 + p
Give the funcition of the formulae of the maximums of the graph.
Good luck. |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Oct 2012 10:17 AM |
@billy k I got that wrong I'm in 7th grade, do you know about vectors |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2012 10:17 AM |
| I hated doing sin cos and tas. Logs were annoying for a while too until I realized they weren't as hard as I thought. |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2012 10:28 AM |
| And Indy, I would be willing to guess that at least half the people posting on this thread including myself are in high school, so quizzing people on this thread to prove how smart you are isn't going to work. The only thing I see you knowing that we don't know is what happened on the latest episode of your favorite Disney show. |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2012 10:31 AM |
| Correction: Are in high school, or have graduated high school. |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2012 10:52 AM |
| My friend goes to the same school as me, he has a sister who's in high school, and he said our work is harder than high school's. <- and yes, that's proper possessive. |
|
|
| Report Abuse |
|
|
|
| 02 Oct 2012 11:03 AM |
| @indy, I do those problems everyday. Stupid. That is basic 7th grade math. |
|
|
| Report Abuse |
|
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 02 Oct 2012 11:11 AM |
| did.. you.. guys.. actually.. fell.. for.. it..? |
|
|
| Report Abuse |
|
|
| |
|
nairod7
|
  |
| Joined: 26 Mar 2010 |
| Total Posts: 869 |
|
|
| 02 Oct 2012 11:55 AM |
1: This is 'Lua', not 'LUA'...
2: You're using 'io' but you can't get it works with RBX.Lua. New learners don't know this at all...
3: With a tutorial ( ? ) like this, you should talk about comments in a script, no ? Or even say what's the use of "end"s, shouldn't you ?
4: There are errors... ( Or Lua and RBX.Lua are (totally) two differents languages ? )
> Number 1 = 5 -- Beautiful ERROR, you can't make a variable with spaces like this. You can do this with getfenv(): getfenv(0)["Number 1"] = 5; but that's advanced scripting ( I THINK ) ; use undercore ' _ ' -> Number_1 = 5; > Print("5 x 10 + Your number = " Number 1 * Number2, Value, Number3) -- Concatenation ? "string"..variable instead of "string" variable; and no spaces between values ? By the way, are you sure that coma can be used like this ? ._. > You can use "While 2 do". That will make it do the function while on line 2. -- What? Here, while 2 do is a loop, not a function at all. while (condition) do -> while the condition doesn't return nil or false, do... So, the 2 doesn't mean 'execute the second line...', 2 doesn't return nil or false so it would execute lines in the while scope. > ArrayName{12, 3} -- This works in Lua ( not RBX.Lua ) ? I would do this -> ArrayName = {12, 3}... But you can keep your method and get scammed by your debugger. > print("math.random(1,5)) -- What's this " ? I don't know if there are other errors... I'm bored...*facepalm* 5: There are alot of points you didn't talk about, you spoke about loops ( while ... do ) but not for loops, repeat loops...
6: "A function is basically like, making, you know, a function", Nice definition!
Etc, etc...
"You might find this helpful!" ._. ... [ no comment ] |
|
|
| Report Abuse |
|
|