Roblox In-Sider
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Lesson: Calc-Lua-Tor (Just had to put that pun in there. :P)

Go down

Lesson: Calc-Lua-Tor (Just had to put that pun in there. :P) Empty Lesson: Calc-Lua-Tor (Just had to put that pun in there. :P)

Post  Intile Sat Mar 22, 2008 7:06 pm

Lua is a pretty useful scripting language. Perfect for beginners (like me), who are trying to become a good develepor. Lua is a pretty limited language, but with ROBLOX it seems as though it has unlimited possibilities. Today, I'm going to teach you one of my favorite things to use with it: A calculator. Lua is a pretty good-working scientific calculator, and when you know how to use it, can be very helpful. Be it a script your working on, or just trying to do some math homework. Here are some things I'll be teaching you in this lesson.

Plus (+)
Minus/Negative (-)
Divide (/)
Multiply (*)
Pi (math.pi)
Infinity (math.huge) PS: Yes, Lua handles infinity. LOL.
Square Root(math.sqrt)
To The Power Of (^)


Before beginning, we need the command bar, and the output window. To get the Output window, go into ROBLOX Studio, and click View -> Output. You'll soon find that the Output Window is very handy with advanced scripts. To get the command bar, click View -> Toolbars -> Command. The Command Bar is your best friend for one-lined scripts.

BASIC SYMBOLS (+. -. /, *)

Everyone knows how to add, subtract, divide, and multiply. But so does Lua. In the command bar, we'll look at a basic multiplication problem.

print(5 * 5)

In the output window, it will show what you typed, and also the answer to the equation. Now, let's get a bit fancy.

print(5 + 5 * 5)

Now, those people that are aware of elementary math know PEMDAS, or the Order of Operations. So does Lua, which can be very helpful. Now mess around with some basic equations. You'll soon find out how fun math can be!!

Powerful Squares With an Infinite Amount of Pi.

Now, let's get into some really fun things. Let's start out with Pi. As everyone knows, Pi is a low number with a very long decimal. It has not yet been confirmed Irrational, so you cannot say it has a neverending decimal. Only a really big one. Infinity on the other hand.... well, I don't even need to explain that. With math.huge (Infinity), you really won't get too much of a good response. If you're a really good mathematician, you'll know what to do with it. Otherwise, you're stuch with the output window saying 1.#INF. Pi can be pretty helpful though, if you know how to use it. Now, ehn you say print(math.pi), it isn't going to give you those tens of thousands of decimals. No, only 3.1415926535898. But as everyone knows, circles are big about pi. So try experimenting with it. You might get something.

Now onto Square Roots and Power Of. These can be pretty dandy. Homework wise, at least. Let's say for our homework, we need to find the square root of 256. Let's type in print(math.sqrt(256)), and voila! We get 16, which is the square root of 256. (16 * 16, for those who don't know.) Now that we know that, let's try power of. This too can be pretty helpful with homework. Let's say we need to do 25 to the power of 7. Go ahead, try this one on your own. If you did it correct, you should get 6103515625. If not, here's what you should've typed in. print(25 ^ 7). That '^' is the normal mathematical way of saying "To The Power Of". That wraps up what the title says.




So, in conclusion, if you have some basic math homework, and don't have a calculator in handy, use Lua. It helps. Alot.

>Int<
Intile
Intile
Admin
Admin

Posts : 10
Join date : 2008-03-22

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum