How to subdivide and multiply numbers?

It appears to me that just recently I tried to do some math with scripting for the first time and I realized that you can't write just asterisk or slash. I know there must be some method to simply subdivide and multiply numeric values to express equasions but I searched the whole API Reference for way to long and the only ones I found was the higher math methods in the object index like sinus, cosinus and logarithmic.

Can someone please give me a script example with subdivide and multiply?

Comments

  • PraxisPraxis Posts: 252

    * and / do work with Numbers:  In the Script IDE Pane:

    var a = 10 * 5;var b = 10 / 5;print( a, b );      // 50 2

    Are you perhaps trying to multiply or divide DzVec3 Vectors?:

    var c = new DzVec3( 10, 20, 30 );var d = 7;// This will not work:// var e = c * d;// This will work:var e = new DzVec3( c.x * d, c.y * d, c.z * d );

    Hope this helps.
    P.

     

  • Syrus_DanteSyrus_Dante Posts: 983
    edited June 2019

    Thanks Praxis yeah first I thought the type isn't numeric but I double checked that. It's about simple 2D coordinates but I guess I just can't write it like this:

    nXoffset = (nXoffsetLeft + (nBkrndResX / 2));

    Now I see there is no variable defined for handing over the resulting value of the multiplication.

    [Edit:] Wait now it is working.. was missing parentices again, I should get some sleep.

    Post edited by Syrus_Dante on
Sign In or Register to comment.