What does this line of code do?

Yeah im kinda confused on what this line does:

if x^3 + 2*x^2 < y then

Its in a function (isAboveFunction) on this page.

Here is the function

function isAboveFunction(x,y)
    if x^3 + 2*x^2 < y then
        return 0
    end
    return 1
end

I was trying to get some examples for the library but i didnt really understand that function…
Thanks!

This is an example, it does nothing. :slight_smile:

1 Like

If you actually put it on a script it will work…

(I mean the whole example)

What is calling the function exactly then? This is just an example code and just makes up numbers and does math.

1 Like

uh… some intense mathematical function that takes 2 arguments and returns them depending on the result

2 Likes

Yeah, i can pretty much tell… what are those “^” signs tho?

function that takes two parameters: x, y
if x³ + 2 × x² is less than y then return 0,
otherwise return 1

in simple words.

1 Like
local correctAnswer = isAboveFunction (coords.x,coords.y)

Pretty much just doing math to get a correct answer (just pretend x and y is a 4 or 5 number…

They are exponents. For example 2^2 = 4. You can find a list of operators and what not here.

1 Like

i believe what this does is when the result of x paremeter with the power of 3, and 2 times x parameter with the power of 2 is smaller than y parameter it would return 1, if not then it will return 0

1 Like

Oh so pretty much the “^” is the power? (Forgot wats its called)

So 3^3 is 27 if i am correct…

Oh alright, i get it better now… thanks (cant spell god)

1 Like

power, like what the others said above

1 Like