Square Roots [Solved]

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Firefang
Major
Major
Posts: 518
Joined: Mon Nov 15, 2010 8:55 pm
Location: California

Square Roots [Solved]

Post by Firefang »

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
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: Square Roots

Post by Marth8880 »

It would probably be "sqrt(INSERT#HERELOLOLSOIQ%5)".
User avatar
Firefang
Major
Major
Posts: 518
Joined: Mon Nov 15, 2010 8:55 pm
Location: California

Re: Square Roots

Post by Firefang »

Nope. I just tested it with my code being

Code: Select all

number = 5
if number == 5 then
number = sqrt(number)
print(number)
end
and the error log saying

Code: 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'
User avatar
AceMastermind
Gametoast Staff
Gametoast Staff
Posts: 3285
Joined: Mon Aug 21, 2006 6:23 am
Contact:

Re: Square Roots

Post by AceMastermind »

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
Post Reply