Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to do math, please?

Asked by 10 years ago

What is math for scripting?

2 answers

Log in to vote
4
Answered by
Gamenew09 180
10 years ago

You can add, subtract, multiply, and divide like normal.

local var = 2 + 2
print(var) -- 4
local var = 2 - 2
print(var) -- 0
local var = 2 * 3
print(var) -- 6
local var = 2 / 2
print(var) -- 1

To check what a value is equal to you use two equal signs.

local bool = 2+2 == 4
print(bool) -- true, 2+2 equals 4

Please vote me up and accept me as the answer if you found this helpful. Thank you for taking the time to read this!

0
What is * and / mean? iluvmaths1123 198 — 10y
0
Works! iluvmaths1123 198 — 10y
1
* is multiplication, and / is division. So 3 * 2 is 3 multiplied by 2, and 3 / 2 is 3 divided by 2 TurboFusion 1821 — 10y
0
Cool , thanks! iluvmaths1123 198 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Like the answer above says there's the basic math operators found in most programming languages (adding, subtraction, multiplication and dividing) but also in lua there is other functions that will do more complex code, such as finding the sine of a number.

The link below is by a website goes through all the more complex functions that are available in lua, I suggest you give it a read: http://lua-users.org/wiki/MathLibraryTutorial

Answer this question