Advertisement
Guest User

GenBoot.ks v1.0.0 Generic Boot script Author - Scar

a guest
Dec 10th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. // GenBoot.ks v1.0.0
  2. // Generic Boot script
  3. // Author - Scarlet-Laura
  4.  
  5. set ship:control:pilotmainthrottle to 0.
  6.  
  7. function NOTIFY {
  8. parameter message.
  9. HUDTEXT("kOS: " + message, 5, 2, 50, WHITE, false).
  10. }
  11.  
  12. NOTIFY("SYSTEM BOOT IN PROGRESS...").
  13.  
  14. // File manager starts here
  15.  
  16. // Detect existence of file of interest
  17. function hasFile {
  18. parameter name. // Name of file of interest
  19. parameter vol. // Volume to search
  20. local searchIn is vol + ":/".
  21.  
  22. if exists(searchIn + name) {
  23. return true.
  24. } else {
  25. return false.
  26. }
  27. }
  28.  
  29. // Get file from KSC - seems inoprable when called
  30. function download {
  31. parameter name.
  32.  
  33. if hasFile(name, 1) {
  34. deletepath("1:/" + name).
  35. }
  36. if hasFile(name, 0) {
  37. copypath("0:/" + name, "1:/").
  38. }
  39. }
  40.  
  41. // Send file to KSC
  42. function upload {
  43. parameter name.
  44.  
  45. if hasFile(name, 0) {
  46. switch to 0.
  47. deletepath("0:/" + name).
  48. switch to 1.
  49. }
  50. if hasFile(name, 1) {
  51. copypath("1:/" + name + ", 0:/").
  52. }
  53. }
  54.  
  55. // Actual Bootup Process
  56. set updateScript to ship:name + ".update.ks".
  57. // eg: Ship name - Kerbal X; updateScript = Kerbal X.update.ks
  58.  
  59. // check for and run new instructions
  60. if hasFile(updateScript, 0) {
  61. NOTIFY("Update Found").
  62. download(updateScript).
  63. switch to 0.
  64. deletepath("0:/" + updateScript).
  65. switch to 1.
  66. NOTIFY("Running Update").
  67. wait 1.
  68. runpath("1:/" + updateScript).
  69. }
  70.  
  71.  
  72. // If startup.ks file exists onboard, run that automatically
  73. set startup to ship:name + ".startup.ks".
  74. if hasFile(startup, 1) {
  75. runpath("1:/" + startup).
  76. }
  77. else {
  78. wait 10.
  79. reboot.
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement