Advertisement
sumguytwitches

Fuel to dv

Feb 2nd, 2023 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1.  
  2. function fuelfordvtarget {
  3. parameter targetRocketDv.
  4. parameter rocketisp to 315.
  5.  
  6. set orewiggle to 0.1.
  7.  
  8. set res to gui(200, 100).
  9. Set res:x to -40.
  10. set res:y to 5.
  11. res:show.
  12. set reslist to list().
  13. for rs in ship:resources {
  14. set l to res:addlabel().
  15. Set l:style:fontsize to 20.
  16. reslist:add(l).
  17. }
  18. on time:seconds {
  19. set i to 0.
  20. for rs in ship:resources {
  21. set reslist[i]:text to rs:name + " " + round(rs:amount,1) + " / " + rs:capacity.
  22. set reslist[i]:style:textcolor to rgb(1 - rs:amount/rs:capacity, rs:amount/rs:capacity, 0.3).
  23. set i to i + 1.
  24. }
  25. return res:visible.
  26. }
  27.  
  28.  
  29. radiators on.
  30.  
  31. lock liquidmatched to min(ship:oxidizer * 9 / 11, ship:liquidfuel).
  32. lock oxidizermatched to min(ship:oxidizer, ship:liquidfuel * 11 / 9).
  33. lock vectordv to Round(rocketisp * 9.81 * ln(ship:mass / (ship:mass - (liquidmatched * 0.005) - (oxidizermatched * 0.005))), 5).
  34. print vectordv.
  35. set isrs to ship:modulesnamed("ModuleResourceConverter").
  36. set warp to 1. wait 1. set warp to 5.
  37. if(vectordv < targetRocketDv and ship:oxidizer * 9 / 11 <= ship:liquidfuel)
  38. {
  39. print "refilling ox to match liquid".
  40. for isr in isrs { if isr:hasaction("start isru [ox]") isr:doaction("start isru [ox]",true).}
  41.  
  42. set warp to 1. wait 1. set warp to 5.
  43. wait until ship:oxidizer * 9 / 11 >= ship:liquidfuel or vectordv >= targetRocketDv or ship:ore < orewiggle.
  44. }
  45. isru off.
  46. if(vectordv < targetRocketDv)
  47. {
  48. print "refilling lf + o to match dv target".
  49. for isr in isrs { if isr:hasaction("start isru [lf+ox]") isr:doaction("start isru [lf+ox]",true).}
  50.  
  51. wait until vectordv >= targetRocketDv or ship:ore < orewiggle.
  52. }
  53. isru off.
  54. for isr in isrs { if isr:hasaction("start isru [lqdfuel]") isr:doaction("start isru [lqdfuel]",true).}
  55. print "converting remaining ore to liquidfuel".
  56. wait until ship:ore < orewiggle.
  57. isru off.
  58. set warp to 0.
  59. radiators off.
  60. print "Fuel Converted".
  61. res:hide.
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement