pickar

test

Aug 12th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 37.94 KB | None | 0 0
  1. version = "1.9.0 Rewrite"
  2. Alarm = "top"
  3.  
  4. Style = {
  5.     CDeflt = colors.white,
  6.     BGDeflt = colors.gray,
  7.     CTitle = colors.black,
  8.     BGTitle = colors.lightGray,
  9.     CWarn = colors.white,
  10.     BGWarn = colors.red
  11. }
  12.  
  13. function SetColorDeflt()
  14.     term.setBackgroundColor(Style.BGDeflt)
  15.     term.setTextColor(Style.CDeflt)
  16. end
  17.  
  18. function SetColorTitle()
  19.     term.setBackgroundColor(Style.BGTitle)
  20.     term.setTextColor(Style.CTitle)
  21. end
  22.  
  23. function SetColorWarn()
  24.     term.setBackgroundColor(Style.BGWarn)
  25.     term.setTextColor(Style.CWarn)
  26. end
  27.  
  28. function Clear()
  29.     term.clear()
  30.     term.setCursorPos(1,1)
  31. end
  32.  
  33. SetColorDeflt()
  34. Clear()
  35. print("Loading...")
  36.  
  37. function Show(Text)
  38.     term.write(Text)
  39.     local xt,yt = term.getCursorPos()
  40.     term.setCursorPos(1, yt+1)
  41. end
  42.  
  43. function ShowTitle(Text)
  44.     SetColorTitle()
  45.     local w, h = term.getSize()
  46.     local posX = math.floor((w-string.len(Text))/2)
  47.     if posX<0 then
  48.         posX=0
  49.     end
  50.     term.setCursorPos(posX,1)
  51.     Show(Text)
  52.     SetColorDeflt()
  53. end
  54.  
  55. function ShowMenu(Text)
  56.     term.write(Text)
  57.     local xt, yt = term.getCursorPos()
  58.     for i = xt, 51 do
  59.         term.write(" ")
  60.     end
  61.     term.setCursorPos(1, yt+1)
  62. end
  63.  
  64. function ShowWarning(Text)
  65.     SetColorWarn()
  66.     term.setCursorPos(10, 19)
  67.     term.write(" "..Text.." ")
  68.     SetColorDeflt()
  69. end
  70.  
  71. function SaveData()
  72.     local file = fs.open("shipdata.txt", "w")
  73.     file.writeLine(textutils.serialize(SData))
  74.     file.close()
  75. end
  76.  
  77. function ReadData()
  78.     local file = fs.open("shipdata.txt", "r")
  79.     SData = textutils.unserialize(file.readAll())
  80.     file.close()
  81. end
  82.  
  83. function SaveGUIOptions()
  84.     local GUIFile = fs.open("GUIOptions.txt", "w")
  85.     GUIFile.writeLine(textutils.serialize(GUIOptions))
  86.     GUIFile.close()
  87. end
  88.  
  89. function LoadGUIOptions()
  90.     local GUIFile = fs.open("GUIOptions.txt", "r")
  91.     GUIOptions = textutils.unserialize(GUIFile.readAll())
  92.     GUIFile.close()
  93. end
  94.  
  95. function TextDirection()
  96.     if SData.Direction == 0 then
  97.         return "Front"
  98.     elseif SData.Direction == 180 then
  99.         return "Back"
  100.     elseif SData.Direction == 1 then
  101.         return "Up"
  102.     elseif SData.Direction == 2 then
  103.         return "Down"
  104.     elseif SData.Direction == 90 then
  105.         return "Left"
  106.     elseif SData.Direction == 255 then
  107.         return "Right"
  108.     else
  109.         return "Unknown"
  110.     end
  111. end
  112.  
  113. function AddTextAnim(x, y, k, t, text, add)
  114.     if add == true then
  115.         if not (k > t) then
  116.             AddText(x, y, text)
  117.         end
  118.     else
  119.         if not (k < t) then
  120.             AddText(x, y, text)
  121.         end
  122.     end
  123. end
  124.  
  125. function AnimationSmallToBig()
  126.     local speed = 3
  127.     local x = speed
  128.     while x < 148 do
  129.         sleep(.00005)
  130.         BRIDGE.clear()
  131.         InfoBox = BRIDGE.addBox(730, 180, 230, 54 + x, 0xff3300, 0.3)
  132.         InfoBoxLeft = BRIDGE.addBox(730, 182, 2, 50 + x, 0x000000, 0.5)
  133.         InfoBoxRight = BRIDGE.addBox(958, 182 ,2, 50 + x, 0x000000, 0.5)
  134.         InfoBoxTop = BRIDGE.addBox(730, 180, 230, 2, 0x000000, 0.5)
  135.         InfoBoxBottom = BRIDGE.addBox(730, 232 + x, 230, 2, 0x000000, 0.5)
  136.         x = x + speed
  137.        
  138.         AddTextAnim(734, 184, x, 13,  "<===========     Big Help      ===========>", false)
  139.         AddTextAnim(734, 194, x, 13, "$$jump [Direction] [Distance] [Quantity] -")
  140.         AddTextAnim(734, 204, x, 13, "warps few times. If quantity wasn't set  -")
  141.         AddTextAnim(734, 214, x, 13, "jumps once. <$$jump up 58 3>")
  142.         AddTextAnim(734, 224, x, 13, "$$setDim [Front] [Right] [Up] [Back] [Left]")
  143.         AddTextAnim(734, 234, x, 13, "[Down] - sets dimensions of the ship.")
  144.         AddTextAnim(734, 244, x, 23, "<$$setDim 4 5 6 1 2 3>")
  145.         AddTextAnim(734, 254, x, 33, "$$summon [#] - summons a player with")
  146.         AddTextAnim(734, 264, x, 43, "number #. You can see your number in")
  147.         AddTextAnim(734, 274, x, 53, "computer when press <C>. To summon all - ")
  148.         AddTextAnim(734, 284, x, 63, "don't write the number.")
  149.         AddTextAnim(734, 294, x, 73, "<$$summon 4>")
  150.         AddTextAnim(734, 304, x, 83, "$$hyper - jumps into hyperspace. Only works")
  151.         AddTextAnim(734, 314, x, 93, "if you are in space.")
  152.         AddTextAnim(734, 324, x, 103, "<$$hyper>")
  153.         AddTextAnim(734, 334, x, 113, "$$GUI info - hides/shows info. about your")
  154.         AddTextAnim(734, 344, x, 123, "ship.")
  155.         AddTextAnim(734, 354, x, 133, "$$GUI help - hides/shows help info.")
  156.         AddTextAnim(734, 224, x, 143, "$$GUI bigHelp - shows more help info.")
  157.        
  158.        
  159.         if GUIOptions.HideInfo == false then
  160.             local energy = warp.energy()
  161.             local dest = CalcNewCoords(X, Y, Z)
  162.             local players = Explode(",", warp.getAttachedPlayers())
  163.            
  164.             AddText(2, 29, "Energy = "..energy.."EU")
  165.             AddText(2, 39, "x, y, z = "..X..", "..Y..", "..Z)
  166.             AddText(2, 49, "Direction = "..TextDirection(), 0x000000)
  167.             AddText(2, 59, "Distance = "..RealDistance.." ("..JumpCost.."EU, "..math.floor(energy/JumpCost).." jumps)")
  168.             AddText(2, 69, "Dest.coordinates = "..dest.x..", "..dest.y..", "..dest.z)
  169.             if GUIOptions.HidePlayers == false then
  170.                 for i = 1, #players do
  171.                     AddText(2, 69 + i * 10, i..". "..players[i])
  172.                 end
  173.             end
  174.         end
  175.  
  176.         BRIDGE.sync()
  177.     end
  178.     GUIOptions.SmallToBig = false
  179. end
  180.  
  181. function AnimationBigToSmall()
  182.     local speed = 3
  183.     local x = speed
  184.     while x < 148 do
  185.         sleep(.00005)
  186.         BRIDGE.clear()
  187.         InfoBox = BRIDGE.addBox(730, 180, 230, 204 - x, 0xff3300, 0.3)
  188.         InfoBoxLeft = BRIDGE.addBox(730, 182, 2, 200 - x, 0x000000, 0.5)
  189.         InfoBoxRight = BRIDGE.addBox(958, 182 ,2, 200 - x, 0x000000, 0.5)
  190.         InfoBoxTop = BRIDGE.addBox(730, 180, 230, 2, 0x000000, 0.5)
  191.         InfoBoxBottom = BRIDGE.addBox(730, 382 - x, 230, 2, 0x000000, 0.5)
  192.         x = x + speed
  193.        
  194.         AddTextAnim(734, 184, x, 147, "<===========    Small Help    ===========>", true)
  195.         AddTextAnim(734, 194, x, 147, "$$jump [Direction] [Distance] [Quantity]", true)
  196.         AddTextAnim(734, 204, x, 147, "$$update - updates software", true)
  197.         AddTextAnim(734, 214, x, 147, "$$GUI help - hides/shows help info.", true)
  198.         AddTextAnim(734, 224, x, 147, "$$GUI bigHelp - shows more help info.", true)
  199.         AddTextAnim(734, 234, x, 143, "[Down] - sets dimensions of the ship.", true)
  200.         AddTextAnim(734, 244, x, 133, "<$$setDim 4 5 6 1 2 3>", true)
  201.         AddTextAnim(734, 254, x, 123, "$$summon [#] - summons a player with", true)
  202.         AddTextAnim(734, 264, x, 113, "number #. You can see your number in", true)
  203.         AddTextAnim(734, 274, x, 103, "computer when press <C>. To summon all - ", true)
  204.         AddTextAnim(734, 284, x, 93, "don't write the number.", true)
  205.         AddTextAnim(734, 294, x, 83, "<$$summon 4>", true)
  206.         AddTextAnim(734, 304, x, 73, "$$hyper - jumps into hyperspace. Only works", true)
  207.         AddTextAnim(734, 314, x, 63, "if you are in space.", true)
  208.         AddTextAnim(734, 324, x, 53, "<$$hyper>", true)
  209.         AddTextAnim(734, 334, x, 43, "$$GUI info - hides/shows info. about your", true)
  210.         AddTextAnim(734, 344, x, 33, "ship.", true)
  211.         AddTextAnim(734, 354, x, 23, "$$GUI help - hides/shows help info.", true)
  212.         AddTextAnim(734, 224, x, 13, "$$GUI bigHelp - shows more help info.", true)
  213.        
  214.         if GUIOptions.HideInfo == false then
  215.             local energy = warp.energy()
  216.             local dest = CalcNewCoords(X, Y, Z)
  217.             local players = Explode(",", warp.getAttachedPlayers())
  218.            
  219.             AddText(2, 29, "Energy = "..energy.."EU")
  220.             AddText(2, 39, "x, y, z = "..X..", "..Y..", "..Z)
  221.             AddText(2, 49, "Direction = "..TextDirection(), 0x000000)
  222.             AddText(2, 59, "Distance = "..RealDistance.." ("..JumpCost.."EU, "..math.floor(energy/JumpCost).." jumps)")
  223.             AddText(2, 69, "Dest.coordinates = "..dest.x..", "..dest.y..", "..dest.z)
  224.             if GUIOptions.HidePlayers == false then
  225.                 for i = 1, #players do
  226.                     AddText(2, 69 + i * 10, i..". "..players[i])
  227.                 end
  228.             end
  229.         end
  230.  
  231.         BRIDGE.sync()
  232.     end
  233.     GUIOptions.BigToSmall = false
  234. end
  235.  
  236. function AddText(x, y, text, color)
  237.     x = type(x) == "number" and x or 0
  238.     y = type(y) == "number" and y or 0
  239.     AddedTextBlack = BRIDGE.addText(x + 1, y + 1, text, 0x000000)
  240.     AddedText = BRIDGE.addText(x, y, text, 0xffffff)
  241. end
  242.  
  243. function GUIDraw()
  244.     if fs.exists("GUIOptions.txt") then
  245.         LoadGUIOptions()
  246.         newDistance = {}
  247.         MultiJump = {}
  248.     else
  249.         GUIOptions.Update = true
  250.         GUIOptions.BigHelp = false
  251.         GUIOptions.SmallHelp = true
  252.         GUIOptions.HideInfo = false
  253.         GUIOptions.Help = true
  254.         GUIOptions.BigToSmall = false
  255.         GUIOptions.SmallToBig = false
  256.         GUIOptions.HidePlayers = false
  257.         SaveGUIOptions()
  258.        
  259.         newDistance = {}
  260.         MultiJump = {}
  261.     end
  262.    
  263.     while GUIOptions.Update == true do
  264.         sleep(.1)
  265.         BRIDGE.clear()
  266.        
  267.         if GUIOptions.SmallHelp == true and GUIOptions.Help == true then
  268.             InfoBox = BRIDGE.addBox(730, 180, 230, 54, 0xff3300, 0.3)
  269.             InfoBoxLeft = BRIDGE.addBox(730, 182, 2, 50, 0x000000, 0.5)
  270.             InfoBoxRight = BRIDGE.addBox(958, 182 ,2, 50, 0x000000, 0.5)
  271.             InfoBoxTop = BRIDGE.addBox(730, 180, 230, 2, 0x000000, 0.5)
  272.             InfoBoxBottom = BRIDGE.addBox(730, 232, 230, 2, 0x000000, 0.5)
  273.            
  274.             AddText(734, 184, "<===========    Small Help    ===========>")
  275.             AddText(734, 194, "$$jump [Direction] [Distance] [Quantity]")
  276.             AddText(734, 204, "$$update - updates software")
  277.             AddText(734, 214, "$$GUI help - hides/shows help info.")
  278.             AddText(734, 224, "$$GUI bigHelp - shows more help info.")
  279.            
  280.         end
  281.        
  282.         if GUIOptions.SmallToBig == true then
  283.             GUIOptions.Update = false
  284.             GUIOptions.SmallHelp = false
  285.             AnimationSmallToBig()
  286.             GUIOptions.BigHelp = true
  287.             GUIOptions.Update = true
  288.             SaveGUIOptions()
  289.         end
  290.        
  291.         if GUIOptions.BigHelp == true and GUIOptions.Help == true then
  292.             InfoBox = BRIDGE.addBox(730, 180, 230, 204, 0xff3300, 0.3)
  293.             InfoBoxLeft = BRIDGE.addBox(730, 182, 2, 200, 0x000000, 0.5)
  294.             InfoBoxRight = BRIDGE.addBox(958, 182 ,2, 200, 0x000000, 0.5)
  295.             InfoBoxTop = BRIDGE.addBox(730, 180, 230, 2, 0x000000, 0.5)
  296.             InfoBoxBottom = BRIDGE.addBox(730, 382, 230, 2, 0x000000, 0.5)
  297.            
  298.             AddText(734, 184, "<===========     Big Help      ===========>")
  299.             AddText(734, 194, "$$jump [Direction] [Distance] [Quantity] -")
  300.             AddText(734, 204, "warps few times. If quantity wasn't set  -")
  301.             AddText(734, 214, "jumps once. <$$jump up 58 3>")
  302.             AddText(734, 224, "$$setDim [Front] [Right] [Up] [Back] [Left]")
  303.             AddText(734, 234, "[Down] - sets dimensions of the ship.")
  304.             AddText(734, 244, "<$$setDim 4 5 6 1 2 3>")
  305.             AddText(734, 254, "$$summon [#] - summons a player with")
  306.             AddText(734, 264, "number #. You can see your number in")
  307.             AddText(734, 274, "computer when press <C>. To summon all - ")
  308.             AddText(734, 284, "don't write the number.")
  309.             AddText(734, 294, "<$$summon 4>")
  310.             AddText(734, 304, "$$hyper - jumps into hyperspace. Only works")
  311.             AddText(734, 314, "if you are in space.")
  312.             AddText(734, 324, "<$$hyper>")
  313.             AddText(734, 334, "$$GUI info - hides/shows info. about your")
  314.             AddText(734, 344, "ship.")
  315.             AddText(734, 354, "$$GUI help - hides/shows help info.")
  316.             AddText(734, 364, "$$GUI smallHelp - shows less help info.")
  317.             AddText(734, 374, "Version - "..version)
  318.         end
  319.        
  320.         if GUIOptions.BigToSmall == true then
  321.             GUIOptions.Update = false
  322.             GUIOptions.BigHelp = false
  323.             AnimationBigToSmall()
  324.             GUIOptions.SmallHelp = true
  325.             GUIOptions.Update = true
  326.             SaveGUIOptions()
  327.         end
  328.        
  329.         if GUIOptions.HideInfo == false then
  330.             local energy = warp.energy()
  331.             local dest = CalcNewCoords(X, Y, Z)
  332.             local players = Explode(",", warp.getAttachedPlayers())
  333.            
  334.             AddText(2, 29, "Energy = "..energy.."EU")
  335.             AddText(2, 39, "x, y, z = "..X..", "..Y..", "..Z)
  336.             AddText(2, 49, "Direction = "..TextDirection(), 0x000000)
  337.             AddText(2, 59, "Distance = "..RealDistance.." ("..JumpCost.."EU, "..math.floor(energy/JumpCost).." jumps)")
  338.             AddText(2, 69, "Dest.coordinates = "..dest.x..", "..dest.y..", "..dest.z)
  339.             if GUIOptions.HidePlayers == false then
  340.                 for i = 1, #players do
  341.                     AddText(2, 69 + i * 10, i..". "..players[i])
  342.                     maxTextY = 69 + i * 10
  343.                 end
  344.             end
  345.         end
  346.  
  347.         BRIDGE.sync()
  348.     end
  349. end
  350.  
  351. function SaveJumpOnCoords()
  352.     local JOC = fs.open("JumpOnCoords.txt", "w")
  353.     JOC.writeLine(textutils.serialize(MultiJump))
  354.     JOC.close()
  355. end
  356.  
  357. function LoadJumpOnCoords()
  358.     local JOC = fs.open("JumpOnCoords.txt", "r")
  359.     MultiJump = textutils.unserialize(JOC.readAll())
  360.     JOC.close()
  361. end
  362.  
  363. function Glasses()
  364.     while true do
  365.         command = {}
  366.         event, side, nick, uuid, message = os.pullEvent()
  367.         if event == "glasses_chat_command" then
  368.             for message in string.gmatch(message, "%S+") do
  369.                 command[#command+1] = message
  370.             end
  371.             print(message)
  372.            
  373.             if command[1] == "setDim" then
  374.            
  375.                 GFront = tonumber(command[2])
  376.                 GRight = tonumber(command[3])
  377.                 GUp = tonumber(command[4])
  378.                 GBack = tonumber(command[5])
  379.                 GLeft = tonumber(command[6])
  380.                 GDown = tonumber(command[7])
  381.                
  382.                 warp.dim_setp(GFront, GRight, GUp)
  383.                 warp.dim_setn(GBack, GLeft, GDown)
  384.                
  385.                 SaveData()
  386.                
  387.             elseif command[1] == "jump" then
  388.                 if command[2] == "forward" or command[2] == "front" then
  389.                     SData.Direction = 0
  390.                 elseif command[2] == "up" then
  391.                     SData.Direction = 1
  392.                 elseif command[2] == "left" then
  393.                     SData.Direction = 90
  394.                 elseif command[2] == "right" then
  395.                     SData.Direction = 255
  396.                 elseif command[2] == "back" then
  397.                     SData.Direction = 180
  398.                 elseif command[2] == "down" then
  399.                     SData.Direction = 2
  400.                 end
  401.                 SData.Distance = 0
  402.                 CalcRealDistance()
  403.                 MaximumDistance = MinimumDistance + 127
  404.                 SData.Distance = tonumber(command[3])
  405.                 if SData.Distance == nil then
  406.                     SData.Distance = 1
  407.                 end
  408.                 if SData.Distance < MinimumDistance or SData.Distance > MaximumDistance then
  409.                     SData.Distance = 1
  410.                     CalcRealDistance()
  411.                 else
  412.                     if not IsInHyper then
  413.                         SData.Distance = SData.Distance - RealDistance
  414.                     end
  415.                     warp.set_distance(SData.Distance)
  416.                     CalcRealDistance()
  417.                 end
  418.                 SaveData()
  419.                 if command[4] == nil or command[4] == 1 then
  420.                     CreateMultiJumpFile("0")
  421.                 else
  422.                     CreateMultiJumpFile(command[4] - 1)
  423.                 end
  424.                 Warp()
  425.             elseif command[1] == "jumpOnCoords" then
  426.                 if command[2] ~= nil and command[4] ~= nil then
  427.                     local destCoordX, destCoordY, destCoordZ = tonumber(command[2]), tonumber(command[3]), tonumber(command[4])
  428.                     CalcNewCoords(warp.get_x(), warp.get_y(), warp.get_z())
  429.                     newCoords = {x = res.x, y = res.y, z = res.z}
  430.                     newDistance = {x = destCoordX - warp.get_x(), y = destCoordY - warp.get_y(), z = destCoordZ - warp.get_z()}
  431.                     MultiJump = {}
  432.                    
  433.                     if command[5] ~= nil then
  434.                         if command[5] == "hyper" then
  435.                             MultiJump.Hyper = true
  436.                         elseif command[5] == "space" then
  437.                             MultiJump.Space = true
  438.                         elseif command[5] == "earth" then
  439.                             MultiJump.Earth = true
  440.                         else
  441.                             MultiJump.NotGoInAnotherDim = true
  442.                         end
  443.                     else
  444.                         MultiJump.NotGoInAnotherDim = true
  445.                     end
  446.                    
  447.                     --searching sides
  448.                     SData.Direction = 0
  449.                     SData.Distance = 50
  450.                     CalcNewCoords(warp.get_x(), warp.get_y(), warp.get_z())
  451.                     if warp.get_x() > res.x then
  452.                         MultiJump.MinusX = 0
  453.                         MultiJump.PlusX = 180
  454.                     elseif warp.get_x() < res.x then
  455.                         MultiJump.MinusX = 180
  456.                         MultiJump.PlusX = 0
  457.                     elseif warp.get_z() > res.z then
  458.                         MultiJump.MinusZ = 0
  459.                         MultiJump.PlusZ = 180
  460.                     elseif warp.get_z() < res.z then
  461.                         MultiJump.MinusZ = 180
  462.                         MultiJump.PlusZ = 0
  463.                     end
  464.                    
  465.                     if MultiJump.MinusX == 0 and MultiJump.PlusX == 180 then
  466.                         MultiJump.PlusZ = 90
  467.                         MultiJump.MinusZ = 255
  468.                     elseif MultiJump.MinusX == 180 and MultiJump.PlusX == 0 then
  469.                         MultiJump.PlusZ = 255
  470.                         MultiJump.MinusZ = 90
  471.                     elseif MultiJump.MinusZ == 0 and MultiJump.PlusZ == 180 then
  472.                         MultiJump.PlusX = 255
  473.                         MultiJump.MinusX = 90
  474.                     elseif MultiJump.MinusZ == 180 and MultiJump.PlusZ == 0 then
  475.                         MultiJump.PlusX = 90
  476.                         MultiJump.MinusX = 255
  477.                     end
  478.                    
  479.                     if newDistance.x < 0 then
  480.                         MultiJump.DirectionX = MultiJump.MinusX
  481.                     elseif newDistance.x > 0 then
  482.                         MultiJump.DirectionX = MultiJump.PlusX
  483.                     end
  484.                    
  485.                     SData.Direction = MultiJump.DirectionX
  486.                     SData.Distance = 0
  487.                     CalcRealDistance()
  488.                     MaximumDistanceX = MinimumDistance + 127
  489.                    
  490.                     if newDistance.y < 0 then
  491.                         MultiJump.DirectionY = 2
  492.                     elseif newDistance.y > 0 then
  493.                         MultiJump.DirectionY = 1
  494.                     end
  495.                    
  496.                     SData.Direction = MultiJump.DirectionY
  497.                     SData.Distance = 0
  498.                     CalcRealDistance()
  499.                     MaximumDistanceY = MinimumDistance + 127
  500.                    
  501.                     if newDistance.z < 0 then
  502.                         MultiJump.DirectionZ = MultiJump.MinusZ
  503.                     elseif newDistance.z > 0 then
  504.                         MultiJump.DirectionZ = MultiJump.PlusZ
  505.                     end
  506.                    
  507.                     SData.Direction = MultiJump.DirectionZ
  508.                     SData.Distance = 0
  509.                     CalcRealDistance()
  510.                     MaximumDistanceZ = MinimumDistance + 127
  511.                    
  512.                     --counting distance and quantity of jumps
  513.                     local d = math.abs(MaximumDistanceX)
  514.                     local q = 0
  515.                     MultiJump.Loop = true
  516.                     while MultiJump.Loop do
  517.                         if d < newDistance.x then
  518.                             q = q + 1
  519.                             d = d + MaximumDistanceX
  520.                         elseif d == newDistance.x then
  521.                             MultiJump.JumpX = q + 1
  522.                             MultiJump.AddJumpX = "none"
  523.                             MultiJump.Loop = false
  524.                         elseif d > newDistance.x then
  525.                             MultiJump.JumpX = q
  526.                             MultiJump.AddJumpX = newDistance.x - (d - MaximumDistanceX) - (MaximumDistanceX - 128)
  527.                             MultiJump.Loop = false
  528.                         end
  529.                     end
  530.                    
  531.                     --[[if newDistance.y ~= 0 then
  532.                         local d = MaximumDistanceY
  533.                         local q = 0
  534.                         MultiJump.Loop = true
  535.                         while MultiJump.Loop do
  536.                             if d < newDistance.y then
  537.                                 q = q + 1
  538.                                 d = d + MaximumDistanceY
  539.                             elseif d == newDistance.y then
  540.                                 MultiJump.JumpY = q + 1
  541.                                 MultiJump.AddJumpY = "none"
  542.                                 MultiJump.Loop = false
  543.                             elseif d > newDistance.y then
  544.                                 MultiJump.JumpY = q
  545.                                 MultiJump.AddJumpY = newDistance.y - (d - MaximumDistanceY)
  546.                                 MultiJump.Loop = false
  547.                             end
  548.                         end
  549.                     end--]]
  550.                    
  551.                     local d = math.abs(MaximumDistanceZ)
  552.                     local q = 0
  553.                     MultiJump.Loop = true
  554.                     while MultiJump.Loop do
  555.                         if d < newDistance.z then
  556.                             q = q + 1
  557.                             d = d + MaximumDistanceZ
  558.                         elseif d == newDistance.z then
  559.                             MultiJump.JumpZ = q + 1
  560.                             MultiJump.AddJumpZ = "none"
  561.                             MultiJump.Loop = false
  562.                         elseif d > newDistance.z then
  563.                             MultiJump.JumpZ = q
  564.                             MultiJump.AddJumpZ = newDistance.z - (d - MaximumDistanceZ) - (MaximumDistanceZ - 128)
  565.                             MultiJump.Loop = false
  566.                         end
  567.                     end
  568.                        
  569.                     SaveJumpOnCoords()
  570.                     sleep(5)
  571.                     os.reboot()
  572.                 end
  573.             elseif command[1] == "summon" then
  574.                 if command[2] == nil then
  575.                     warp.summon_all()
  576.                 else
  577.                     warp.summon(command[2] - 1)
  578.                 end
  579.             elseif command[1] == "hyper" then
  580.                 if IsInSpace or IsInHyper then
  581.                     warp.mode(5)
  582.                     warp.do_jump()
  583.                 end
  584.             elseif command[1] == "update" then
  585.                 UpdateSoftware()
  586.                 os.reboot()
  587.             elseif command[1] == "GUI" then
  588.                 if command[2] == "help" then
  589.                     if GUIOptions.Help == false then
  590.                         GUIOptions.Help = true
  591.                     else
  592.                         GUIOptions.Help = false
  593.                     end
  594.                 elseif command[2] == "bigHelp" and GUIOptions.Help == true then
  595.                     if GUIOptions.BigHelp == false then
  596.                         GUIOptions.SmallToBig = true
  597.                     end
  598.                 elseif command[2] == "smallHelp" and GUIOptions.Help == true then
  599.                     if GUIOptions.SmallHelp == false then
  600.                         GUIOptions.BigToSmall = true
  601.                     end
  602.                 elseif command[2] == "info" then
  603.                     if GUIOptions.HideInfo == false then
  604.                         GUIOptions.HideInfo = true
  605.                     else
  606.                         GUIOptions.HideInfo = false
  607.                     end
  608.                 elseif command[2] == "players" and GUIOptions.HideInfo == false then
  609.                     if GUIOptions.HidePlayers == false then
  610.                         GUIOptions.HidePlayers = true
  611.                     else
  612.                         GUIOptions.HidePlayers = false
  613.                     end
  614.                 end
  615.                 SaveGUIOptions()
  616.             end
  617.             SaveData()
  618.         end
  619.     end
  620. end
  621.  
  622. function JumpingOnCoords()
  623.     if fs.exists("JumpOnCoords.txt") then
  624.         sleep(.1)
  625.         SData.Distance = 0
  626.         CalcRealDistance()
  627.         MaximumDistance = MinimumDistance + 127
  628.         LoadJumpOnCoords()
  629.         if MultiJump.Jump ~= nil then
  630.        
  631.             if not IsInHyper then
  632.                 MaximumDistance = MaximumDistance - RealDistance
  633.             end
  634.            
  635.             if MultiJump.JumpX > 0 then
  636.                 if MultiJump.Hyper == true then
  637.                     if warp.isInSpace() == true then
  638.                         warp.mode(5)
  639.                         warp.do_jump()
  640.                         sleep(10)
  641.                     elseif warp.isInSpace() == false and warp.isInHyperspace() == false then
  642.                         warp.set_direction(1)
  643.                         warp.set_distance(MaximumDistance)
  644.                         CalcRealDistance()
  645.                         warp.mode(1)
  646.                         warp.do_jump()
  647.                         sleep(10)
  648.                     else
  649.                         MultiJump.JumpX = MultiJump.JumpX - 1
  650.                         SaveJumpOnCoords()
  651.                         warp.set_direction(MultiJump.DirectionX)
  652.                         warp.set_distance(MaximumDistance)
  653.                         CalcRealDistance()
  654.                         warp.mode(2)
  655.                         warp.do_jump()
  656.                         sleep(10)
  657.                     end
  658.                 elseif MultiJump.Space == true then
  659.                     if warp.isInSpace() == false and warp.isInHyperspace() == false then
  660.                         warp.set_direction(1)
  661.                         warp.set_distance(MaximumDistance)
  662.                         CalcRealDistance()
  663.                         warp.mode(1)
  664.                         warp.do_jump()
  665.                         sleep(10)
  666.                     elseif warp.isInHyperspace() == true then
  667.                         warp.mode(5)
  668.                         warp.do_jump()
  669.                         sleep(10)
  670.                     else
  671.                         MultiJump.JumpX = MultiJump.JumpX - 1
  672.                         SaveJumpOnCoords()
  673.                         warp.set_direction(MultiJump.DirectionX)
  674.                         warp.set_distance(MaximumDistance)
  675.                         CalcRealDistance()
  676.                         warp.mode(1)
  677.                         warp.do_jump()
  678.                         sleep(10)
  679.                     end
  680.                 elseif MultiJump.Earth == true then
  681.                     if warp.isInSpace() == true then
  682.                         warp.set_direction(2)
  683.                         warp.set_distance(MaximumDistance)
  684.                         CalcRealDistance()
  685.                         warp.mode(1)
  686.                         warp.do_jump()
  687.                         sleep(10)
  688.                     elseif warp.isInHyperspace() == true then
  689.                         warp.mode(5)
  690.                         warp.do_jump()
  691.                         sleep(10)
  692.                     else
  693.                         MultiJump.JumpX = MultiJump.JumpX - 1
  694.                         SaveJumpOnCoords()
  695.                         warp.set_direction(MultiJump.DirectionX)
  696.                         warp.set_distance(MaximumDistance)
  697.                         CalcRealDistance()
  698.                         warp.mode(1)
  699.                         warp.do_jump()
  700.                         sleep(10)
  701.                     end
  702.                 elseif MultiJump.NotGoInAnotherDim == true then
  703.                     if warp.isInHyperspace() == true then
  704.                         MultiJump.JumpX = MultiJump.JumpX - 1
  705.                         SaveJumpOnCoords()
  706.                         warp.set_direction(MultiJump.DirectionX)
  707.                         warp.set_distance(MaximumDistance)
  708.                         CalcRealDistance()
  709.                         warp.mode(2)
  710.                         warp.do_jump()
  711.                         sleep(10)
  712.                     else
  713.                         MultiJump.JumpX = MultiJump.JumpX - 1
  714.                         SaveJumpOnCoords()
  715.                         warp.set_direction(MultiJump.DirectionX)
  716.                         warp.set_distance(MaximumDistance)
  717.                         CalcRealDistance()
  718.                         warp.mode(1)
  719.                         warp.do_jump()
  720.                         sleep(10)
  721.                     end
  722.                 end
  723.             end
  724.         end
  725.        
  726.         sleep(.1)
  727.        
  728.         if MultiJump.AddJumpX ~= "none" and MultiJump.AddJumpX ~= nil then
  729.             if MultiJump.AddJumpX < 0 then
  730.                 warp.set_direction(MultiJump.DirectionX)
  731.                 warp.set_distance(-MultiJump.AddJumpX - 1) --KOSTYL
  732.                 CalcRealDistance()
  733.                 MultiJump.AddJumpX = "none"
  734.                 SaveJumpOnCoords()
  735.                 if warp.isInHyperspace() == true then
  736.                     warp.mode(2)
  737.                     warp.do_jump()
  738.                     sleep(10)
  739.                 else
  740.                     warp.mode(1)
  741.                     warp.do_jump()
  742.                     sleep(10)
  743.                 end
  744.             elseif MultiJump.AddJumpX > 0 then
  745.                 warp.set_direction(MultiJump.DirectionX)
  746.                 warp.set_distance(MultiJump.AddJumpX + 1) --KOSTYL
  747.                 CalcRealDistance()
  748.                 MultiJump.AddJumpX = "none"
  749.                 SaveJumpOnCoords()
  750.                 if warp.isInHyperspace() == true then
  751.                     warp.mode(2)
  752.                     warp.do_jump()
  753.                     sleep(10)
  754.                 else
  755.                     warp.mode(1)
  756.                     warp.do_jump()
  757.                     sleep(10)
  758.                 end
  759.             end
  760.         end
  761.        
  762.         sleep(.1)
  763.        
  764.         if MultiJump.JumpZ ~= nil then
  765.             if MultiJump.JumpZ > 0 then
  766.                 MultiJump.JumpZ = MultiJump.JumpZ - 1
  767.                 SaveJumpOnCoords()
  768.                 warp.set_direction(MultiJump.DirectionZ)
  769.                 warp.set_distance(MaximumDistance)
  770.                 CalcRealDistance()
  771.                 if warp.isInHyperspace() == true then
  772.                     warp.mode(2)
  773.                     warp.do_jump()
  774.                     sleep(10)
  775.                 else
  776.                     warp.mode(1)
  777.                     warp.do_jump()
  778.                     sleep(10)
  779.                 end
  780.             end
  781.         end
  782.        
  783.         sleep(.1)
  784.        
  785.         if MultiJump.AddJumpZ ~= "none" and MultiJump.AddJumpZ ~= nil then
  786.             if MultiJump.AddJumpZ < 0 then
  787.                 warp.set_direction(MultiJump.DirectionZ)
  788.                 warp.set_distance(-MultiJump.AddJumpZ - 1) --KOSTYL
  789.                 CalcRealDistance()
  790.                 MultiJump.AddJumpZ = "none"
  791.                 SaveJumpOnCoords()
  792.                 if warp.isInHyperspace() == true then
  793.                     warp.mode(2)
  794.                     warp.do_jump()
  795.                     sleep(10)
  796.                 else
  797.                     warp.mode(1)
  798.                     warp.do_jump()
  799.                     sleep(10)
  800.                 end
  801.             elseif MultiJump.AddJumpZ > 0 then
  802.                 warp.set_direction(MultiJump.DirectionZ)
  803.                 warp.set_distance(MultiJump.AddJumpZ + 1) --KOSTYL
  804.                 CalcRealDistance()
  805.                 MultiJump.AddJumpZ = "none"
  806.                 SaveJumpOnCoords()
  807.                 if warp.isInHyperspace() == true then
  808.                     warp.mode(2)
  809.                     warp.do_jump()
  810.                     sleep(10)
  811.                 else
  812.                     warp.mode(1)
  813.                     warp.do_jump()
  814.                     sleep(10)
  815.                 end
  816.             end
  817.         end
  818.        
  819.         sleep(.1)
  820.        
  821.         JumpedOnCoords = true
  822.     end
  823. end
  824.  
  825. function DoMultiJump()
  826.     if fs.exists("multijump.txt") and JumpedOnCoords == false then
  827.         sleep(.1)
  828.         ReadData()
  829.         local rj = fs.open("multijump.txt", "r")
  830.         mjt = tonumber(rj.readAll())
  831.         rj.close()
  832.         if mjt > 1 or mjt == 1 then
  833.             local w = fs.open("multijump.txt", "w")
  834.             w.write(mjt - 1)
  835.             w.close()
  836.             Warp()
  837.         else
  838.             StartAll = true
  839.         end
  840.     else
  841.         StartAll = true
  842.     end
  843. end
  844.  
  845. function CreateMultiJumpFile(j)
  846.     local wj = fs.open("multijump.txt", "w")
  847.     wj.write(tostring(j))
  848.     wj.close()
  849. end
  850.  
  851. function Explode(d, p)
  852.     local t, ll
  853.     t = {}
  854.     ll = 0
  855.     if(#p == 1) then return {p} end
  856.     while true do
  857.         l = string.find(p ,d, ll, true)
  858.         if l ~= nil then
  859.             table.insert(t, string.sub(p, ll, l-1))
  860.             ll = l+1
  861.         else
  862.             table.insert(t, string.sub(p, ll))
  863.             break
  864.         end
  865.     end
  866.     return t
  867. end
  868.  
  869. function ShowDirection()
  870.     if SData.Direction == 1 then
  871.         Show(" Direction        = Up")
  872.     elseif SData.Direction == 2 then
  873.         Show(" Direction        = Down")
  874.     elseif SData.Direction == 0 then
  875.         Show(" Direction        = Front")
  876.     elseif SData.Direction == 180 then
  877.         Show(" Direction        = Back")
  878.     elseif SData.Direction == 90 then
  879.         Show(" Direction        = Left")
  880.     elseif SData.Direction == 255 then
  881.         Show(" Direction        = Right")
  882.     end
  883. end
  884.  
  885. function CalcRealDistance()
  886.     if IsInHyper then
  887.         RealDistance = SData.Distance * 100
  888.         MinimumDistance = 1
  889.         JumpCost = (1000 * Weight) + (1000 * SData.Distance)
  890.     else
  891.         if SData.Direction == 1 or SData.Direction == 2 then
  892.             MinimumDistance = GUp + GDown
  893.             RealDistance = SData.Distance + MinimumDistance
  894.         elseif SData.Direction == 0 or SData.Direction == 180 then
  895.             MinimumDistance = GFront + GBack
  896.             RealDistance = SData.Distance + MinimumDistance
  897.         elseif SData.Direction == 90 or SData.Direction == 255 then
  898.             MinimumDistance = GLeft + GRight
  899.             RealDistance = SData.Distance + MinimumDistance
  900.         end
  901.         MinimumDistance = MinimumDistance + 1
  902.         JumpCost = (10 * Weight) + (100 * SData.Distance)
  903.     end
  904. end
  905.  
  906. function CalcNewCoords(cx, cy, cz)
  907.     res = {x=cx, y=cy, z=cz}
  908.     -- if SData.Direction == 1 then
  909.     --  res.y = res.y + RealDistance
  910.     -- elseif SData.Direction == 2 then
  911.     --  res.y = res.y - RealDistance
  912.     -- end
  913.     -- local dx = warp.get_dx()
  914.     -- local dz = warp.get_dz()
  915.     -- if dx ~= 0 then
  916.     --  if SData.Direction == 0 then
  917.     --      res.x = res.x + (RealDistance * dx)
  918.     --  elseif SData.Direction == 180 then
  919.     --      res.x = res.x - (RealDistance * dx)
  920.     --  elseif SData.Direction == 90 then
  921.     --      res.z = res.z + (RealDistance * dx)
  922.     --  elseif SData.Direction == 255 then
  923.     --      res.z = res.z - (RealDistance * dx)
  924.     --  end
  925.     -- else
  926.     --  if SData.Direction == 0 then
  927.     --      res.z = res.z + (RealDistance * dz)
  928.     --  elseif SData.Direction == 180 then
  929.     --      res.z = res.z - (RealDistance * dz)
  930.     --  elseif SData.Direction == 90 then
  931.     --      res.x = res.x + (RealDistance * dz)
  932.     --  elseif SData.Direction == 255 then
  933.     --      res.x = res.x - (RealDistance * dz)
  934.     --  end
  935.     -- end
  936.     return res
  937. end
  938.  
  939. function ShowInfo()
  940.     ShowTitle(Title)
  941.     Show("Core: "..SData["CurrentCore"])
  942.     Show(" x, y, z          = "..X..", "..Y..", "..Z)
  943.     local energy = warp.energy()
  944.     Show(" Energy           = "..math.floor(energy / 1000000).." % ("..energy.."EU)")
  945.     Show(" Attached players = "..warp.getAttachedPlayers())
  946.     Show("Dimensions:")
  947.     Show(" Front, Right, Up = "..GFront..", "..GRight..", "..GUp)
  948.     Show(" Back, Left, Down = "..GBack..", "..GLeft..", "..GDown)
  949.     Show(" Size             = "..Weight.." blocks")
  950.     Show("Warp data:")
  951.     ShowDirection()
  952.     local dest = CalcNewCoords(X, Y, Z)
  953.     Show(" Distance         = "..RealDistance.." ("..JumpCost.."EU, "..math.floor(energy/JumpCost).." jumps)")
  954.     Show(" Dest.coordinates = "..dest.x..", "..dest.y..", "..dest.z)
  955.     if SData.Summon then
  956.         Show(" Summon after     = Yes")
  957.     else
  958.         Show(" Summon after     = No")
  959.     end
  960. end
  961.  
  962. function Confirm()
  963.     ShowWarning("Are you sure? (y/n)")
  964.     local event, keycode = os.pullEvent("key")
  965.     if keycode == 21 then
  966.         return true
  967.     else
  968.         return false
  969.     end
  970. end
  971.  
  972. function Warp()
  973.     PowerOffAllCores()
  974.     rs.setOutput(Alarm, false)
  975.     sleep(.5)
  976.     warp.set_direction(SData.Direction)
  977.     if IsInHyper then
  978.         warp.mode(2)
  979.     else
  980.         warp.mode(1)
  981.     end
  982.     warp.do_jump()
  983. end
  984.  
  985. function SetDistance()
  986.     Clear()
  987.     ShowTitle("<====  Set distance  ====>")
  988.     SData.Distance = 0
  989.     CalcRealDistance()
  990.     MaximumDistance = MinimumDistance + 127
  991.     if IsInHyper then
  992.         term.write("Distance * 100 (min "..MinimumDistance..", max "..MaximumDistance.."): ")
  993.     else
  994.         term.write("Distance (min "..MinimumDistance..", max "..MaximumDistance.."): ")
  995.     end
  996.     sleep(.3)
  997.     SData.Distance = tonumber(read())
  998.     if SData.Distance == nil then
  999.         SData.Distance = 1
  1000.     end
  1001.     if SData.Distance < MinimumDistance or SData.Distance > MaximumDistance then
  1002.         SData.Distance = 1
  1003.         ShowWarning("Wrong distance. Try again.")
  1004.         os.pullEvent("key")
  1005.         CalcRealDistance()
  1006.     else
  1007.         if not IsInHyper then
  1008.             SData.Distance = SData.Distance - RealDistance
  1009.         end
  1010.         warp.set_distance(SData.Distance)
  1011.         CalcRealDistance()
  1012.     end
  1013. end
  1014.  
  1015. function SetDirection()
  1016.     local drun = true
  1017.     while(drun) do
  1018.         Clear()
  1019.         ShowTitle("<==== Set direction ====>")
  1020.         ShowDirection()
  1021.         term.setCursorPos(1, 16)
  1022.         SetColorTitle()
  1023.         ShowMenu("Use directional keys")
  1024.         ShowMenu("W/S keys for Up/Down")
  1025.         ShowMenu("Enter - confirm")
  1026.         SetColorDeflt()
  1027.         local event, keycode = os.pullEvent("key")
  1028.         if keycode == 200 then
  1029.             SData.Direction = 0
  1030.         elseif keycode == 17 then
  1031.             SData.Direction = 1
  1032.         elseif keycode == 203 then
  1033.             SData.Direction = 90
  1034.         elseif keycode == 205 then
  1035.             SData.Direction = 255
  1036.         elseif keycode == 208 then
  1037.             SData.Direction = 180
  1038.         elseif keycode == 31 then
  1039.             SData.Direction = 2
  1040.         elseif keycode == 28 then
  1041.             drun = false
  1042.         end
  1043.     end
  1044. end
  1045.  
  1046. function SetDimensions()
  1047.     Clear()
  1048.     sleep(.3)
  1049.     ShowTitle("<== Set dimensions for "..SData["CurrentCore"].." ==>")
  1050.     term.write(" Front ("..GFront..") : ")
  1051.     GFront = tonumber(read())
  1052.     term.write(" Right ("..GRight..") : ")
  1053.     GRight = tonumber(read())
  1054.     term.write(" Up    ("..GUp..") : ")
  1055.     GUp = tonumber(read())
  1056.     term.write(" Back  ("..GBack..") : ")
  1057.     GBack = tonumber(read())
  1058.     term.write(" Left  ("..GLeft..") : ")
  1059.     GLeft = tonumber(read())
  1060.     term.write(" Down  ("..GDown..") : ")
  1061.     GDown = tonumber(read())
  1062.     term.write("Setting dimensions...")
  1063.     warp.dim_setp(GFront, GRight, GUp)
  1064.     warp.dim_setn(GBack, GLeft, GDown)
  1065. end
  1066.  
  1067. function ChooseWarpCore()
  1068.     Clear()
  1069.     sleep(.3)
  1070.     ShowTitle("<==== Select warpcore ====>")
  1071.     GetCoreInfo()
  1072.     Show("Current core: " .. warps[curCoreIndex]["ID"])
  1073.     Show(" x, y, z          = "..X..", "..Y..", "..Z)
  1074.     local energy = warp.energy()
  1075.     Show(" Energy           = "..math.floor(energy / 1000000).." % ("..energy.."EU)")
  1076.     Show(" Attached players = "..warp.getAttachedPlayers())
  1077.     Show("Dimensions:")
  1078.     Show(" Front, Right, Up = "..GFront..", "..GRight..", "..GUp)
  1079.     Show(" Back, Left, Down = "..GBack..", "..GLeft..", "..GDown)
  1080.     Show(" Size             = "..Weight.." blocks")
  1081.     ShowMenu("Press <Left> or <Right> to switch core")
  1082.     ShowMenu("Press <Enter> to select core")
  1083.     local event, keycode = os.pullEvent("key")
  1084.     if keycode == 28 then
  1085.         return
  1086.     elseif keycode == 203 then -- Left
  1087.         if curCoreIndex==1 then
  1088.             curCoreIndex = #warps
  1089.         else
  1090.             curCoreIndex = curCoreIndex-1
  1091.         end
  1092.     elseif keycode == 205 then -- Right
  1093.         if curCoreIndex==#warps then
  1094.             curCoreIndex = 1
  1095.         else
  1096.             curCoreIndex = curCoreIndex+1
  1097.         end
  1098.     end
  1099.     warp = warps[curCoreIndex]["core"]
  1100.     SData["CurrentCore"] = warps[curCoreIndex]["ID"]
  1101.     ChooseWarpCore()
  1102. end
  1103.  
  1104. function Summon()
  1105.     Clear()
  1106.     ShowTitle("<==== Summon players ====>")
  1107.     local players = Explode(",", warp.getAttachedPlayers())
  1108.     for i = 1, #players do
  1109.         Show(i..". "..players[i])
  1110.     end
  1111.     SetColorTitle()
  1112.     ShowMenu("Enter player number")
  1113.     ShowMenu("or press enter to summon everyone")
  1114.     SetColorDeflt()
  1115.     sleep(.3)
  1116.     term.write(":")
  1117.     local input = read()
  1118.     if input == "" then
  1119.         warp.summon_all()
  1120.     else
  1121.         input = tonumber(input)
  1122.         warp.summon(input - 1)
  1123.     end
  1124. end
  1125.  
  1126. function JumpToBeacon()
  1127.     Clear()
  1128.     ShowTitle("<==== Jump to beacon ====>")
  1129.     sleep(.3)
  1130.     term.write("Enter beacon frequency: ")
  1131.     local freq = tostring(read())
  1132.     rs.setOutput(Alarm, true)
  1133.     if Confirm() then
  1134.         rs.setOutput(Alarm, false)
  1135.         warp.mode(4)
  1136.         warp.set_beacon_frequency(freq)
  1137.         warp.do_jump()
  1138.     end
  1139.     rs.setOutput(Alarm, false)
  1140. end
  1141.  
  1142. function JumpToGate()
  1143.     Clear()
  1144.     ShowTitle("<==== Jump to JumpGate ====>")
  1145.     sleep(.3)
  1146.     term.write("Enter jumpgate name: ")
  1147.     local name = tostring(read())
  1148.     rs.setOutput(Alarm, true)
  1149.     if Confirm() then
  1150.         rs.setOutput(Alarm, false)
  1151.         warp.mode(6)
  1152.         warp.set_target_jumpgate(name)
  1153.         warp.do_jump()
  1154.     end
  1155.     rs.setOutput(Alarm, false)
  1156. end
  1157.  
  1158. function SetShipName()
  1159.     Clear()
  1160.     ShowTitle("<==== Set ship name ====>")
  1161.     sleep(.3)
  1162.     term.write("Enter ship name: ")
  1163.     SData.Shipname = tostring(read())
  1164.     os.setComputerLabel(SData.Shipname)
  1165.     warp.shipName(SData.Shipname)
  1166.     SaveData()
  1167.     -- os.reboot()
  1168. end
  1169.  
  1170. function PowerOffAllCores()
  1171.     for i = 1,#warps do
  1172.         warps[i]["core"].mode(0)
  1173.     end
  1174. end
  1175.  
  1176. function PowerOnAllCores()
  1177.     for i = 1,#warps do
  1178.         warps[i]["core"].mode(1)
  1179.     end
  1180. end
  1181.  
  1182. function GetCoreInfo()
  1183.     GFront, GRight, GUp = warp.dim_positive()
  1184.     GBack, GLeft, GDown = warp.dim_negative()
  1185.     IsInHyper = warp.isInHyperspace()
  1186.     IsInSpace = warp.isInSpace()
  1187.     X, Y, Z = warp.position()
  1188.     Weight = warp.getShipSize()
  1189. end
  1190.  
  1191. function UpdateSoftware()
  1192.     shell.run("rm startup")
  1193.     shell.run("pastebin get xcpS4Kz5 startup")
  1194.     os.reboot()
  1195. end
  1196.  
  1197. if fs.exists("shipdata.txt") then
  1198.     ReadData()
  1199. else
  1200.     SData = {
  1201.     Summon = false,
  1202.     Distance = 1,
  1203.     Direction = 0,
  1204.     Shipname = "",
  1205.     CurrentCore = ""
  1206.     }
  1207. end
  1208.  
  1209. SetColorDeflt()
  1210. warps = {}
  1211.  
  1212. function FindWarps()
  1213.     peripherals = peripheral.getNames()
  1214.     for i = 1,#peripherals do
  1215.         if peripheral.getType(peripherals[i]) == "warpdriveShipController" then
  1216.             table.insert(warps,{ID = peripherals[i],core = peripheral.wrap(peripherals[i])})
  1217.             if (SData["CurrentCore"]~="" and SData["CurrentCore"]==peripherals[i]) then
  1218.                 warp = warps[#warps]["core"]
  1219.                 curCoreIndex = #warps
  1220.             end
  1221.             warps[#warps]["core"].mode(0)
  1222.         end
  1223.     end
  1224. end
  1225.  
  1226. FindWarps()
  1227. GUIOptions = {}
  1228.  
  1229. if peripheral.getType("right") == "openperipheral_bridge" then
  1230.     GUIOptions.Bridge = true
  1231.     BRIDGE = peripheral.wrap("right")
  1232. else
  1233.     GUIOptions.Bridge = false
  1234. end
  1235.  
  1236. if #warps <1 then
  1237.     ShowWarning("No warpcore controllers detected")
  1238.     sleep(1)
  1239.     os.reboot()
  1240. end
  1241.  
  1242. if warp == nil then
  1243.     SData["CurrentCore"] = warps[1]["ID"]
  1244.     warp=warps[1]["core"]
  1245.     curCoreIndex=1
  1246. end
  1247.  
  1248. if SData.Shipname == "" then
  1249.     SetShipName()
  1250. end
  1251.  
  1252. Title = "<Jump-S "..version.." \""..SData.Shipname.."\">"
  1253.  
  1254. if SData.Summon then
  1255.     warp.summon_all()
  1256. end
  1257.  
  1258. GetCoreInfo()
  1259. CalcRealDistance()
  1260.  
  1261. PowerOnAllCores()
  1262.  
  1263. mainloop = true
  1264. doLoop = true
  1265. function Main()
  1266.     while(mainloop) do
  1267.         Clear()
  1268.         ShowInfo()
  1269.         term.setCursorPos(1, 15)
  1270.         SetColorTitle()
  1271.         ShowMenu("D - Dimensions, M - Toggle summon, N - Ship name")
  1272.         ShowMenu("S - Set Warp Data, J - Jump, G - to JumpGate")
  1273.         ShowMenu("B - to Beacon, H - to Hyperspace, C - Summon")
  1274.         ShowMenu("X - Shutdown, R - Restart, U - Update") --Z - Power cores, A - Disable cores
  1275.         if #warps>1 then
  1276.             ShowMenu("            <- Choose warpcore ->")
  1277.         end
  1278.         SetColorDeflt()
  1279.         while not(doLoop) do
  1280.             os.queueEvent("randomEvent")
  1281.             os.pullEvent()      
  1282.             sleep(.1)
  1283.         end
  1284.         sleep(.1)
  1285.     end
  1286. end
  1287.  
  1288. function EventListener()
  1289.     while mainloop do
  1290.         local event, keycode = os.pullEvent("key")
  1291.         doLoop = false
  1292.         sleep(.2)
  1293.         if keycode == 31 then
  1294.             SetDirection()
  1295.             SetDistance()
  1296.             SaveData()
  1297.         elseif keycode == 50 then
  1298.             if SData.Summon then
  1299.                 SData.Summon = false
  1300.             else
  1301.                 SData.Summon = true
  1302.             end
  1303.             SaveData()
  1304.         elseif keycode == 32 then
  1305.             SetDimensions()
  1306.             SaveData()
  1307.         elseif keycode == 36 then
  1308.             rs.setOutput(Alarm, true)
  1309.             if Confirm() then
  1310.                 Warp()
  1311.             end
  1312.             rs.setOutput(Alarm, false)
  1313.         elseif keycode == 46 then
  1314.             Summon()
  1315.         elseif keycode == 48 then
  1316.             JumpToBeacon()
  1317.         elseif #warps>1 and (keycode == 203 or keycode == 205) then -- Left or right with warps count > 1
  1318.             if keycode == 203 then
  1319.                 if curCoreIndex==1 then
  1320.                     curCoreIndex = #warps
  1321.                 else
  1322.                     curCoreIndex = curCoreIndex-1
  1323.                 end
  1324.             elseif keycode == 205 then -- Right
  1325.                 if curCoreIndex==#warps then
  1326.                     curCoreIndex = 1
  1327.                 else
  1328.                     curCoreIndex = curCoreIndex+1
  1329.                 end
  1330.             end
  1331.             warp = warps[curCoreIndex]["core"]
  1332.             SData["CurrentCore"] = warps[curCoreIndex]["ID"]
  1333.             SaveData()
  1334.             GetCoreInfo()
  1335.         elseif keycode == 17 then -- w
  1336.             ChooseWarpCore()
  1337.         elseif keycode == 44 then -- z
  1338.             PowerOnAllCores()
  1339.         elseif keycode == 30 then -- a
  1340.             PowerOffAllCores()
  1341.         elseif keycode == 22 then -- u
  1342.             UpdateSoftware()
  1343.         elseif keycode == 19 then -- r
  1344.             os.reboot()
  1345.         elseif keycode == 34 then
  1346.             JumpToGate()
  1347.         elseif keycode == 35 then
  1348.             rs.setOutput(Alarm, true)
  1349.             if Confirm() then
  1350.                 rs.setOutput(Alarm, false)
  1351.                 warp.mode(5)
  1352.                 warp.do_jump()
  1353.             end
  1354.             rs.setOutput(Alarm, false)
  1355.         elseif keycode == 45 then
  1356.             mainloop = false
  1357.             GracefulExit()
  1358.         elseif keycode == 49 then
  1359.             SetShipName()
  1360.         end
  1361.         doLoop = true
  1362.     end
  1363. end
  1364.  
  1365. function GracefulExit()
  1366.     if SData.Summon then
  1367.         SData.Summon = false
  1368.         SaveData()
  1369.     end
  1370.     Clear()
  1371.     print("Wish you good")
  1372.     for i = 1,#warps do
  1373.         warps[i]["core"].mode(0)
  1374.     end
  1375.     sleep(.5)
  1376.     error()
  1377. end
  1378.  
  1379. JumpedOnCoords = false
  1380. JumpingOnCoords()
  1381.  
  1382. StartAll = false
  1383. DoMultiJump()
  1384.  
  1385. if GUIOptions.Bridge == false and StartAll == true then
  1386.     parallel.waitForAny(EventListener, Main)
  1387. elseif GUIOptions.Bridge == true and StartAll == true then
  1388.     parallel.waitForAny(EventListener, Main, GUIDraw, Glasses)
  1389. end
Advertisement
Add Comment
Please, Sign In to add comment