Home   Help Search Login Register  

Author Topic: Getting a scalar, not a vector.  (Read 624 times)

0 Members and 2 Guests are viewing this topic.

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Getting a scalar, not a vector.
« on: 09 Feb 2003, 01:44:22 »
How do I use only the magnitude of a mathmatical result in a flashpoint script?

Example;

4 - 7 = -3

But I only want the 3, I dont give amonkey butt if the answer is a negative.  I tried using | modulas | signs but flashpoint doesnt recognise them?  Is there another way of using only magnitude in flashpoint?

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Getting a scalar, not a vector.
« Reply #1 on: 09 Feb 2003, 01:57:17 »
Try:

(-3^2)^(1/2)

Boy that looks like fun huh?

What it does is multiply your number to the power of two (which effectively gets rid of the negative) then get's the square root of the number (which is the reverse of multiplying it to the power of two)...

Anyway, looks complicated but it's not ;)

You'd use a line like:

variable = ((variable^2)^(1/2))

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Getting a scalar, not a vector.
« Reply #2 on: 09 Feb 2003, 02:01:59 »
Ahh yes, thats what I was looking for.  I went for a  *(-1) at first, but then that broke it when it was already a positive result :P

Liquid_Silence

  • Guest
Re:Getting a scalar, not a vector.
« Reply #3 on: 09 Feb 2003, 02:38:05 »
abs variable

i.e.
Code: [Select]
_a = abs -4
hint format ["%1",_a]
will display 4 not -4

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Getting a scalar, not a vector.
« Reply #4 on: 09 Feb 2003, 03:05:36 »
Oh my would you look at that, an absolute value.  Thats excellent.

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Getting a scalar, not a vector.
« Reply #5 on: 09 Feb 2003, 08:03:35 »
Ah ha!

That's more like it...

I thought that command was some sort of chest fitness thing... ;)

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Getting a scalar, not a vector.
« Reply #6 on: 09 Feb 2003, 16:55:16 »
We'll assume you mean stomach, not chest :)