Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. //Search for fuel tanks and SRBs on SHIP and add to lists.
  2. for i in SHIP:PARTS
  3. {
  4. //Walk through resources for that part
  5. for res in i:resources
  6. {
  7. if res:name = "LIQUIDFUEL"
  8. {
  9. SET child to i.
  10. //Check to see if it has an engine or fuel line attached
  11. //We do this so stacked tanks are staged properly,
  12. //rather than staging as soon as one of them is empty
  13. for j in child:CHILDREN
  14. {
  15. if j:name = "fuelLine" OR j:name = "liquidEngine"
  16. {
  17. tanklist:ADD (i).
  18. break.
  19. }
  20. }
  21. }
  22. if res:name = "SOLIDFUEL"
  23. {
  24. srblist:ADD (i).
  25. break.
  26. }
  27. }
  28. }
  29. SET tanklist2 to tanklist:COPY.
  30. SET srblist2 to srblist:COPY.
  31.  
  32. //Check tanks to see if empty and stage if needed
  33. WHEN flight_state <= 3 THEN
  34. {
  35. SET tanknum to 0.
  36. for t in tanklist
  37. {
  38. if t:resources[0]:AMOUNT < 0.01
  39. {
  40. PRINT "Staging due to empty fuel tank".
  41. tanklist2:REMOVE(tanknum).
  42. STAGE.
  43. break.
  44. }
  45. set tanknum to tanknum + 1.
  46. }
  47. SET tanklist to tanklist2:COPY.
  48.  
  49. //Stage SRBs when empty
  50. set srbnum to 0.
  51. if srblist:LENGTH > 0
  52. {
  53. for i in srblist
  54. {
  55. if i:resources[0]:AMOUNT < 0.01 AND i:STAGE = STAGE:NUMBER
  56. {
  57. PRINT "Staging due to empty SRB".
  58. srblist2:REMOVE(srbnum).
  59. STAGE.
  60. break.
  61. }
  62. set srbnum to srbnum + 1.
  63. }
  64. set srblist to srblist2:COPY.
  65. }
  66. PRESERVE.
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement