Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: JSRNerdo on July 22, 2016, 07:38:09 pm

Title: Maths division returning -3
Post by: JSRNerdo on July 22, 2016, 07:38:09 pm
Hello. I'm trying to divide a variable by 50, then feed that into a modify-variable, to make that the value of another variable. However, when I do this, it always returns -3 for some reason. I'm not sure what's going on or why maths doesn't work. To be honest, even using maths is pretty much a hack for fire-beam burst fire beams, but hey, that's fredding.

Anyway, the relevant sexp test:

   ( modify-variable
      @LeftBeamTick[0]
         ( / ( - @BeamLeftStatus[200] 150 ) 50 )
   )

BeamLeftStatus always has to be above 200 for this event to fire, so that shouldn't be the problem. I've also tested without the subtraction, still returns -3.

Any ideas?
Title: Re: Maths division returning -3
Post by: General Battuta on July 22, 2016, 11:20:31 pm
FRED only thinks in integers, could that be the problem?
Title: Re: Maths division returning -3
Post by: karajorma on July 22, 2016, 11:22:24 pm
What does the event log output?


Also, try putting in P=NP. A Nobel prize awaits. :p
Title: Re: Maths division returning -3
Post by: JSRNerdo on July 22, 2016, 11:37:32 pm
Oh.

I'm an idiot.

Found the problem, I had modified the variable BeamLeftStatus to 0 BEFORE dividing, not after. After swapping the orders of the sexps, it works as intended.
Title: Re: Maths division returning -3
Post by: AdmiralRalwood on July 23, 2016, 01:04:13 am
Found the problem, I had modified the variable BeamLeftStatus to 0 BEFORE dividing, not after. After swapping the orders of the sexps, it works as intended.
...:wtf: But...
I've also tested without the subtraction, still returns -3.
:confused:
Title: Re: Maths division returning -3
Post by: 0rph3u5 on July 25, 2016, 03:21:52 pm
Found the problem, I had modified the variable BeamLeftStatus to 0 BEFORE dividing, not after. After swapping the orders of the sexps, it works as intended.
...:wtf: But...
I've also tested without the subtraction, still returns -3.
:confused:

He was going for ( 200 - 150 ) / 50 = 3  due to the error he had ( 0 - 150 ) / 50 = -3
as for the without substaction part I am as puzzled as you are... (I am also quite tired and may or may not have access to my full visual field at the moment...)