Advertisement
sumguytwitches

Refuel All Mining

Aug 30th, 2023
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //!runscript hN43FW08
  2. bays on.
  3. lock twr to ship:availablethrust/ship:mass/body:mu*body:position:sqrmagnitude.
  4. if (defined twrcutoff ) when twr < twrcutoff then {drills off. filled on.}
  5. function ShowResources {
  6. set elcount to 0.
  7. for el in ship:elements {
  8. print "[" + elcount + "] " + el:name.
  9. set elcount to elcount + 1.
  10. set rescount to 0.
  11. for res in el:resources {
  12. print (" [" + rescount + "] " + res:name):padright(21)
  13. + round(res:amount / res:capacity * 100):tostring():padright(4)
  14. + round(res:amount,1):tostring():padright(8)
  15. + "/ "
  16. + round(res:capacity,1):tostring().
  17. set rescount to rescount + 1.
  18. }
  19. print "-".
  20. }
  21. }
  22.  
  23. kuniverse:quicksaveto("fuelbeginautosave").
  24.  
  25. set res to gui(400, 200).
  26. Set res:x to -80.
  27. set res:y to 10.
  28. res:show.
  29. set reslist to list().
  30. for rs in ship:resources {
  31. set l to res:addlabel().
  32. Set l:style:fontsize to 26.
  33. reslist:add(l).
  34. }
  35. set warp to 1.
  36. radiators on.
  37. panels on.
  38. fuelcells on.
  39. radiators on.
  40. deploydrills on.
  41. wait 8.
  42. set warp to 1.
  43. wait until kuniverse:timewarp:issettled.
  44. isru on.
  45. drills on.
  46. set warp to 6.
  47. if not (defined watchlist) set watchlist to list("liquidfuel", "ore", "oxidizer").
  48. on time:second {
  49. drills on.
  50. set isrs to ship:modulesnamed("ModuleResourceConverter"). for isr in isrs { if isr:hasaction("start isru [lqdfuel]") isr:doaction("start isru [lqdfuel]",true).}
  51. set i to 0.
  52. set filled to true.
  53. // todo: handle locked tanks
  54. for rs in ship:resources {
  55. set reslist[i]:text to rs:name + " " + round(rs:amount,1) + " / " + rs:capacity.
  56. set reslist[i]:style:textcolor to rgb(1 - rs:amount/rs:capacity,rs:amount/rs:capacity,0.3).
  57. if watchlist:contains(rs:name) and (rs:capacity - rs:amount) > 1 set filled to false.
  58. set i to i + 1.
  59. }
  60. if filled {
  61. set warp to 1.
  62. radiators off.
  63. panels off.
  64. fuelcells off.
  65. isru off.
  66. deploydrills off.
  67. print "filled".
  68. kuniverse:quicksaveto("fuelautosaveinwarp").
  69. set res:visible to false.
  70. ShowResources().
  71. wait 1.
  72. set warp to 0.
  73. bays off.
  74. wait until kuniverse:timewarp:issettled.
  75. kuniverse:quicksaveto("fuelautosave").
  76. }
  77.  
  78. return res:visible.
  79. }
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement