AndrewofDoom

Untitled

Jun 27th, 2012
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Conditional Hooks
  2.  
  3. $State: GS_STATE_GAME_PLAY
  4.  
  5. $On Frame:
  6.  
  7. [
  8. if boolean_startRotation == true then
  9. if ship_to_rotate.Orientation["p"] > (pitch_desired+0.01) then --get it within +-.01 of the desire. An exact number may take forever...
  10. ship_to_rotate.Orientation["p"] = (ship_to_rotate.Orientation["p"] - (ship_to_rotate.Orientation["p"]/pitch_desired))
  11. elseif ship_to_rotate.Orientation["p"] < (pitch_desired-0.01) then
  12. ship_to_rotate.Orientation["p"] = (ship_to_rotate.Orientation["p"] + (ship_to_rotate.Orientation["p"]/pitch_desired))
  13. else --must be done
  14. boolean_startRotation = false
  15. end
  16. end
  17. function fpo(shipName, rotate_amount, boolean_direction)
  18. ba.print("fpo called with parameters: " + shipname + " " + rotate_amount + " " + boolean_direction + "\n")
  19. ship_to_rotate = mn.Ships[shipName]
  20. if ship_to_rotate:isValid() then
  21. ba.print("Found valid ship\n")
  22. end
  23. local vect_rotVelMax = ship_to_rotate.Physics.RotationalVelocityMax
  24. local t = rotate_amount/vect_rotVelMax["x"] --solve for the time.
  25. if boolean_direction == true then
  26. ba.print("Rotating in one direction\n")
  27. ship_to_rotate:doManeuver(t,0,100,0,true,0,0,0,false)
  28. elseif boolean_direction == false then
  29. ba.print("Rotating in other direction\n")
  30. ship_to_rotate:doManeuver(t,0,-100,0,true,0,0,0,false)
  31. else
  32. ba.print("Shit be fucked up yo\n")
  33. --nothing. If somehow this is nil then it'll go here.
  34. end
  35. end
  36.  
  37. ]
Advertisement
Add Comment
Please, Sign In to add comment