Page 1 of 1

Mathematical functions (Solved)

Posted: Thu Sep 27, 2007 6:11 am
by JQuartz
Hello.

I was wondering if Renpy supported any mathematical functions other than the +-=<>)(. Can anyone point me to the right direction.

Thanks in advance.

Re: Mathematical functions

Posted: Thu Sep 27, 2007 8:22 am
by monele
I might be confusing with another language but there's some "^" or "Pow()" for X at the power of Y. Square root should be possible then (Power of 1/2 as someone here pointed out once ^^)... or am I mixing things up >.>..?...

The best is to say what you're looking for.

Re: Mathematical functions

Posted: Thu Sep 27, 2007 9:30 am
by PyTom
Actually, in python, power is **. For example, 2 ** 8 = 64.

A list of numeric operators is at: http://docs.python.org/lib/typesnumeric.html and http://docs.python.org/lib/bitstring-ops.html .

You can also import the python math module, using code like:

Code: Select all

init:
    $ import math
This gives you a bunch of mathematical operations. For example:

Code: Select all

$ a = math.sin(b)
The math module documentation is here:

http://docs.python.org/lib/module-math.html

Re: Mathematical functions

Posted: Thu Sep 27, 2007 10:15 am
by monele
Actually, in python, power is **
I *always* mix it up XD...

Re: Mathematical functions

Posted: Thu Sep 27, 2007 6:57 pm
by Criptych
monele wrote:
Actually, in python, power is **
I *always* mix it up XD...
Well, a lot of other modern languages use Math.Pow() or some variant, so you have a good excuse. :P

Re: Mathematical functions

Posted: Thu Sep 27, 2007 10:05 pm
by JQuartz
Thanks Pytom and Monele. The links was very helpful.