Square Roots [Solved]
Moderator: Moderators
- Firefang
- Major

- Posts: 518
- Joined: Mon Nov 15, 2010 8:55 pm
- Location: California
Square Roots [Solved]
So, lua supports math functions. 5+5, 9/3, was well as trigonomic functions (found in the GC scripts). Is there any way to take the square root of a number/variable?
-
Marth8880
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Square Roots
It would probably be "sqrt(INSERT#HERELOLOLSOIQ%5)".
- Firefang
- Major

- Posts: 518
- Joined: Mon Nov 15, 2010 8:55 pm
- Location: California
Re: Square Roots
Nope. I just tested it with my code being
and the error log saying
Code: Select all
number = 5
if number == 5 then
number = sqrt(number)
print(number)
endCode: Select all
Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call global `sqrt' (a nil value)
stack traceback:
(none): in function `ScriptPostLoad'- AceMastermind
- Gametoast Staff

- Posts: 3285
- Joined: Mon Aug 21, 2006 6:23 am
- Contact:
Re: Square Roots
I'm not a programmer but it looks like you should be using math.sqrt according to THIS, THIS and THIS.
[color=#FF8040]lua-users.org/wiki/MathLibraryTutorial math.sqrt examples[/color] wrote:math.sqrt
Return the square root of a given number. Only non-negative arguments are allowed.
- > = math.sqrt(100)
10
> = math.sqrt(1234)
35.128336140501
> = math.sqrt(-7)
-1.#IND
