|
| 27 Sep 2013 05:37 AM |
if eject.Velocity.X > 0 then NEWVELX = ("-"..eject.Velocity.X) -- This works elseif eject.Velocity.X ~= 0 then NEWVELX = (eject.Velocity.X) --I want to invert this else NEWVELX = 0 end
Well, the I want to invert eject.Velocity.X, so if it's a negative number then it will go positive. It's to balance out the forces on something for an ejection seat, if you really want to know.
Help appreciated, thanks.
【◄[ϟ]〓☜✪ xWOWZABOYx; FCOM, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2013 05:58 AM |
Bumpin'it k.
【◄[ϟ]〓☜✪ xWOWZABOYx; FCOM, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
getkoed
|
  |
| Joined: 18 Feb 2010 |
| Total Posts: 2298 |
|
|
| 27 Sep 2013 07:04 AM |
if eject.Velocity.X > 0 then NEWVELX = "-" .. tostring(eject.Velocity.X) elseif eject.Velocity.X < 0 then local velx = tostring(eject.Velocity.X) NEWVELX = tonumber(velx:sub(2, velx:len())) elseif eject.Velocity.X == 0 then NEWVELX = 0 end
Probably works, not sure, didn't test it |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2013 07:25 AM |
Uh..inversion is easy.... local x = 1 x = x*-1 print(x)
> -1 |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2013 09:09 AM |
Dragon, I can do that. I can go from positive to negative. But I want to go from negative to positive.
【◄[ϟ]〓☜✪ xWOWZABOYx; FCOM, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
noah
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
| |
|
lupine
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 3561 |
|
|
| 27 Sep 2013 09:19 AM |
But multiplying it by a -1 will always give you the opposite (as a negative multiplied by a negative is a positive)
iirc, math.abs returns the absolute value (which won't go from positive to negative)
print((-1)*-1) --> 1 print((1)*-1) --> -1 |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2013 09:41 AM |
Thanks getkoed, I made it slightly different :)
local velx = tostring(eject.Velocity.X*10) -- Done to increase deceleration if eject.Velocity.X > 0 then NEWVELX = "-"..velx elseif eject.Velocity.X < 0 then NEWVELX = tonumber(velx:sub(2, velx:len())) -- That's your bit elseif eject.Velocity.X == 0 then NEWVELX = 0 end local velz = tostring(eject.Velocity.Z*10) -- Done to increase deceleration if eject.Velocity.Z > 0 then NEWVELZ = "-"..velz elseif eject.Velocity.Z < 0 then NEWVELZ = tonumber(velz:sub(2, velz:len())) -- That's your bit elseif eject.Velocity.Z == 0 then NEWVELZ = 0 end
【◄[ϟ]〓☜✪ xWOWZABOYx; FCOM, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
kubuto2
|
  |
| Joined: 16 Jul 2008 |
| Total Posts: 1275 |
|
|
| 27 Sep 2013 11:56 AM |
local velx = eject.Velocity.X*10 if eject.Velocity.X > 0 then NEWVELX = -(velx) -- This switches the number from positive to negative elseif eject.Velocity.X < 0 then
--NEWVELX = tonumber(velx:sub(2, velx:len())) -- Can you try and explain this line better?
else -- don't need elseif because the other 2 check if it is greater or less NEWVELX = 0 end
local velz = eject.Velocity.Z*10 -- Done to increase deceleration if eject.Velocity.Z > 0 then NEWVELZ = -(velz) -- This switches the number from positive to negative elseif eject.Velocity.Z < 0 then
--NEWVELZ = tonumber(velz:sub(2, velz:len())) -- Can you try and explain this line better?
else NEWVELZ = 0 end |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2013 02:05 PM |
I might actually use lupine's or noah's. Thanks guys :)
【◄[ϟ]〓☜✪ xWOWZABOYx; FCOM, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|