Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- version = "1.9.0 Rewrite"
- Alarm = "top"
- Style = {
- CDeflt = colors.white,
- BGDeflt = colors.gray,
- CTitle = colors.black,
- BGTitle = colors.lightGray,
- CWarn = colors.white,
- BGWarn = colors.red
- }
- function SetColorDeflt()
- term.setBackgroundColor(Style.BGDeflt)
- term.setTextColor(Style.CDeflt)
- end
- function SetColorTitle()
- term.setBackgroundColor(Style.BGTitle)
- term.setTextColor(Style.CTitle)
- end
- function SetColorWarn()
- term.setBackgroundColor(Style.BGWarn)
- term.setTextColor(Style.CWarn)
- end
- function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- SetColorDeflt()
- Clear()
- print("Loading...")
- function Show(Text)
- term.write(Text)
- local xt,yt = term.getCursorPos()
- term.setCursorPos(1, yt+1)
- end
- function ShowTitle(Text)
- SetColorTitle()
- local w, h = term.getSize()
- local posX = math.floor((w-string.len(Text))/2)
- if posX<0 then
- posX=0
- end
- term.setCursorPos(posX,1)
- Show(Text)
- SetColorDeflt()
- end
- function ShowMenu(Text)
- term.write(Text)
- local xt, yt = term.getCursorPos()
- for i = xt, 51 do
- term.write(" ")
- end
- term.setCursorPos(1, yt+1)
- end
- function ShowWarning(Text)
- SetColorWarn()
- term.setCursorPos(10, 19)
- term.write(" "..Text.." ")
- SetColorDeflt()
- end
- function SaveData()
- local file = fs.open("shipdata.txt", "w")
- file.writeLine(textutils.serialize(SData))
- file.close()
- end
- function ReadData()
- local file = fs.open("shipdata.txt", "r")
- SData = textutils.unserialize(file.readAll())
- file.close()
- end
- function SaveGUIOptions()
- local GUIFile = fs.open("GUIOptions.txt", "w")
- GUIFile.writeLine(textutils.serialize(GUIOptions))
- GUIFile.close()
- end
- function LoadGUIOptions()
- local GUIFile = fs.open("GUIOptions.txt", "r")
- GUIOptions = textutils.unserialize(GUIFile.readAll())
- GUIFile.close()
- end
- function TextDirection()
- if SData.Direction == 0 then
- return "Front"
- elseif SData.Direction == 180 then
- return "Back"
- elseif SData.Direction == 1 then
- return "Up"
- elseif SData.Direction == 2 then
- return "Down"
- elseif SData.Direction == 90 then
- return "Left"
- elseif SData.Direction == 255 then
- return "Right"
- else
- return "Unknown"
- end
- end
- function AddTextAnim(x, y, k, t, text, add)
- if add == true then
- if not (k > t) then
- AddText(x, y, text)
- end
- else
- if not (k < t) then
- AddText(x, y, text)
- end
- end
- end
- function AnimationSmallToBig()
- local speed = 3
- local x = speed
- while x < 148 do
- sleep(.00005)
- BRIDGE.clear()
- InfoBox = BRIDGE.addBox(730, 180, 230, 54 + x, 0xff3300, 0.3)
- InfoBoxLeft = BRIDGE.addBox(730, 182, 2, 50 + x, 0x000000, 0.5)
- InfoBoxRight = BRIDGE.addBox(958, 182 ,2, 50 + x, 0x000000, 0.5)
- InfoBoxTop = BRIDGE.addBox(730, 180, 230, 2, 0x000000, 0.5)
- InfoBoxBottom = BRIDGE.addBox(730, 232 + x, 230, 2, 0x000000, 0.5)
- x = x + speed
- AddTextAnim(734, 184, x, 13, "<=========== Big Help ===========>", false)
- AddTextAnim(734, 194, x, 13, "$$jump [Direction] [Distance] [Quantity] -")
- AddTextAnim(734, 204, x, 13, "warps few times. If quantity wasn't set -")
- AddTextAnim(734, 214, x, 13, "jumps once. <$$jump up 58 3>")
- AddTextAnim(734, 224, x, 13, "$$setDim [Front] [Right] [Up] [Back] [Left]")
- AddTextAnim(734, 234, x, 13, "[Down] - sets dimensions of the ship.")
- AddTextAnim(734, 244, x, 23, "<$$setDim 4 5 6 1 2 3>")
- AddTextAnim(734, 254, x, 33, "$$summon [#] - summons a player with")
- AddTextAnim(734, 264, x, 43, "number #. You can see your number in")
- AddTextAnim(734, 274, x, 53, "computer when press <C>. To summon all - ")
- AddTextAnim(734, 284, x, 63, "don't write the number.")
- AddTextAnim(734, 294, x, 73, "<$$summon 4>")
- AddTextAnim(734, 304, x, 83, "$$hyper - jumps into hyperspace. Only works")
- AddTextAnim(734, 314, x, 93, "if you are in space.")
- AddTextAnim(734, 324, x, 103, "<$$hyper>")
- AddTextAnim(734, 334, x, 113, "$$GUI info - hides/shows info. about your")
- AddTextAnim(734, 344, x, 123, "ship.")
- AddTextAnim(734, 354, x, 133, "$$GUI help - hides/shows help info.")
- AddTextAnim(734, 224, x, 143, "$$GUI bigHelp - shows more help info.")
- if GUIOptions.HideInfo == false then
- local energy = warp.energy()
- local dest = CalcNewCoords(X, Y, Z)
- local players = Explode(",", warp.getAttachedPlayers())
- AddText(2, 29, "Energy = "..energy.."EU")
- AddText(2, 39, "x, y, z = "..X..", "..Y..", "..Z)
- AddText(2, 49, "Direction = "..TextDirection(), 0x000000)
- AddText(2, 59, "Distance = "..RealDistance.." ("..JumpCost.."EU, "..math.floor(energy/JumpCost).." jumps)")
- AddText(2, 69, "Dest.coordinates = "..dest.x..", "..dest.y..", "..dest.z)
- if GUIOptions.HidePlayers == false then
- for i = 1, #players do
- AddText(2, 69 + i * 10, i..". "..players[i])
- end
- end
- end
- BRIDGE.sync()
- end
- GUIOptions.SmallToBig = false
- end
- function AnimationBigToSmall()
- local speed = 3
- local x = speed
- while x < 148 do
- sleep(.00005)
- BRIDGE.clear()
- InfoBox = BRIDGE.addBox(730, 180, 230, 204 - x, 0xff3300, 0.3)
- InfoBoxLeft = BRIDGE.addBox(730, 182, 2, 200 - x, 0x000000, 0.5)
- InfoBoxRight = BRIDGE.addBox(958, 182 ,2, 200 - x, 0x000000, 0.5)
- InfoBoxTop = BRIDGE.addBox(730, 180, 230, 2, 0x000000, 0.5)
- InfoBoxBottom = BRIDGE.addBox(730, 382 - x, 230, 2, 0x000000, 0.5)
- x = x + speed
- AddTextAnim(734, 184, x, 147, "<=========== Small Help ===========>", true)
- AddTextAnim(734, 194, x, 147, "$$jump [Direction] [Distance] [Quantity]", true)
- AddTextAnim(734, 204, x, 147, "$$update - updates software", true)
- AddTextAnim(734, 214, x, 147, "$$GUI help - hides/shows help info.", true)
- AddTextAnim(734, 224, x, 147, "$$GUI bigHelp - shows more help info.", true)
- AddTextAnim(734, 234, x, 143, "[Down] - sets dimensions of the ship.", true)
- AddTextAnim(734, 244, x, 133, "<$$setDim 4 5 6 1 2 3>", true)
- AddTextAnim(734, 254, x, 123, "$$summon [#] - summons a player with", true)
- AddTextAnim(734, 264, x, 113, "number #. You can see your number in", true)
- AddTextAnim(734, 274, x, 103, "computer when press <C>. To summon all - ", true)
- AddTextAnim(734, 284, x, 93, "don't write the number.", true)
- AddTextAnim(734, 294, x, 83, "<$$summon 4>", true)
- AddTextAnim(734, 304, x, 73, "$$hyper - jumps into hyperspace. Only works", true)
- AddTextAnim(734, 314, x, 63, "if you are in space.", true)
- AddTextAnim(734, 324, x, 53, "<$$hyper>", true)
- AddTextAnim(734, 334, x, 43, "$$GUI info - hides/shows info. about your", true)
- AddTextAnim(734, 344, x, 33, "ship.", true)
- AddTextAnim(734, 354, x, 23, "$$GUI help - hides/shows help info.", true)
- AddTextAnim(734, 224, x, 13, "$$GUI bigHelp - shows more help info.", true)
- if GUIOptions.HideInfo == false then
- local energy = warp.energy()
- local dest = CalcNewCoords(X, Y, Z)
- local players = Explode(",", warp.getAttachedPlayers())
- AddText(2, 29, "Energy = "..energy.."EU")
- AddText(2, 39, "x, y, z = "..X..", "..Y..", "..Z)
- AddText(2, 49, "Direction = "..TextDirection(), 0x000000)
- AddText(2, 59, "Distance = "..RealDistance.." ("..JumpCost.."EU, "..math.floor(energy/JumpCost).." jumps)")
- AddText(2, 69, "Dest.coordinates = "..dest.x..", "..dest.y..", "..dest.z)
- if GUIOptions.HidePlayers == false then
- for i = 1, #players do
- AddText(2, 69 + i * 10, i..". "..players[i])
- end
- end
- end
- BRIDGE.sync()
- end
- GUIOptions.BigToSmall = false
- end
- function AddText(x, y, text, color)
- x = type(x) == "number" and x or 0
- y = type(y) == "number" and y or 0
- AddedTextBlack = BRIDGE.addText(x + 1, y + 1, text, 0x000000)
- AddedText = BRIDGE.addText(x, y, text, 0xffffff)
- end
- function GUIDraw()
- if fs.exists("GUIOptions.txt") then
- LoadGUIOptions()
- newDistance = {}
- MultiJump = {}
- else
- GUIOptions.Update = true
- GUIOptions.BigHelp = false
- GUIOptions.SmallHelp = true
- GUIOptions.HideInfo = false
- GUIOptions.Help = true
- GUIOptions.BigToSmall = false
- GUIOptions.SmallToBig = false
- GUIOptions.HidePlayers = false
- SaveGUIOptions()
- newDistance = {}
- MultiJump = {}
- end
- while GUIOptions.Update == true do
- sleep(.1)
- BRIDGE.clear()
- if GUIOptions.SmallHelp == true and GUIOptions.Help == true then
- InfoBox = BRIDGE.addBox(730, 180, 230, 54, 0xff3300, 0.3)
- InfoBoxLeft = BRIDGE.addBox(730, 182, 2, 50, 0x000000, 0.5)
- InfoBoxRight = BRIDGE.addBox(958, 182 ,2, 50, 0x000000, 0.5)
- InfoBoxTop = BRIDGE.addBox(730, 180, 230, 2, 0x000000, 0.5)
- InfoBoxBottom = BRIDGE.addBox(730, 232, 230, 2, 0x000000, 0.5)
- AddText(734, 184, "<=========== Small Help ===========>")
- AddText(734, 194, "$$jump [Direction] [Distance] [Quantity]")
- AddText(734, 204, "$$update - updates software")
- AddText(734, 214, "$$GUI help - hides/shows help info.")
- AddText(734, 224, "$$GUI bigHelp - shows more help info.")
- end
- if GUIOptions.SmallToBig == true then
- GUIOptions.Update = false
- GUIOptions.SmallHelp = false
- AnimationSmallToBig()
- GUIOptions.BigHelp = true
- GUIOptions.Update = true
- SaveGUIOptions()
- end
- if GUIOptions.BigHelp == true and GUIOptions.Help == true then
- InfoBox = BRIDGE.addBox(730, 180, 230, 204, 0xff3300, 0.3)
- InfoBoxLeft = BRIDGE.addBox(730, 182, 2, 200, 0x000000, 0.5)
- InfoBoxRight = BRIDGE.addBox(958, 182 ,2, 200, 0x000000, 0.5)
- InfoBoxTop = BRIDGE.addBox(730, 180, 230, 2, 0x000000, 0.5)
- InfoBoxBottom = BRIDGE.addBox(730, 382, 230, 2, 0x000000, 0.5)
- AddText(734, 184, "<=========== Big Help ===========>")
- AddText(734, 194, "$$jump [Direction] [Distance] [Quantity] -")
- AddText(734, 204, "warps few times. If quantity wasn't set -")
- AddText(734, 214, "jumps once. <$$jump up 58 3>")
- AddText(734, 224, "$$setDim [Front] [Right] [Up] [Back] [Left]")
- AddText(734, 234, "[Down] - sets dimensions of the ship.")
- AddText(734, 244, "<$$setDim 4 5 6 1 2 3>")
- AddText(734, 254, "$$summon [#] - summons a player with")
- AddText(734, 264, "number #. You can see your number in")
- AddText(734, 274, "computer when press <C>. To summon all - ")
- AddText(734, 284, "don't write the number.")
- AddText(734, 294, "<$$summon 4>")
- AddText(734, 304, "$$hyper - jumps into hyperspace. Only works")
- AddText(734, 314, "if you are in space.")
- AddText(734, 324, "<$$hyper>")
- AddText(734, 334, "$$GUI info - hides/shows info. about your")
- AddText(734, 344, "ship.")
- AddText(734, 354, "$$GUI help - hides/shows help info.")
- AddText(734, 364, "$$GUI smallHelp - shows less help info.")
- AddText(734, 374, "Version - "..version)
- end
- if GUIOptions.BigToSmall == true then
- GUIOptions.Update = false
- GUIOptions.BigHelp = false
- AnimationBigToSmall()
- GUIOptions.SmallHelp = true
- GUIOptions.Update = true
- SaveGUIOptions()
- end
- if GUIOptions.HideInfo == false then
- local energy = warp.energy()
- local dest = CalcNewCoords(X, Y, Z)
- local players = Explode(",", warp.getAttachedPlayers())
- AddText(2, 29, "Energy = "..energy.."EU")
- AddText(2, 39, "x, y, z = "..X..", "..Y..", "..Z)
- AddText(2, 49, "Direction = "..TextDirection(), 0x000000)
- AddText(2, 59, "Distance = "..RealDistance.." ("..JumpCost.."EU, "..math.floor(energy/JumpCost).." jumps)")
- AddText(2, 69, "Dest.coordinates = "..dest.x..", "..dest.y..", "..dest.z)
- if GUIOptions.HidePlayers == false then
- for i = 1, #players do
- AddText(2, 69 + i * 10, i..". "..players[i])
- maxTextY = 69 + i * 10
- end
- end
- end
- BRIDGE.sync()
- end
- end
- function SaveJumpOnCoords()
- local JOC = fs.open("JumpOnCoords.txt", "w")
- JOC.writeLine(textutils.serialize(MultiJump))
- JOC.close()
- end
- function LoadJumpOnCoords()
- local JOC = fs.open("JumpOnCoords.txt", "r")
- MultiJump = textutils.unserialize(JOC.readAll())
- JOC.close()
- end
- function Glasses()
- while true do
- command = {}
- event, side, nick, uuid, message = os.pullEvent()
- if event == "glasses_chat_command" then
- for message in string.gmatch(message, "%S+") do
- command[#command+1] = message
- end
- print(message)
- if command[1] == "setDim" then
- GFront = tonumber(command[2])
- GRight = tonumber(command[3])
- GUp = tonumber(command[4])
- GBack = tonumber(command[5])
- GLeft = tonumber(command[6])
- GDown = tonumber(command[7])
- warp.dim_setp(GFront, GRight, GUp)
- warp.dim_setn(GBack, GLeft, GDown)
- SaveData()
- elseif command[1] == "jump" then
- if command[2] == "forward" or command[2] == "front" then
- SData.Direction = 0
- elseif command[2] == "up" then
- SData.Direction = 1
- elseif command[2] == "left" then
- SData.Direction = 90
- elseif command[2] == "right" then
- SData.Direction = 255
- elseif command[2] == "back" then
- SData.Direction = 180
- elseif command[2] == "down" then
- SData.Direction = 2
- end
- SData.Distance = 0
- CalcRealDistance()
- MaximumDistance = MinimumDistance + 127
- SData.Distance = tonumber(command[3])
- if SData.Distance == nil then
- SData.Distance = 1
- end
- if SData.Distance < MinimumDistance or SData.Distance > MaximumDistance then
- SData.Distance = 1
- CalcRealDistance()
- else
- if not IsInHyper then
- SData.Distance = SData.Distance - RealDistance
- end
- warp.set_distance(SData.Distance)
- CalcRealDistance()
- end
- SaveData()
- if command[4] == nil or command[4] == 1 then
- CreateMultiJumpFile("0")
- else
- CreateMultiJumpFile(command[4] - 1)
- end
- Warp()
- elseif command[1] == "jumpOnCoords" then
- if command[2] ~= nil and command[4] ~= nil then
- local destCoordX, destCoordY, destCoordZ = tonumber(command[2]), tonumber(command[3]), tonumber(command[4])
- CalcNewCoords(warp.get_x(), warp.get_y(), warp.get_z())
- newCoords = {x = res.x, y = res.y, z = res.z}
- newDistance = {x = destCoordX - warp.get_x(), y = destCoordY - warp.get_y(), z = destCoordZ - warp.get_z()}
- MultiJump = {}
- if command[5] ~= nil then
- if command[5] == "hyper" then
- MultiJump.Hyper = true
- elseif command[5] == "space" then
- MultiJump.Space = true
- elseif command[5] == "earth" then
- MultiJump.Earth = true
- else
- MultiJump.NotGoInAnotherDim = true
- end
- else
- MultiJump.NotGoInAnotherDim = true
- end
- --searching sides
- SData.Direction = 0
- SData.Distance = 50
- CalcNewCoords(warp.get_x(), warp.get_y(), warp.get_z())
- if warp.get_x() > res.x then
- MultiJump.MinusX = 0
- MultiJump.PlusX = 180
- elseif warp.get_x() < res.x then
- MultiJump.MinusX = 180
- MultiJump.PlusX = 0
- elseif warp.get_z() > res.z then
- MultiJump.MinusZ = 0
- MultiJump.PlusZ = 180
- elseif warp.get_z() < res.z then
- MultiJump.MinusZ = 180
- MultiJump.PlusZ = 0
- end
- if MultiJump.MinusX == 0 and MultiJump.PlusX == 180 then
- MultiJump.PlusZ = 90
- MultiJump.MinusZ = 255
- elseif MultiJump.MinusX == 180 and MultiJump.PlusX == 0 then
- MultiJump.PlusZ = 255
- MultiJump.MinusZ = 90
- elseif MultiJump.MinusZ == 0 and MultiJump.PlusZ == 180 then
- MultiJump.PlusX = 255
- MultiJump.MinusX = 90
- elseif MultiJump.MinusZ == 180 and MultiJump.PlusZ == 0 then
- MultiJump.PlusX = 90
- MultiJump.MinusX = 255
- end
- if newDistance.x < 0 then
- MultiJump.DirectionX = MultiJump.MinusX
- elseif newDistance.x > 0 then
- MultiJump.DirectionX = MultiJump.PlusX
- end
- SData.Direction = MultiJump.DirectionX
- SData.Distance = 0
- CalcRealDistance()
- MaximumDistanceX = MinimumDistance + 127
- if newDistance.y < 0 then
- MultiJump.DirectionY = 2
- elseif newDistance.y > 0 then
- MultiJump.DirectionY = 1
- end
- SData.Direction = MultiJump.DirectionY
- SData.Distance = 0
- CalcRealDistance()
- MaximumDistanceY = MinimumDistance + 127
- if newDistance.z < 0 then
- MultiJump.DirectionZ = MultiJump.MinusZ
- elseif newDistance.z > 0 then
- MultiJump.DirectionZ = MultiJump.PlusZ
- end
- SData.Direction = MultiJump.DirectionZ
- SData.Distance = 0
- CalcRealDistance()
- MaximumDistanceZ = MinimumDistance + 127
- --counting distance and quantity of jumps
- local d = math.abs(MaximumDistanceX)
- local q = 0
- MultiJump.Loop = true
- while MultiJump.Loop do
- if d < newDistance.x then
- q = q + 1
- d = d + MaximumDistanceX
- elseif d == newDistance.x then
- MultiJump.JumpX = q + 1
- MultiJump.AddJumpX = "none"
- MultiJump.Loop = false
- elseif d > newDistance.x then
- MultiJump.JumpX = q
- MultiJump.AddJumpX = newDistance.x - (d - MaximumDistanceX) - (MaximumDistanceX - 128)
- MultiJump.Loop = false
- end
- end
- --[[if newDistance.y ~= 0 then
- local d = MaximumDistanceY
- local q = 0
- MultiJump.Loop = true
- while MultiJump.Loop do
- if d < newDistance.y then
- q = q + 1
- d = d + MaximumDistanceY
- elseif d == newDistance.y then
- MultiJump.JumpY = q + 1
- MultiJump.AddJumpY = "none"
- MultiJump.Loop = false
- elseif d > newDistance.y then
- MultiJump.JumpY = q
- MultiJump.AddJumpY = newDistance.y - (d - MaximumDistanceY)
- MultiJump.Loop = false
- end
- end
- end--]]
- local d = math.abs(MaximumDistanceZ)
- local q = 0
- MultiJump.Loop = true
- while MultiJump.Loop do
- if d < newDistance.z then
- q = q + 1
- d = d + MaximumDistanceZ
- elseif d == newDistance.z then
- MultiJump.JumpZ = q + 1
- MultiJump.AddJumpZ = "none"
- MultiJump.Loop = false
- elseif d > newDistance.z then
- MultiJump.JumpZ = q
- MultiJump.AddJumpZ = newDistance.z - (d - MaximumDistanceZ) - (MaximumDistanceZ - 128)
- MultiJump.Loop = false
- end
- end
- SaveJumpOnCoords()
- sleep(5)
- os.reboot()
- end
- elseif command[1] == "summon" then
- if command[2] == nil then
- warp.summon_all()
- else
- warp.summon(command[2] - 1)
- end
- elseif command[1] == "hyper" then
- if IsInSpace or IsInHyper then
- warp.mode(5)
- warp.do_jump()
- end
- elseif command[1] == "update" then
- UpdateSoftware()
- os.reboot()
- elseif command[1] == "GUI" then
- if command[2] == "help" then
- if GUIOptions.Help == false then
- GUIOptions.Help = true
- else
- GUIOptions.Help = false
- end
- elseif command[2] == "bigHelp" and GUIOptions.Help == true then
- if GUIOptions.BigHelp == false then
- GUIOptions.SmallToBig = true
- end
- elseif command[2] == "smallHelp" and GUIOptions.Help == true then
- if GUIOptions.SmallHelp == false then
- GUIOptions.BigToSmall = true
- end
- elseif command[2] == "info" then
- if GUIOptions.HideInfo == false then
- GUIOptions.HideInfo = true
- else
- GUIOptions.HideInfo = false
- end
- elseif command[2] == "players" and GUIOptions.HideInfo == false then
- if GUIOptions.HidePlayers == false then
- GUIOptions.HidePlayers = true
- else
- GUIOptions.HidePlayers = false
- end
- end
- SaveGUIOptions()
- end
- SaveData()
- end
- end
- end
- function JumpingOnCoords()
- if fs.exists("JumpOnCoords.txt") then
- sleep(.1)
- SData.Distance = 0
- CalcRealDistance()
- MaximumDistance = MinimumDistance + 127
- LoadJumpOnCoords()
- if MultiJump.Jump ~= nil then
- if not IsInHyper then
- MaximumDistance = MaximumDistance - RealDistance
- end
- if MultiJump.JumpX > 0 then
- if MultiJump.Hyper == true then
- if warp.isInSpace() == true then
- warp.mode(5)
- warp.do_jump()
- sleep(10)
- elseif warp.isInSpace() == false and warp.isInHyperspace() == false then
- warp.set_direction(1)
- warp.set_distance(MaximumDistance)
- CalcRealDistance()
- warp.mode(1)
- warp.do_jump()
- sleep(10)
- else
- MultiJump.JumpX = MultiJump.JumpX - 1
- SaveJumpOnCoords()
- warp.set_direction(MultiJump.DirectionX)
- warp.set_distance(MaximumDistance)
- CalcRealDistance()
- warp.mode(2)
- warp.do_jump()
- sleep(10)
- end
- elseif MultiJump.Space == true then
- if warp.isInSpace() == false and warp.isInHyperspace() == false then
- warp.set_direction(1)
- warp.set_distance(MaximumDistance)
- CalcRealDistance()
- warp.mode(1)
- warp.do_jump()
- sleep(10)
- elseif warp.isInHyperspace() == true then
- warp.mode(5)
- warp.do_jump()
- sleep(10)
- else
- MultiJump.JumpX = MultiJump.JumpX - 1
- SaveJumpOnCoords()
- warp.set_direction(MultiJump.DirectionX)
- warp.set_distance(MaximumDistance)
- CalcRealDistance()
- warp.mode(1)
- warp.do_jump()
- sleep(10)
- end
- elseif MultiJump.Earth == true then
- if warp.isInSpace() == true then
- warp.set_direction(2)
- warp.set_distance(MaximumDistance)
- CalcRealDistance()
- warp.mode(1)
- warp.do_jump()
- sleep(10)
- elseif warp.isInHyperspace() == true then
- warp.mode(5)
- warp.do_jump()
- sleep(10)
- else
- MultiJump.JumpX = MultiJump.JumpX - 1
- SaveJumpOnCoords()
- warp.set_direction(MultiJump.DirectionX)
- warp.set_distance(MaximumDistance)
- CalcRealDistance()
- warp.mode(1)
- warp.do_jump()
- sleep(10)
- end
- elseif MultiJump.NotGoInAnotherDim == true then
- if warp.isInHyperspace() == true then
- MultiJump.JumpX = MultiJump.JumpX - 1
- SaveJumpOnCoords()
- warp.set_direction(MultiJump.DirectionX)
- warp.set_distance(MaximumDistance)
- CalcRealDistance()
- warp.mode(2)
- warp.do_jump()
- sleep(10)
- else
- MultiJump.JumpX = MultiJump.JumpX - 1
- SaveJumpOnCoords()
- warp.set_direction(MultiJump.DirectionX)
- warp.set_distance(MaximumDistance)
- CalcRealDistance()
- warp.mode(1)
- warp.do_jump()
- sleep(10)
- end
- end
- end
- end
- sleep(.1)
- if MultiJump.AddJumpX ~= "none" and MultiJump.AddJumpX ~= nil then
- if MultiJump.AddJumpX < 0 then
- warp.set_direction(MultiJump.DirectionX)
- warp.set_distance(-MultiJump.AddJumpX - 1) --KOSTYL
- CalcRealDistance()
- MultiJump.AddJumpX = "none"
- SaveJumpOnCoords()
- if warp.isInHyperspace() == true then
- warp.mode(2)
- warp.do_jump()
- sleep(10)
- else
- warp.mode(1)
- warp.do_jump()
- sleep(10)
- end
- elseif MultiJump.AddJumpX > 0 then
- warp.set_direction(MultiJump.DirectionX)
- warp.set_distance(MultiJump.AddJumpX + 1) --KOSTYL
- CalcRealDistance()
- MultiJump.AddJumpX = "none"
- SaveJumpOnCoords()
- if warp.isInHyperspace() == true then
- warp.mode(2)
- warp.do_jump()
- sleep(10)
- else
- warp.mode(1)
- warp.do_jump()
- sleep(10)
- end
- end
- end
- sleep(.1)
- if MultiJump.JumpZ ~= nil then
- if MultiJump.JumpZ > 0 then
- MultiJump.JumpZ = MultiJump.JumpZ - 1
- SaveJumpOnCoords()
- warp.set_direction(MultiJump.DirectionZ)
- warp.set_distance(MaximumDistance)
- CalcRealDistance()
- if warp.isInHyperspace() == true then
- warp.mode(2)
- warp.do_jump()
- sleep(10)
- else
- warp.mode(1)
- warp.do_jump()
- sleep(10)
- end
- end
- end
- sleep(.1)
- if MultiJump.AddJumpZ ~= "none" and MultiJump.AddJumpZ ~= nil then
- if MultiJump.AddJumpZ < 0 then
- warp.set_direction(MultiJump.DirectionZ)
- warp.set_distance(-MultiJump.AddJumpZ - 1) --KOSTYL
- CalcRealDistance()
- MultiJump.AddJumpZ = "none"
- SaveJumpOnCoords()
- if warp.isInHyperspace() == true then
- warp.mode(2)
- warp.do_jump()
- sleep(10)
- else
- warp.mode(1)
- warp.do_jump()
- sleep(10)
- end
- elseif MultiJump.AddJumpZ > 0 then
- warp.set_direction(MultiJump.DirectionZ)
- warp.set_distance(MultiJump.AddJumpZ + 1) --KOSTYL
- CalcRealDistance()
- MultiJump.AddJumpZ = "none"
- SaveJumpOnCoords()
- if warp.isInHyperspace() == true then
- warp.mode(2)
- warp.do_jump()
- sleep(10)
- else
- warp.mode(1)
- warp.do_jump()
- sleep(10)
- end
- end
- end
- sleep(.1)
- JumpedOnCoords = true
- end
- end
- function DoMultiJump()
- if fs.exists("multijump.txt") and JumpedOnCoords == false then
- sleep(.1)
- ReadData()
- local rj = fs.open("multijump.txt", "r")
- mjt = tonumber(rj.readAll())
- rj.close()
- if mjt > 1 or mjt == 1 then
- local w = fs.open("multijump.txt", "w")
- w.write(mjt - 1)
- w.close()
- Warp()
- else
- StartAll = true
- end
- else
- StartAll = true
- end
- end
- function CreateMultiJumpFile(j)
- local wj = fs.open("multijump.txt", "w")
- wj.write(tostring(j))
- wj.close()
- end
- function Explode(d, p)
- local t, ll
- t = {}
- ll = 0
- if(#p == 1) then return {p} end
- while true do
- l = string.find(p ,d, ll, true)
- if l ~= nil then
- table.insert(t, string.sub(p, ll, l-1))
- ll = l+1
- else
- table.insert(t, string.sub(p, ll))
- break
- end
- end
- return t
- end
- function ShowDirection()
- if SData.Direction == 1 then
- Show(" Direction = Up")
- elseif SData.Direction == 2 then
- Show(" Direction = Down")
- elseif SData.Direction == 0 then
- Show(" Direction = Front")
- elseif SData.Direction == 180 then
- Show(" Direction = Back")
- elseif SData.Direction == 90 then
- Show(" Direction = Left")
- elseif SData.Direction == 255 then
- Show(" Direction = Right")
- end
- end
- function CalcRealDistance()
- if IsInHyper then
- RealDistance = SData.Distance * 100
- MinimumDistance = 1
- JumpCost = (1000 * Weight) + (1000 * SData.Distance)
- else
- if SData.Direction == 1 or SData.Direction == 2 then
- MinimumDistance = GUp + GDown
- RealDistance = SData.Distance + MinimumDistance
- elseif SData.Direction == 0 or SData.Direction == 180 then
- MinimumDistance = GFront + GBack
- RealDistance = SData.Distance + MinimumDistance
- elseif SData.Direction == 90 or SData.Direction == 255 then
- MinimumDistance = GLeft + GRight
- RealDistance = SData.Distance + MinimumDistance
- end
- MinimumDistance = MinimumDistance + 1
- JumpCost = (10 * Weight) + (100 * SData.Distance)
- end
- end
- function CalcNewCoords(cx, cy, cz)
- res = {x=cx, y=cy, z=cz}
- -- if SData.Direction == 1 then
- -- res.y = res.y + RealDistance
- -- elseif SData.Direction == 2 then
- -- res.y = res.y - RealDistance
- -- end
- -- local dx = warp.get_dx()
- -- local dz = warp.get_dz()
- -- if dx ~= 0 then
- -- if SData.Direction == 0 then
- -- res.x = res.x + (RealDistance * dx)
- -- elseif SData.Direction == 180 then
- -- res.x = res.x - (RealDistance * dx)
- -- elseif SData.Direction == 90 then
- -- res.z = res.z + (RealDistance * dx)
- -- elseif SData.Direction == 255 then
- -- res.z = res.z - (RealDistance * dx)
- -- end
- -- else
- -- if SData.Direction == 0 then
- -- res.z = res.z + (RealDistance * dz)
- -- elseif SData.Direction == 180 then
- -- res.z = res.z - (RealDistance * dz)
- -- elseif SData.Direction == 90 then
- -- res.x = res.x + (RealDistance * dz)
- -- elseif SData.Direction == 255 then
- -- res.x = res.x - (RealDistance * dz)
- -- end
- -- end
- return res
- end
- function ShowInfo()
- ShowTitle(Title)
- Show("Core: "..SData["CurrentCore"])
- Show(" x, y, z = "..X..", "..Y..", "..Z)
- local energy = warp.energy()
- Show(" Energy = "..math.floor(energy / 1000000).." % ("..energy.."EU)")
- Show(" Attached players = "..warp.getAttachedPlayers())
- Show("Dimensions:")
- Show(" Front, Right, Up = "..GFront..", "..GRight..", "..GUp)
- Show(" Back, Left, Down = "..GBack..", "..GLeft..", "..GDown)
- Show(" Size = "..Weight.." blocks")
- Show("Warp data:")
- ShowDirection()
- local dest = CalcNewCoords(X, Y, Z)
- Show(" Distance = "..RealDistance.." ("..JumpCost.."EU, "..math.floor(energy/JumpCost).." jumps)")
- Show(" Dest.coordinates = "..dest.x..", "..dest.y..", "..dest.z)
- if SData.Summon then
- Show(" Summon after = Yes")
- else
- Show(" Summon after = No")
- end
- end
- function Confirm()
- ShowWarning("Are you sure? (y/n)")
- local event, keycode = os.pullEvent("key")
- if keycode == 21 then
- return true
- else
- return false
- end
- end
- function Warp()
- PowerOffAllCores()
- rs.setOutput(Alarm, false)
- sleep(.5)
- warp.set_direction(SData.Direction)
- if IsInHyper then
- warp.mode(2)
- else
- warp.mode(1)
- end
- warp.do_jump()
- end
- function SetDistance()
- Clear()
- ShowTitle("<==== Set distance ====>")
- SData.Distance = 0
- CalcRealDistance()
- MaximumDistance = MinimumDistance + 127
- if IsInHyper then
- term.write("Distance * 100 (min "..MinimumDistance..", max "..MaximumDistance.."): ")
- else
- term.write("Distance (min "..MinimumDistance..", max "..MaximumDistance.."): ")
- end
- sleep(.3)
- SData.Distance = tonumber(read())
- if SData.Distance == nil then
- SData.Distance = 1
- end
- if SData.Distance < MinimumDistance or SData.Distance > MaximumDistance then
- SData.Distance = 1
- ShowWarning("Wrong distance. Try again.")
- os.pullEvent("key")
- CalcRealDistance()
- else
- if not IsInHyper then
- SData.Distance = SData.Distance - RealDistance
- end
- warp.set_distance(SData.Distance)
- CalcRealDistance()
- end
- end
- function SetDirection()
- local drun = true
- while(drun) do
- Clear()
- ShowTitle("<==== Set direction ====>")
- ShowDirection()
- term.setCursorPos(1, 16)
- SetColorTitle()
- ShowMenu("Use directional keys")
- ShowMenu("W/S keys for Up/Down")
- ShowMenu("Enter - confirm")
- SetColorDeflt()
- local event, keycode = os.pullEvent("key")
- if keycode == 200 then
- SData.Direction = 0
- elseif keycode == 17 then
- SData.Direction = 1
- elseif keycode == 203 then
- SData.Direction = 90
- elseif keycode == 205 then
- SData.Direction = 255
- elseif keycode == 208 then
- SData.Direction = 180
- elseif keycode == 31 then
- SData.Direction = 2
- elseif keycode == 28 then
- drun = false
- end
- end
- end
- function SetDimensions()
- Clear()
- sleep(.3)
- ShowTitle("<== Set dimensions for "..SData["CurrentCore"].." ==>")
- term.write(" Front ("..GFront..") : ")
- GFront = tonumber(read())
- term.write(" Right ("..GRight..") : ")
- GRight = tonumber(read())
- term.write(" Up ("..GUp..") : ")
- GUp = tonumber(read())
- term.write(" Back ("..GBack..") : ")
- GBack = tonumber(read())
- term.write(" Left ("..GLeft..") : ")
- GLeft = tonumber(read())
- term.write(" Down ("..GDown..") : ")
- GDown = tonumber(read())
- term.write("Setting dimensions...")
- warp.dim_setp(GFront, GRight, GUp)
- warp.dim_setn(GBack, GLeft, GDown)
- end
- function ChooseWarpCore()
- Clear()
- sleep(.3)
- ShowTitle("<==== Select warpcore ====>")
- GetCoreInfo()
- Show("Current core: " .. warps[curCoreIndex]["ID"])
- Show(" x, y, z = "..X..", "..Y..", "..Z)
- local energy = warp.energy()
- Show(" Energy = "..math.floor(energy / 1000000).." % ("..energy.."EU)")
- Show(" Attached players = "..warp.getAttachedPlayers())
- Show("Dimensions:")
- Show(" Front, Right, Up = "..GFront..", "..GRight..", "..GUp)
- Show(" Back, Left, Down = "..GBack..", "..GLeft..", "..GDown)
- Show(" Size = "..Weight.." blocks")
- ShowMenu("Press <Left> or <Right> to switch core")
- ShowMenu("Press <Enter> to select core")
- local event, keycode = os.pullEvent("key")
- if keycode == 28 then
- return
- elseif keycode == 203 then -- Left
- if curCoreIndex==1 then
- curCoreIndex = #warps
- else
- curCoreIndex = curCoreIndex-1
- end
- elseif keycode == 205 then -- Right
- if curCoreIndex==#warps then
- curCoreIndex = 1
- else
- curCoreIndex = curCoreIndex+1
- end
- end
- warp = warps[curCoreIndex]["core"]
- SData["CurrentCore"] = warps[curCoreIndex]["ID"]
- ChooseWarpCore()
- end
- function Summon()
- Clear()
- ShowTitle("<==== Summon players ====>")
- local players = Explode(",", warp.getAttachedPlayers())
- for i = 1, #players do
- Show(i..". "..players[i])
- end
- SetColorTitle()
- ShowMenu("Enter player number")
- ShowMenu("or press enter to summon everyone")
- SetColorDeflt()
- sleep(.3)
- term.write(":")
- local input = read()
- if input == "" then
- warp.summon_all()
- else
- input = tonumber(input)
- warp.summon(input - 1)
- end
- end
- function JumpToBeacon()
- Clear()
- ShowTitle("<==== Jump to beacon ====>")
- sleep(.3)
- term.write("Enter beacon frequency: ")
- local freq = tostring(read())
- rs.setOutput(Alarm, true)
- if Confirm() then
- rs.setOutput(Alarm, false)
- warp.mode(4)
- warp.set_beacon_frequency(freq)
- warp.do_jump()
- end
- rs.setOutput(Alarm, false)
- end
- function JumpToGate()
- Clear()
- ShowTitle("<==== Jump to JumpGate ====>")
- sleep(.3)
- term.write("Enter jumpgate name: ")
- local name = tostring(read())
- rs.setOutput(Alarm, true)
- if Confirm() then
- rs.setOutput(Alarm, false)
- warp.mode(6)
- warp.set_target_jumpgate(name)
- warp.do_jump()
- end
- rs.setOutput(Alarm, false)
- end
- function SetShipName()
- Clear()
- ShowTitle("<==== Set ship name ====>")
- sleep(.3)
- term.write("Enter ship name: ")
- SData.Shipname = tostring(read())
- os.setComputerLabel(SData.Shipname)
- warp.shipName(SData.Shipname)
- SaveData()
- -- os.reboot()
- end
- function PowerOffAllCores()
- for i = 1,#warps do
- warps[i]["core"].mode(0)
- end
- end
- function PowerOnAllCores()
- for i = 1,#warps do
- warps[i]["core"].mode(1)
- end
- end
- function GetCoreInfo()
- GFront, GRight, GUp = warp.dim_positive()
- GBack, GLeft, GDown = warp.dim_negative()
- IsInHyper = warp.isInHyperspace()
- IsInSpace = warp.isInSpace()
- X, Y, Z = warp.position()
- Weight = warp.getShipSize()
- end
- function UpdateSoftware()
- shell.run("rm startup")
- shell.run("pastebin get xcpS4Kz5 startup")
- os.reboot()
- end
- if fs.exists("shipdata.txt") then
- ReadData()
- else
- SData = {
- Summon = false,
- Distance = 1,
- Direction = 0,
- Shipname = "",
- CurrentCore = ""
- }
- end
- SetColorDeflt()
- warps = {}
- function FindWarps()
- peripherals = peripheral.getNames()
- for i = 1,#peripherals do
- if peripheral.getType(peripherals[i]) == "warpdriveShipController" then
- table.insert(warps,{ID = peripherals[i],core = peripheral.wrap(peripherals[i])})
- if (SData["CurrentCore"]~="" and SData["CurrentCore"]==peripherals[i]) then
- warp = warps[#warps]["core"]
- curCoreIndex = #warps
- end
- warps[#warps]["core"].mode(0)
- end
- end
- end
- FindWarps()
- GUIOptions = {}
- if peripheral.getType("right") == "openperipheral_bridge" then
- GUIOptions.Bridge = true
- BRIDGE = peripheral.wrap("right")
- else
- GUIOptions.Bridge = false
- end
- if #warps <1 then
- ShowWarning("No warpcore controllers detected")
- sleep(1)
- os.reboot()
- end
- if warp == nil then
- SData["CurrentCore"] = warps[1]["ID"]
- warp=warps[1]["core"]
- curCoreIndex=1
- end
- if SData.Shipname == "" then
- SetShipName()
- end
- Title = "<Jump-S "..version.." \""..SData.Shipname.."\">"
- if SData.Summon then
- warp.summon_all()
- end
- GetCoreInfo()
- CalcRealDistance()
- PowerOnAllCores()
- mainloop = true
- doLoop = true
- function Main()
- while(mainloop) do
- Clear()
- ShowInfo()
- term.setCursorPos(1, 15)
- SetColorTitle()
- ShowMenu("D - Dimensions, M - Toggle summon, N - Ship name")
- ShowMenu("S - Set Warp Data, J - Jump, G - to JumpGate")
- ShowMenu("B - to Beacon, H - to Hyperspace, C - Summon")
- ShowMenu("X - Shutdown, R - Restart, U - Update") --Z - Power cores, A - Disable cores
- if #warps>1 then
- ShowMenu(" <- Choose warpcore ->")
- end
- SetColorDeflt()
- while not(doLoop) do
- os.queueEvent("randomEvent")
- os.pullEvent()
- sleep(.1)
- end
- sleep(.1)
- end
- end
- function EventListener()
- while mainloop do
- local event, keycode = os.pullEvent("key")
- doLoop = false
- sleep(.2)
- if keycode == 31 then
- SetDirection()
- SetDistance()
- SaveData()
- elseif keycode == 50 then
- if SData.Summon then
- SData.Summon = false
- else
- SData.Summon = true
- end
- SaveData()
- elseif keycode == 32 then
- SetDimensions()
- SaveData()
- elseif keycode == 36 then
- rs.setOutput(Alarm, true)
- if Confirm() then
- Warp()
- end
- rs.setOutput(Alarm, false)
- elseif keycode == 46 then
- Summon()
- elseif keycode == 48 then
- JumpToBeacon()
- elseif #warps>1 and (keycode == 203 or keycode == 205) then -- Left or right with warps count > 1
- if keycode == 203 then
- if curCoreIndex==1 then
- curCoreIndex = #warps
- else
- curCoreIndex = curCoreIndex-1
- end
- elseif keycode == 205 then -- Right
- if curCoreIndex==#warps then
- curCoreIndex = 1
- else
- curCoreIndex = curCoreIndex+1
- end
- end
- warp = warps[curCoreIndex]["core"]
- SData["CurrentCore"] = warps[curCoreIndex]["ID"]
- SaveData()
- GetCoreInfo()
- elseif keycode == 17 then -- w
- ChooseWarpCore()
- elseif keycode == 44 then -- z
- PowerOnAllCores()
- elseif keycode == 30 then -- a
- PowerOffAllCores()
- elseif keycode == 22 then -- u
- UpdateSoftware()
- elseif keycode == 19 then -- r
- os.reboot()
- elseif keycode == 34 then
- JumpToGate()
- elseif keycode == 35 then
- rs.setOutput(Alarm, true)
- if Confirm() then
- rs.setOutput(Alarm, false)
- warp.mode(5)
- warp.do_jump()
- end
- rs.setOutput(Alarm, false)
- elseif keycode == 45 then
- mainloop = false
- GracefulExit()
- elseif keycode == 49 then
- SetShipName()
- end
- doLoop = true
- end
- end
- function GracefulExit()
- if SData.Summon then
- SData.Summon = false
- SaveData()
- end
- Clear()
- print("Wish you good")
- for i = 1,#warps do
- warps[i]["core"].mode(0)
- end
- sleep(.5)
- error()
- end
- JumpedOnCoords = false
- JumpingOnCoords()
- StartAll = false
- DoMultiJump()
- if GUIOptions.Bridge == false and StartAll == true then
- parallel.waitForAny(EventListener, Main)
- elseif GUIOptions.Bridge == true and StartAll == true then
- parallel.waitForAny(EventListener, Main, GUIDraw, Glasses)
- end
Advertisement
Add Comment
Please, Sign In to add comment