Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MON_SCALE = 0.5
- MIN_OFFSET = 2
- MAX_OFFSET = 250
- lazors = {}
- states = {}
- wcores = {}
- camers = {}
- heights = {}
- step = 12
- xOffset = 2
- yOffset = 4
- offset = MIN_OFFSET
- lasN = 0
- print("loading...")
- sleep(2)
- Alarm = "top"
- Style = {
- CDeflt = colors.white,
- BGDeflt = colors.blue,
- CTitle = colors.black,
- BGTitle = colors.cyan,
- CWarn = colors.white,
- BGWarn = colors.red
- }
- function setScreenPosition()
- backbutton_position = {x = screen_width/2, y = 1}
- start_all_position = {x = 1, y = screen_height-2}
- stop_all_position = {x = screen_width - 3, y = screen_height-2}
- lasermode_position = {x = math.floor(screen_width/2 - 2), y = screen_height-4}
- mining_position = {x=screen_width/2 - 2, y = screen_height/2-4}
- jumping_position = {x=screen_width/2 - 2, y = screen_height/2-2}
- GoJump_position = {x=screen_width/2 - 3, y = screen_height/2}
- JumpToCoord_position = {x=screen_width/2 - 3, y = screen_height/2+4}
- automine_position = {x=screen_width/2 - 3, y = screen_height/2+2}
- shipscan_position = {x=screen_width/2 - 3, y = screen_height/2+2}
- shipsc_position = {x=screen_width/2 - 2, y = screen_height/2-6}
- deployship_position = {x=screen_width/2 - 3, y = screen_height/2-4}
- deployship1_position = {x=2, y = screen_height/2-2}
- deployship2_position = {x=2, y = screen_height/2}
- deployship3_position = {x=2, y = screen_height/2+2}
- deployship4_position = {x=2, y = screen_height/2+4}
- radar_position = {x=screen_width/2 - 2, y = screen_height/2}
- radarscan_position = {x=2, y = screen_height-2}
- cloak_position = {x=5, y = screen_height/2+4}
- camera_position = {x=5, y = screen_height/2+6}
- title_position = {x=1, y = 1}
- textcenter_position = {x=1, y = screen_height/2}
- end
- function resetColorsScreen()
- screen.setBackgroundColor(colors.black)
- screen.setTextColor(colors.white)
- end
- function setlasermode()
- if lasermode == "mine" then
- lasermode = "quarry"
- print(lasermode)
- SData.lasermode = lasermode
- SaveData()
- else
- lasermode = "mine"
- print(lasermode)
- SData.lasermode = lasermode
- SaveData()
- end
- minestatistic()
- end
- function start(laserNUM)
- print("Calling laser "..lazors[laserNUM].." for start")
- setOffset(laserNUM, offset)
- m.callRemote(lazors[laserNUM], lasermode)
- end
- function startAll()
- for i =1 ,#lazors do
- start(i)
- end
- end
- function stop(laserNUM)
- print("Calling laser "..lazors[laserNUM].." for stop")
- m.callRemote(lazors[laserNUM], "stop")
- end
- function stopAll()
- for i = 1 ,#lazors do
- stop(i)
- end
- end
- function setOffset(laserNUM, offset)
- m.callRemote(lazors[laserNUM], "offset", offset)
- end
- function minestatistic()
- screen.clear()
- feelScreen(colors.black,colors.white)
- qml = 0
- lay = 0
- lux = 0
- min = 0
- screen.setCursorPos(1 , 3)
- screen.setBackgroundColor(colors.cyan)
- screen.write( "LASERS " .. #lazors)
- feelScreen(colors.black,colors.white)
- screen.setBackgroundColor(colors.blue)
- screen.setCursorPos(start_all_position.x ,start_all_position.y)
- if modemenu == "automine" then
- screen.write("AUTOMINE")
- else
- screen.write("GO")
- screen.setCursorPos(stop_all_position.x, stop_all_position.y)
- screen.write("xXx")
- end
- screen.setBackgroundColor(colors.green)
- screen.setCursorPos(lasermode_position.x, lasermode_position.y)
- screen.write(lasermode)
- feelScreen(colors.black,colors.white)
- screen.setBackgroundColor(colors.blue)
- screen.setCursorPos(backbutton_position.x, backbutton_position.y)
- screen.write("BACK")
- feelScreen(colors.black,colors.white)
- for a = 1,#lazors do
- mState, mEnergy, mLayer, mValuablesMined, mValuablesInLayer = m.callRemote(lazors[a], "state")
- print(mState)
- if mState ~= "not mining" then
- qml= qml+1
- lay = lay + mLayer
- lux = lux + mValuablesMined
- min = min + mValuablesInLayer
- if mEnergy == 0 then
- screen.setCursorPos(1 , 11)
- screen.setBackgroundColor(colors.red)
- screen.write( "low energy L" ..a)
- feelScreen(colors.black,colors.white)
- end
- end
- end
- screen.setCursorPos(1 , 5)
- screen.setBackgroundColor(colors.green)
- screen.write( "IN WORK " .. qml)
- feelScreen(colors.black,colors.white)
- print(qml)
- if qml > 0 then
- mLay = lay/qml
- mLux = lux/qml
- mmin = min*10/qml
- end
- screen.setCursorPos(1 , 7)
- screen.setBackgroundColor(colors.blue)
- screen.write( "LAYER " .. tostring(mLay))
- feelScreen(colors.black,colors.white)
- screen.setCursorPos(1 , 9)
- screen.setBackgroundColor(colors.blue)
- screen.write( "MINE " .. tostring(lux) .."/" .. tostring(mmin))
- feelScreen(colors.black,colors.white)
- sleep(1)
- end
- function mining()
- modemenu = "mine"
- SData.modemenu = "mine"
- SaveData()
- minestatistic()
- end
- function automine()
- modemenu = "automine"
- SData.modemenu = "automine"
- SData.lasermode = lasermode
- SaveData()
- minestatistic()
- if qml == 0 then
- stopAll()
- sleep(3)
- Warp()
- sleep(10)
- end
- sleep(0.5)
- return 0
- end
- function feelScreen(bcolor,tcolor)
- screen.setBackgroundColor(bcolor)
- screen.setTextColor(tcolor)
- end
- 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
- function Show(Text)
- term.write(Text)
- local xt,yt = term.getCursorPos()
- term.setCursorPos(1, yt+1)
- end
- function ShowTitle(Text)
- SetColorTitle()
- term.setCursorPos(12, 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 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
- return 0
- end
- function GetMinimumDistance()
- if IsInHyper then
- MinimumDistance = 1
- else
- if SData.Direction == 1 or SData.Direction == 2 then
- MinimumDistance = GUp + GDown
- elseif SData.Direction == 0 or SData.Direction == 180 then
- MinimumDistance = GFront + GBack
- elseif SData.Direction == 90 or SData.Direction == 255 then
- MinimumDistance = GLeft + GRight
- end
- MinimumDistance = MinimumDistance + 1
- end
- end
- function CalcRealDistance()
- GetMinimumDistance()
- if IsInHyper then
- RealDistance = SData.Distance * 100
- JumpCost = (1000 * Weight) + (1000 * SData.Distance)
- else
- RealDistance = SData.Distance + MinimumDistance
- JumpCost = (10 * Weight) + (100 * SData.Distance)
- end
- return 0
- end
- function CalcNewCoords(cx, cy, cz)
- local 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()
- Title = "<Jump-S 1.7.0 \""..SData.Shipname.."\">"
- ShowTitle(Title)
- if SData.MainCore == SData.CurrentCore then
- Show("Current core: " .. tostring(wcores[curCoreIndex]["ID"]) .. "M")
- else
- Show("Current core: " .. tostring(wcores[curCoreIndex]["ID"]) )
- end
- Show(" x, y, z = "..X..", "..Y..", "..Z)
- local energy = warp.get_energy_level()
- Show(" Energy = "..math.floor(energy / 1000000).." % ("..energy.."EU)")
- Show(" Attached players = "..warp.get_attached_players())
- 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
- Clear()
- end
- function Warp()
- rs.setOutput(Alarm, false)
- if multicore then
- for cr = 1, #wcores do
- warp = wcores[cr]["core"]
- SData.CurrentCore = wcores[cr]["ID"]
- SaveData()
- if SData.MainCore ~= SData.CurrentCore then
- warp.set_direction(SData.Direction)
- warp.set_distance(SData.Distance)
- if IsInHyper then
- warp.set_mode(2)
- else
- warp.set_mode(1)
- end
- -- sleep(5)
- warp.do_jump()
- sleep(2)
- end
- end
- warp = wcores[SData.MainCore]["core"]
- warp.set_direction(SData.Direction)
- warp.set_distance(SData.Distance)
- if IsInHyper then
- warp.set_mode(2)
- else
- warp.set_mode(1)
- end
- warp.do_jump()
- sleep(1)
- else
- warp.set_direction(SData.Direction)
- warp.set_distance(SData.Distance)
- if IsInHyper then
- warp.set_mode(2)
- else
- warp.set_mode(1)
- end
- warp.do_jump()
- end
- end
- function autojumpStatistic()
- screen.clear()
- feelScreen(colors.black,colors.white)
- screen.setBackgroundColor(colors.blue)
- screen.setCursorPos(backbutton_position.x, backbutton_position.y)
- screen.write("BACK")
- feelScreen(colors.black,colors.white)
- screen.setCursorPos(1 , 3)
- screen.setBackgroundColor(colors.blue)
- screen.write( "DestCoords")
- feelScreen(colors.black,colors.white)
- screen.setCursorPos(1 , 4)
- screen.setBackgroundColor(colors.green)
- screen.write( " x:" .. SData.DestCoordX .. " Z:" .. SData.DestCoordZ)
- feelScreen(colors.black,colors.white)
- screen.setCursorPos(1 , 6)
- screen.setBackgroundColor(colors.green)
- DX = math.abs(SData.DestCoordX - X)
- DZ = math.abs(SData.DestCoordZ - Z)
- screen.write( " DX:" .. DX)
- feelScreen(colors.black,colors.white)
- screen.setCursorPos(1 , 7)
- screen.setBackgroundColor(colors.green)
- screen.write( " DZ:" .. DZ)
- feelScreen(colors.black,colors.white)
- screen.setCursorPos(1 , 9)
- screen.setBackgroundColor(colors.red)
- screen.write( " ENERGY:" .. warp.get_energy_level())
- feelScreen(colors.black,colors.white)
- screen.setCursorPos(1 , 11)
- screen.setBackgroundColor(colors.magenta)
- screen.write( " Jumps:" ..math.floor(warp.get_energy_level()/JumpCost))
- feelScreen(colors.black,colors.white)
- end
- function SetCoord()
- modemenu = "jtc"
- SData.modemenu = "jtc"
- SaveData()
- screen.clear()
- screen.setCursorPos(1 , 7)
- screen.setBackgroundColor(colors.green)
- screen.write( "set coord" )
- screen.setCursorPos(1 , 8)
- screen.write( "on comp" )
- sleep(2)
- if SData.autojump == true then
- JumpToCoord()
- end
- Clear()
- ShowTitle("<==== Set DestCoords ====>")
- term.write(" X ("..tostring(SData.DestCoordX)..") : ")
- SData.DestCoordX = tonumber(read())
- term.write(" Z ("..tostring(SData.DestCoordZ)..") : ")
- SData.DestCoordZ = tonumber(read())
- SaveData()
- sleep(0.3)
- if Confirm() then
- JumpToCoord()
- end
- end
- function GoToSpace()
- autojumpStatistic()
- if warp.is_in_space() then
- SData.DestCoordY = 250
- SData.Direction = 1
- GetMinimumDistance()
- SaveData()
- DY = math.abs(SData.DestCoordY - Y)
- if DY > MinimumDistance then
- if SData.DestCoordY>Y then
- SData.Direction = 1
- elseif SData.DestCoordY<Y then
- SData.Direction = 0
- end
- Dist = DY
- GetMinimumDistance()
- MaxDist = MinimumDistance+127
- print(MaxDist .. " MaxDist")
- print(Dist .. " Dist")
- if Dist>MaxDist then
- SData.Distance = MaxDist
- else
- SData.Distance = Dist
- end
- SaveData()
- Warp()
- sleep(10)
- end
- elseif not IsInHyper then
- SData.Direction = 1
- GetMinimumDistance()
- MaxDist = MinimumDistance+127
- SData.Distance = MaxDist
- SaveData()
- Warp()
- sleep(10)
- end
- end
- function JumpInHyper()
- autojumpStatistic()
- if IsInHyper then
- print("in Hyperspace")
- DX = math.abs(SData.DestCoordX - X)
- print(DX .. " alldistX")
- DZ = math.abs(SData.DestCoordZ - Z)
- print(DZ .. " alldistZ")
- SData.Direction = 255
- GetMinimumDistance()
- if DX > 100 then
- if SData.DestCoordX>X then
- SData.Direction = 255
- elseif SData.DestCoordX<X then
- SData.Direction = 90
- end
- Dist = DX
- GetMinimumDistance()
- MaxDist = MinimumDistance+127
- print(MaxDist .. " MaxDist")
- print(Dist .. " Dist")
- if Dist>MaxDist*100 then
- SData.Distance = MaxDist
- else
- SData.Distance = math.floor(Dist/100)
- end
- SaveData()
- Warp()
- sleep(10)
- else
- SData.Direction = 180
- GetMinimumDistance()
- if DZ > 100 then
- if SData.DestCoordZ>Z then
- SData.Direction = 180
- elseif SData.DestCoordZ<Z then
- SData.Direction = 0
- end
- Dist = DZ
- GetMinimumDistance()
- MaxDist = MinimumDistance + 127
- print(MaxDist .. " MaxDist")
- print(Dist .. " Dist")
- if Dist>MaxDist*100 then
- SData.Distance = MaxDist
- else
- SData.Distance = math.floor(Dist/100)
- end
- SaveData()
- Warp()
- sleep(10)
- else
- rs.setOutput(Alarm, false)
- warp.set_mode(5)
- warp.do_jump()
- sleep (10)
- end
- end
- else
- print("go to Hyperspace")
- rs.setOutput(Alarm, false)
- warp.set_mode(5)
- warp.do_jump()
- sleep (10)
- end
- end
- function JumpToCoord()
- autojumpStatistic()
- SData.autojump = true
- SaveData()
- GoToSpace()
- print(SData.DestCoordX)
- DX = math.abs(SData.DestCoordX - X)
- DZ = math.abs(SData.DestCoordZ - Z)
- SData.Direction = 255
- GetMinimumDistance()
- MaxDist = MinimumDistance+127
- MAXDX =MaxDist*5
- if DX>MAXDX or DZ>MAXDX then
- print(MAXDX .. " to Hyperspace")
- JumpInHyper()
- else
- if IsInHyper then
- rs.setOutput(Alarm, false)
- warp.set_mode(5)
- warp.do_jump()
- end
- end
- if DX > MinimumDistance then
- if SData.DestCoordX>X then
- SData.Direction = 255
- elseif SData.DestCoordX<X then
- SData.Direction = 90
- end
- Dist = DX
- GetMinimumDistance()
- MaxDist = MinimumDistance+127
- if Dist>MaxDist then
- SData.Distance = MaxDist
- else
- SData.Distance = Dist
- end
- for i = 0,5 do
- print("autojump in " .. 5-i .. "sec.")
- sleep(1)
- i = i+1
- end
- SaveData()
- Warp()
- sleep(10)
- else
- SData.Direction = 180
- GetMinimumDistance()
- if DZ > MinimumDistance then
- if SData.DestCoordZ>Z then
- SData.Direction = 180
- elseif SData.DestCoordZ<Z then
- SData.Direction = 0
- end
- Dist = DZ
- GetMinimumDistance()
- MaxDist = MinimumDistance + 127
- if Dist>MaxDist then
- SData.Distance = MaxDist
- else
- SData.Distance = Dist
- end
- for i = 0,5 do
- print("autojump in " .. 5-i .. "sec.")
- sleep(1)
- i = i+1
- end
- SaveData()
- Warp()
- sleep(10)
- else
- SData.autojump = false
- SaveData()
- end
- end
- end
- function SetDistance()
- Clear()
- ShowTitle("<==== Set distance ====>")
- SData.Distance = 0
- GetMinimumDistance()
- 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(0.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
- return 0
- 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(0.3)
- ShowTitle("<==== Set dimensions ====>")
- 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)
- jumping()
- end
- function Summon()
- Clear()
- ShowTitle("<==== Summon players ====>")
- local players = Explode(",", warp.get_attached_players())
- for i = 1, #players do
- Show(i..". "..players[i])
- end
- SetColorTitle()
- ShowMenu("Enter player number")
- ShowMenu("or press enter to summon everyone")
- SetColorDeflt()
- sleep(0.3)
- term.write(":")
- local input = read()
- if input == "" then
- warp.summon_all()
- else
- input = tonumber(input)
- warp.summon(input - 1)
- end
- return 0
- end
- function JumpToBeacon()
- Clear()
- ShowTitle("<==== Jump to beacon ====>")
- sleep(0.3)
- term.write("Enter beacon frequency: ")
- local freq = tostring(read())
- rs.setOutput(Alarm, true)
- if Confirm() then
- rs.setOutput(Alarm, false)
- warp.set_mode(4)
- warp.set_beacon_frequency(freq)
- warp.do_jump()
- end
- rs.setOutput(Alarm, false)
- return 0
- end
- function JumpToGate()
- Clear()
- ShowTitle("<==== Jump to JumpGate ====>")
- sleep(0.3)
- term.write("Enter jumpgate name: ")
- local name = tostring(read())
- rs.setOutput(Alarm, true)
- if Confirm() then
- rs.setOutput(Alarm, false)
- warp.set_mode(6)
- warp.set_target_jumpgate(name)
- warp.do_jump()
- end
- rs.setOutput(Alarm, false)
- return 0
- end
- function SetShipName()
- Clear()
- sleep(0.3)
- ShowTitle("<==== Set ship name ====>")
- term.write("Enter ship name: ")
- SData.Shipname = tostring(read())
- os.setComputerLabel(SData.Shipname)
- warp.set_core_frequency(SData.Shipname)
- SaveData()
- jumping()
- end
- function statistic()
- GFront, GRight, GUp = warp.dim_getp()
- GBack, GLeft, GDown = warp.dim_getn()
- IsInHyper = warp.is_in_hyperspace()
- repeat
- X = warp.get_x()
- sleep(0.3)
- until X ~= nil
- Y = warp.get_y()
- Z = warp.get_z()
- Weight = warp.get_ship_size()
- CalcRealDistance()
- Clear()
- ShowInfo()
- term.setCursorPos(1, 15)
- SetColorTitle()
- ShowMenu("D - Dimensions, M - set MainCore, N - Ship name")
- ShowMenu("S - Set Warp Data, J - Jump, G - Jump to JumpGate")
- ShowMenu("B - Jump to Beacon, H -Jump to Hyperspace")
- ShowMenu("C - Summon, X - Shutdown WarpCore and Exit")
- ShowMenu("Press <Left> or <Right> to switch core")
- ShowMenu("Press <Enter> to select core")
- SetColorDeflt()
- sleep(0.3)
- return 0
- end
- function manctrl()
- statistic()
- local event, keycode = os.pullEvent("key")
- if keycode == 31 then
- SetDirection()
- SetDistance()
- SaveData()
- elseif keycode == 50 then
- SData.MainCore = SData.CurrentCore
- SaveData()
- statistic()
- elseif keycode == 32 then
- SetDimensions()
- SaveData()
- elseif multicore==true and (keycode == 203 or keycode == 205) then -- Left or right with wcores count > 1
- if keycode == 203 then
- if curCoreIndex==1 then
- curCoreIndex = #wcores
- else
- curCoreIndex = curCoreIndex-1
- end
- elseif keycode == 205 then -- Right
- if curCoreIndex==#wcores then
- curCoreIndex = 1
- else
- curCoreIndex = curCoreIndex+1
- end
- end
- warp = wcores[curCoreIndex]["core"]
- SData["CurrentCore"] = wcores[curCoreIndex]["ID"]
- SaveData()
- statistic()
- 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 keycode == 34 then
- JumpToGate()
- elseif keycode == 35 then
- rs.setOutput(Alarm, true)
- if Confirm() then
- rs.setOutput(Alarm, false)
- warp.set_mode(5)
- warp.do_jump()
- end
- rs.setOutput(Alarm, false)
- elseif keycode == 45 then
- warp.set_mode(0)
- Clear()
- print("wish you good")
- os.shutdown()
- elseif keycode == 49 then
- SetShipName()
- end
- end
- function jumping()
- screen.clear()
- feelScreen(colors.black,colors.white)
- screen.setBackgroundColor(colors.blue)
- screen.setCursorPos(backbutton_position.x, backbutton_position.y)
- screen.write("BACK")
- feelScreen(colors.black,colors.white)
- screen.setCursorPos(GoJump_position.x , GoJump_position.y)
- screen.setBackgroundColor(colors.cyan)
- screen.write("GO JUMP")
- feelScreen(colors.cyan,colors.white)
- screen.setCursorPos(JumpToCoord_position.x, JumpToCoord_position.y)
- screen.write("JUMP TO")
- if las then
- feelScreen(colors.black,colors.white)
- screen.setCursorPos(automine_position.x , automine_position.y)
- screen.setBackgroundColor(colors.cyan)
- screen.write("AUTOMINE")
- end
- feelScreen(colors.black,colors.white)
- modemenu = "jumping"
- SData.modemenu = "jumping"
- SaveData()
- statistic()
- sleep(0.3)
- return 0
- end
- function autosum()
- while summonloop do
- local event, command=os.pullEvent("chat_command")
- if (command=="sum1") then
- bridge.clear()
- bridge.addText(6,6,"summoning 1",0x777)
- warp.summon(0)
- bridge.clear()
- end
- if (command=="sum2") then
- bridge.clear()
- bridge.addText(6,6,"summoning 2",0x777)
- warp.summon(1)
- bridge.clear()
- end
- sleep(3)
- end
- jumping()
- end
- function shipscan()
- modemenu = "shipscan"
- SData.modemenu = "shipscan"
- SaveData()
- screen.clear()
- feelScreen(colors.black,colors.white)
- screen.setBackgroundColor(colors.blue)
- screen.setCursorPos(backbutton_position.x, backbutton_position.y)
- screen.write("BACK")
- feelScreen(colors.purple,colors.white)
- screen.setCursorPos(shipsc_position.x , shipsc_position.y)
- screen.write("SCAN")
- feelScreen(colors.black,colors.white)
- feelScreen(colors.purple,colors.white)
- screen.setCursorPos(deployship_position.x , deployship_position.y)
- screen.write("DEPLOY")
- feelScreen(colors.black,colors.white)
- feelScreen(colors.purple,colors.white)
- screen.setCursorPos(deployship1_position.x , deployship1_position.y)
- screen.write("1.MinePlat")
- feelScreen(colors.black,colors.white)
- feelScreen(colors.purple,colors.white)
- screen.setCursorPos(deployship2_position.x , deployship2_position.y)
- screen.write("2.PEKAFlower")
- feelScreen(colors.black,colors.white)
- feelScreen(colors.purple,colors.white)
- screen.setCursorPos(deployship3_position.x , deployship3_position.y)
- screen.write("3.TAXI")
- feelScreen(colors.black,colors.white)
- feelScreen(colors.purple,colors.white)
- screen.setCursorPos(deployship4_position.x , deployship4_position.y)
- screen.write("4.M.Ring")
- feelScreen(colors.black,colors.white)
- end
- function deployship(schema)
- print(schema)
- if schema == SData.schematic then
- if SData.schematic ~= "" then
- res,pw = shipscanner.deploy(SData.schematic,0,20,0)
- print(res)
- print(pw)
- end
- else
- if schema ~= "" then
- res,pw = shipscanner.deploy(schema,0,20,0)
- print(res)
- print(pw)
- end
- end
- end
- function scship()
- --print("scship")
- print("energy level " .. tostring(shipscanner.energy()))
- feelScreen(colors.black,colors.white)
- screen.setBackgroundColor(colors.green)
- screen.setCursorPos(shipsc_position.x, shipsc_position.y+12)
- screen.write(shipscanner.energy())
- scanstrings = shipscanner.scan()
- print(scanstrings)
- FN =shipscanner.fileName()
- l = string.find(FN ," ")
- while l ~= nil do
- FN = shipscanner.fileName()
- l = string.find(FN ," ")
- sleep(1)
- print("is scanning")
- end
- print(FN)
- SData.schematic = FN
- SaveData()
- sleep(0.3)
- return 0
- end
- function radarscan()
- modemenu = "radar"
- screen.clear()
- feelScreen(colors.black,colors.white)
- screen.setBackgroundColor(colors.blue)
- screen.setCursorPos(backbutton_position.x, backbutton_position.y)
- screen.write("BACK")
- feelScreen(colors.black,colors.white)
- radiusr = 1000
- print(radar.pos())
- RadarEnergyLevel = radar.getEnergyLevel()
- print(RadarEnergyLevel)
- if RadarEnergyLevel < radiusr * radiusr then
- print("Low energy level. Sasaj")
- screen.setBackgroundColor(colors.red)
- screen.setCursorPos(1 , backbutton_position.y + 4)
- screen.write("Low energy ")
- feelScreen(colors.black,colors.white)
- sleep(1)
- mainmenu()
- end
- screen.setBackgroundColor(colors.cyan)
- screen.setCursorPos(1 , backbutton_position.y + 2)
- screen.write("Energy " .. RadarEnergyLevel)
- feelScreen(colors.black,colors.white)
- sc = radar.scanRadius(radiusr)
- print(sc)
- --sleep(0.3)
- print("Scanning...")
- rcount = radar.getResultsCount()
- if rcount > 0 then
- for i=0, rcount-1 do
- freq, x, y, z = radar.getResult(i)
- print("Find: "..freq.." ("..x.. " " .. y .. " " .. z .. ")")
- screen.setBackgroundColor(colors.blue)
- screen.setCursorPos(textcenter_position.x, textcenter_position.y -4)
- screen.write("Find: "..x.. " " .. y .. " " .. z)
- feelScreen(colors.black,colors.white)
- end
- mainmenu()
- else
- print("Nothing is found =(")
- screen.setBackgroundColor(colors.blue)
- screen.setCursorPos(textcenter_position.x, textcenter_position.y)
- screen.write("Nothing =(")
- end
- feelScreen(colors.black,colors.white)
- screen.setBackgroundColor(colors.green)
- screen.setCursorPos(radarscan_position.x , radarscan_position.y)
- screen.write("START RADAR")
- feelScreen(colors.black,colors.white)
- sleep (1)
- end
- function initcammon()
- --print("main")
- local fr = 1
- for icam = 1, #camers do
- camera = camers[icam]["cm"]
- camera.freq(fr)
- fr = fr + 1
- --print("camera " .. camera.freq(1))
- print("camera " .. camera.freq())
- end
- end
- function monscreen()
- modemenu = "cmr"
- SData.modemenu = "cmr"
- SaveData()
- screen.clear()
- feelScreen(colors.black,colors.white)
- screen.setBackgroundColor(colors.blue)
- screen.setCursorPos(backbutton_position.x, backbutton_position.y)
- screen.write("BACK")
- screen.setCursorPos(5, 2)
- screen.setBackgroundColor(colors.red)
- screen.write ("VIDEO")
- if cam == true and cammon == true then
- for i=1, #camers do
- y=2*i+2
- heights[i]=y
- screen.setCursorPos(4, y)
- screen.setBackgroundColor(colors.blue)
- screen.write ("camera"..i)
- screen.setBackgroundColor(colors.black)
- end
- end
- end
- function activateChosenCamera()
- screen.clear()
- feelScreen(colors.black,colors.white)
- screen.setBackgroundColor(colors.blue)
- screen.setCursorPos(backbutton_position.x, backbutton_position.y)
- screen.write("BACK")
- screen.setCursorPos(5, 2)
- screen.setBackgroundColor(colors.red)
- screen.write ("VIDEO")
- for i=1, #camers do
- y=2*i+2
- screen.setCursorPos(4, y)
- if y == chosencamera then
- screen.setBackgroundColor(colors.green)
- cammonitor.freq(i)
- print("monitor frequency " .. cammonitor.freq())
- else
- screen.setBackgroundColor(colors.blue)
- end
- screen.write ("camera"..i)
- screen.setBackgroundColor(colors.black)
- end
- end
- function cloakscreen()
- modemenu = "cld"
- SData.modemenu = "cld"
- SaveData()
- screen.clear()
- feelScreen(colors.black,colors.white)
- screen.setBackgroundColor(colors.blue)
- screen.setCursorPos(backbutton_position.x, backbutton_position.y)
- screen.write("BACK")
- screen.setCursorPos(4, 3)
- screen.setBackgroundColor(colors.red)
- screen.write ("CLOAKING")
- screen.setBackgroundColor(colors.black)
- screen.setCursorPos(2, 5)
- screen.setBackgroundColor(colors.blue)
- cloakenergy = cloak.getEnergyLevel()
- screen.write ("ENERGY")
- screen.setCursorPos(2, 6)
- screen.write (cloakenergy)
- screen.setBackgroundColor(colors.black)
- local valid = cloak.isAssemblyValid()
- if valid then
- screen.setCursorPos(2, 8)
- screen.setBackgroundColor(colors.green)
- screen.write("assem.: ok")
- else
- screen.setCursorPos(2, 8)
- screen.setBackgroundColor(colors.red)
- screen.write("assem.: no")
- end
- screen.setBackgroundColor(colors.blue)
- screen.setCursorPos(2, 10)
- if FieldTier == 1 then
- screen.write ("TIER 1")
- else
- screen.write ("TIER 2")
- end
- screen.setCursorPos(4, 16)
- screen.setBackgroundColor(colors.green)
- screen.write ("START")
- screen.setCursorPos(4, 18)
- screen.setBackgroundColor(colors.red)
- screen.write ("STOP")
- screen.setBackgroundColor(colors.black)
- end
- function touch_control()
- local event, side, xPos, yPos = os.pullEvent("monitor_touch")
- if modemenu == "mine" then
- mining()
- if xPos <= start_all_position.x+10 and yPos == start_all_position.y then
- startAll()
- elseif xPos >= stop_all_position.x and yPos == stop_all_position.y then
- stopAll()
- elseif yPos == lasermode_position.y then
- setlasermode()
- elseif yPos == backbutton_position.y then
- mainmenu()
- end
- elseif modemenu == "jumping" then
- if xPos >= backbutton_position.x and xPos <= (backbutton_position.x + 10) and yPos == backbutton_position.y then
- mainmenu()
- elseif yPos == GoJump_position.y then
- feelScreen(colors.black,colors.white)
- screen.setCursorPos(GoJump_position.x , GoJump_position.y)
- screen.setBackgroundColor(colors.green)
- screen.write("GO JUMP")
- Warp()
- sleep(0.3)
- elseif yPos == automine_position.y then
- if las then
- feelScreen(colors.black,colors.white)
- screen.setCursorPos(automine_position.x , automine_position.y)
- screen.setBackgroundColor(colors.green)
- screen.write("AUTOMINE")
- sleep(0.3)
- startAll()
- automine()
- end
- elseif yPos == JumpToCoord_position.y then
- resetColorsScreen()
- SetCoord()
- end
- elseif modemenu == "main" then
- resetColorsScreen()
- if yPos == mining_position.y then
- if las then
- resetColorsScreen()
- mining()
- end
- elseif yPos == jumping_position.y then
- resetColorsScreen()
- jumping()
- elseif yPos == shipscan_position.y then
- if shipsc then
- resetColorsScreen()
- shipscan()
- end
- elseif yPos == radar_position.y then
- resetColorsScreen()
- if radar then
- radarscan()
- end
- elseif yPos == cloak_position.y then
- resetColorsScreen()
- if cldev then
- cloakscreen()
- end
- elseif yPos == camera_position.y then
- resetColorsScreen()
- if cam == true and cammon == true then
- monscreen()
- end
- end
- elseif modemenu == "automine" then
- resetColorsScreen()
- if xPos >= backbutton_position.x and xPos <= (backbutton_position.x + 10) and yPos == backbutton_position.y then
- stopAll()
- mainmenu()
- end
- elseif modemenu == "shipscan" then
- resetColorsScreen()
- if yPos == shipsc_position.y then
- scship()
- elseif yPos == deployship_position.y then
- deployship(SData.schematic)
- elseif yPos == deployship1_position.y then
- schema = "d1404472739316.schematic"
- deployship(schema)
- elseif yPos == deployship2_position.y then
- schema = "default1407225353906.schematic"
- deployship(schema)
- elseif yPos == deployship3_position.y then
- schema = "taxi1407485902452.schematic"
- deployship(schema)
- elseif yPos == deployship4_position.y then
- schema = "default1409504631567.schematic"
- deployship(schema)
- elseif yPos == backbutton_position.y then
- mainmenu()
- end
- elseif modemenu == "radar" then
- resetColorsScreen()
- if yPos == radarscan_position.y then
- feelScreen(colors.black,colors.white)
- screen.setCursorPos(radarscan_position.x , radarscan_position.y)
- screen.setBackgroundColor(colors.green)
- screen.write("START RADAR")
- sleep(0.3)
- radarscan()
- elseif yPos == backbutton_position.y then
- mainmenu()
- end
- elseif modemenu == "jtc" then
- if yPos == backbutton_position.y then
- SData.autojump = false
- SaveData()
- mainmenu()
- end
- elseif modemenu == "cld" then
- if yPos == backbutton_position.y then
- mainmenu()
- end
- if yPos == 10 then
- if FieldTier == 1 then
- FieldTier = 2
- else
- FieldTier = 1
- end
- cloakscreen()
- elseif yPos == 16 then
- cloak.setFieldFrequency(1122)
- cloak.setFieldTier(FieldTier)
- cloak.enableCloakingField()
- cloakscreen()
- elseif yPos == 18 then
- cloak.disableCloakingField()
- cloakscreen()
- end
- elseif modemenu == "cmr" then
- if yPos == backbutton_position.y then
- mainmenu()
- end
- for n=1, #heights do
- if yPos == heights[n] then
- chosencamera = heights[n]
- print("chosencamera " .. n)
- activateChosenCamera()
- end
- end
- end
- sleep(0.3)
- return 0
- end
- function initwcore()
- if wcore then
- print("wcore is present")
- if mon ~= true then
- print "need monitor"
- return 0
- else
- if fs.exists("shipdata.txt") then
- ReadData()
- else
- SData = {
- Summon = false,
- Distance = 1,
- Direction = 0,
- Shipname = "",
- modemenu = "",
- lasermode = "",
- schematic = "",
- CurrentCore = "",
- MainCore = "",
- autojump = "",
- DestCoordX = "",
- DestCoordY = "",
- DestCoordZ = ""
- }
- end
- SetColorDeflt()
- if type(warp) ~= "table" then
- ShowWarning("No warpcore controller detected")
- os.pullEvent("key")
- os.shutdown()
- end
- if SData.Shipname == "" then
- SetShipName()
- end
- if SData.Summon then
- warp.summon_all()
- end
- warp.set_mode(1)
- if SData.Summon then
- SData.Summon = false
- SaveData()
- end
- if SData.autojump ==true then
- statistic()
- autojumpStatistic()
- if IsInHyper then
- JumpInHyper()
- else
- JumpToCoord()
- end
- end
- print("SData.lasermode " .. SData.lasermode)
- if SData.lasermode ~= "mine" or SData.lasermode ~= "quarry" then
- lasermode = "mine"
- SData.lasermode = "mine"
- SaveData()
- end
- lasermode = SData.lasermode
- if SData.modemenu == "jumping" then
- modemenu = "jumping"
- jumping()
- elseif SData.modemenu == "mine" then
- modemenu = "mine"
- mining()
- elseif SData.modemenu == "automine" then
- modemenu = "automine"
- startAll()
- automine()
- elseif SData.modemenu == "shipscan" then
- modemenu = "shipscan"
- shipscan()
- else
- modemenu = "main"
- mainmenu()
- end
- end
- else
- print ("need wcore controller")
- end
- end
- function init()
- --sleep(5)
- local camcount = 0
- local nc = 1
- local periList = peripheral.getNames()
- for i = 1, #periList do
- device=peripheral.getType(periList[i])
- print(device)
- local tableMethods = peripheral.getMethods(periList[i])
- local countOfMethods = table.maxn (tableMethods)
- print("methods: " .. countOfMethods)
- sleep(0.1)
- if device == "monitor" then
- if countOfMethods == 1 then
- cammon = true
- cammonitor = peripheral.wrap(periList[i])
- initcammon()
- else
- mon = true
- screen = peripheral.wrap(periList[i])
- screen.setTextScale(MON_SCALE)
- screen_width, screen_height = screen.getSize()
- print("screensize:" .. tostring(screen_width) .."x".. tostring(screen_height))
- setScreenPosition()
- end
- elseif device == "mininglaser" then
- las = true
- table.insert(lazors, periList[i])
- elseif device == "warpcore" then
- if wcore == true then
- multicore = true
- sleep(1)
- nc = nc+1
- print("multicore")
- sleep(0.1)
- table.insert(wcores,{ID = nc,core = peripheral.wrap(periList[i])})
- warp = wcores[nc]["core"]
- warp.set_mode(1)
- else
- wcore = true
- warp = peripheral.wrap(periList[i])
- table.insert(wcores,{ID=nc,core = peripheral.wrap(periList[i])})
- warp.set_mode(1)
- end
- curCoreIndex = #wcores
- wcores[#wcores]["core"].set_mode(1)
- elseif device == "openperipheral_glassesbridge" then
- bridge = peripheral.wrap(periList[i])
- elseif device == "modem" then
- m = true
- m = peripheral.wrap(periList[i])
- elseif device == "shipscanner" then
- shipsc = true
- shipscanner = peripheral.wrap(periList[i])
- elseif device == "radar" then
- rad = true
- radar = peripheral.wrap(periList[i])
- elseif device == "camera" then
- cam = true
- camcount = camcount+1
- if multicam == true then
- table.insert(camers,{ID = camcount,cm = peripheral.wrap(periList[i])})
- --cammonitor = camers[mc]["cm"]
- --print("camers " ..tostring(camers[camcount]) )
- else
- multicam = true
- table.insert(camers,{ID = camcount,cm = peripheral.wrap(periList[i])})
- --cammonitor = camers[mc]["cm"]
- --print("camers " ..tostring(camers[camcount]["cm"]) )
- end
- elseif device == "cloakingdevicecore" then
- print("found: "..device)
- cldev = true
- cloak = peripheral.wrap(periList[i])
- print("energy: "..tostring(cloakenergy).."eu")
- print("isAssemblyValid: "..tostring(cloak.isAssemblyValid()))
- end
- end
- end
- function mainmenu()
- modemenu = "main"
- SData.modemenu = "main"
- SaveData()
- screen.clear()
- feelScreen(colors.orange,colors.cyan)
- screen.setCursorPos(title_position.x, title_position.y)
- screen.write("kopro-OS")
- screen.setCursorPos(title_position.x, title_position.y+1)
- screen.write("ver. 0.007")
- if las == true then
- feelScreen(colors.cyan,colors.white)
- screen.setCursorPos(mining_position.x, mining_position.y)
- screen.write("MINE")
- feelScreen(colors.orange,colors.cyan)
- end
- if shipsc == true then
- feelScreen(colors.cyan,colors.white)
- screen.setCursorPos(shipscan_position.x, shipscan_position.y)
- screen.write("SHIPSCAN")
- feelScreen(colors.orange,colors.cyan)
- end
- feelScreen(colors.cyan,colors.white)
- screen.setCursorPos(jumping_position.x, jumping_position.y)
- screen.write("JUMP")
- feelScreen(colors.orange,colors.cyan)
- if rad == true then
- feelScreen(colors.cyan,colors.white)
- screen.setCursorPos(radar_position.x, radar_position.y)
- screen.write("RADAR")
- feelScreen(colors.orange,colors.cyan)
- end
- if cam == true and cammon == true then
- feelScreen(colors.cyan,colors.white)
- screen.setCursorPos(camera_position.x, camera_position.y)
- screen.write("CAMERA")
- feelScreen(colors.orange,colors.cyan)
- end
- if cldev == true then
- feelScreen(colors.cyan,colors.white)
- screen.setCursorPos(cloak_position.x, cloak_position.y)
- screen.write("CLOAK")
- feelScreen(colors.orange,colors.cyan)
- end
- feelScreen(colors.orange,colors.white)
- sleep(0.5)
- return 0
- end
- init()
- initwcore()
- while true do
- if modemenu == "jumping" then
- parallel.waitForAny(touch_control,manctrl)
- elseif modemenu == "jtc" then
- parallel.waitForAny(touch_control,SetCoord)
- else
- parallel.waitForAny( touch_control)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement