Updated LUA script with new API
This commit is contained in:
parent
6fc0a63162
commit
40f40978f8
7 changed files with 135 additions and 119 deletions
|
@ -441,7 +441,7 @@ function cloaking_page()
|
||||||
SetColorDefault()
|
SetColorDefault()
|
||||||
Write("Cloaking core " .. cloaking_currentKey .. " of " .. #cloakingcores)
|
Write("Cloaking core " .. cloaking_currentKey .. " of " .. #cloakingcores)
|
||||||
local isAssemblyValid = cloakingcore.isAssemblyValid()
|
local isAssemblyValid = cloakingcore.isAssemblyValid()
|
||||||
local energy, energyMax = cloakingcore.getEnergyLevel()
|
local energy, energyMax = cloakingcore.energy()
|
||||||
local isEnabled = cloakingcore.enable()
|
local isEnabled = cloakingcore.enable()
|
||||||
|
|
||||||
if not isAssemblyValid then
|
if not isAssemblyValid then
|
||||||
|
@ -919,7 +919,7 @@ end
|
||||||
function reactor_laser(side)
|
function reactor_laser(side)
|
||||||
for key,reactorlaser in pairs(reactorlasers) do
|
for key,reactorlaser in pairs(reactorlasers) do
|
||||||
if (side == nil) or (reactorlaser.side() == side) then
|
if (side == nil) or (reactorlaser.side() == side) then
|
||||||
reactorlaser.sendLaser(data.reactor_laserAmount)
|
reactorlaser.stabilize(data.reactor_laserAmount)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -454,7 +454,7 @@ function cloaking_page()
|
||||||
SetColorDefault()
|
SetColorDefault()
|
||||||
Write("Cloaking core " .. cloaking_currentKey .. " of " .. #cloakingcores)
|
Write("Cloaking core " .. cloaking_currentKey .. " of " .. #cloakingcores)
|
||||||
local isAssemblyValid = cloakingcore.isAssemblyValid()
|
local isAssemblyValid = cloakingcore.isAssemblyValid()
|
||||||
local energy, energyMax = cloakingcore.getEnergyLevel()
|
local energy, energyMax = cloakingcore.energy()
|
||||||
local isEnabled = cloakingcore.enable()
|
local isEnabled = cloakingcore.enable()
|
||||||
|
|
||||||
if not isAssemblyValid then
|
if not isAssemblyValid then
|
||||||
|
@ -716,7 +716,7 @@ function data_explode(separator, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
function data_setName()
|
function data_setName()
|
||||||
if warpcore ~= nil then
|
if ship ~= nil then
|
||||||
ShowTitle("<==== Set ship name ====>")
|
ShowTitle("<==== Set ship name ====>")
|
||||||
else
|
else
|
||||||
ShowTitle("<==== Set name ====>")
|
ShowTitle("<==== Set name ====>")
|
||||||
|
@ -726,13 +726,13 @@ function data_setName()
|
||||||
Write("Enter ship name: ")
|
Write("Enter ship name: ")
|
||||||
label = readInputText(label)
|
label = readInputText(label)
|
||||||
os.setComputerLabel(label)
|
os.setComputerLabel(label)
|
||||||
if warpcore ~= nil then
|
if ship ~= nil then
|
||||||
warpcore.coreFrequency(label)
|
ship.coreFrequency(label)
|
||||||
end
|
end
|
||||||
os.reboot()
|
os.reboot()
|
||||||
end
|
end
|
||||||
|
|
||||||
----------- Warpcore support
|
----------- Ship support
|
||||||
|
|
||||||
core_front = 0
|
core_front = 0
|
||||||
core_right = 0
|
core_right = 0
|
||||||
|
@ -747,36 +747,36 @@ core_jumpCost = 0
|
||||||
core_shipSize = 0
|
core_shipSize = 0
|
||||||
|
|
||||||
function core_boot()
|
function core_boot()
|
||||||
if warpcore == nil then
|
if ship == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
Write("Booting Warpdrive Core")
|
Write("Booting Warpdrive Core")
|
||||||
|
|
||||||
if data.core_summon then
|
if data.core_summon then
|
||||||
warpcore.summon_all()
|
ship.summon_all()
|
||||||
end
|
end
|
||||||
|
|
||||||
Write(".")
|
Write(".")
|
||||||
core_front, core_right, core_up = warpcore.dim_positive()
|
core_front, core_right, core_up = ship.dim_positive()
|
||||||
core_back, core_left, core_down = warpcore.dim_negative()
|
core_back, core_left, core_down = ship.dim_negative()
|
||||||
core_isInHyper = warpcore.isInHyperspace()
|
core_isInHyper = ship.isInHyperspace()
|
||||||
|
|
||||||
Write(".")
|
Write(".")
|
||||||
repeat
|
repeat
|
||||||
pos = warpcore.pos()
|
pos = ship.pos()
|
||||||
sleep(0.3)
|
sleep(0.3)
|
||||||
until pos ~= nil
|
until pos ~= nil
|
||||||
X, Y, Z = warpcore.pos()
|
X, Y, Z = ship.pos()
|
||||||
Write(".")
|
Write(".")
|
||||||
repeat
|
repeat
|
||||||
isAttached = warpcore.isAttached()
|
isAttached = ship.isAttached()
|
||||||
sleep(0.3)
|
sleep(0.3)
|
||||||
until isAttached ~= false
|
until isAttached ~= false
|
||||||
|
|
||||||
Write(".")
|
Write(".")
|
||||||
repeat
|
repeat
|
||||||
core_shipSize = warpcore.getShipSize()
|
core_shipSize = ship.getShipSize()
|
||||||
sleep(0.3)
|
sleep(0.3)
|
||||||
until core_shipSize ~= nil
|
until core_shipSize ~= nil
|
||||||
|
|
||||||
|
@ -784,7 +784,7 @@ function core_boot()
|
||||||
core_computeRealDistance()
|
core_computeRealDistance()
|
||||||
|
|
||||||
Write(".")
|
Write(".")
|
||||||
warpcore.mode(1)
|
ship.mode(1)
|
||||||
WriteLn("")
|
WriteLn("")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -829,7 +829,7 @@ function core_computeNewCoordinates(cx, cy, cz)
|
||||||
elseif data.core_direction == 2 then
|
elseif data.core_direction == 2 then
|
||||||
res.y = res.y - core_realDistance
|
res.y = res.y - core_realDistance
|
||||||
end
|
end
|
||||||
local dx, dy, dz = warpcore.getOrientation()
|
local dx, dy, dz = ship.getOrientation()
|
||||||
if dx ~= 0 then
|
if dx ~= 0 then
|
||||||
if data.core_direction == 0 then
|
if data.core_direction == 0 then
|
||||||
res.x = res.x + (core_realDistance * dx)
|
res.x = res.x + (core_realDistance * dx)
|
||||||
|
@ -858,14 +858,14 @@ function core_warp()
|
||||||
rs.setOutput(alarm_side, true)
|
rs.setOutput(alarm_side, true)
|
||||||
if readConfirmation() then
|
if readConfirmation() then
|
||||||
rs.setOutput(alarm_side, false)
|
rs.setOutput(alarm_side, false)
|
||||||
warpcore.direction(data.core_direction)
|
ship.direction(data.core_direction)
|
||||||
warpcore.distance(data.core_distance)
|
ship.distance(data.core_distance)
|
||||||
if core_isInHyper then
|
if core_isInHyper then
|
||||||
warpcore.mode(2)
|
ship.mode(2)
|
||||||
else
|
else
|
||||||
warpcore.mode(1)
|
ship.mode(1)
|
||||||
end
|
end
|
||||||
warpcore.jump()
|
ship.jump()
|
||||||
end
|
end
|
||||||
rs.setOutput(alarm_side, false)
|
rs.setOutput(alarm_side, false)
|
||||||
end
|
end
|
||||||
|
@ -941,15 +941,15 @@ function core_page_setDimensions()
|
||||||
Write(" Down (".. core_down ..") : ")
|
Write(" Down (".. core_down ..") : ")
|
||||||
core_down = readInputNumber(core_down)
|
core_down = readInputNumber(core_down)
|
||||||
Write("Setting dimensions...")
|
Write("Setting dimensions...")
|
||||||
warpcore.dim_positive(core_front, core_right, core_up)
|
ship.dim_positive(core_front, core_right, core_up)
|
||||||
warpcore.dim_negative(core_back, core_left, core_down)
|
ship.dim_negative(core_back, core_left, core_down)
|
||||||
core_shipSize = warpcore.getShipSize()
|
core_shipSize = ship.getShipSize()
|
||||||
if core_shipSize == nil then core_shipSize = 0 end
|
if core_shipSize == nil then core_shipSize = 0 end
|
||||||
end
|
end
|
||||||
|
|
||||||
function core_page_summon()
|
function core_page_summon()
|
||||||
ShowTitle("<==== Summon players ====>")
|
ShowTitle("<==== Summon players ====>")
|
||||||
local playersString, playersArray = warpcore.getAttachedPlayers()
|
local playersString, playersArray = ship.getAttachedPlayers()
|
||||||
for i = 1, #playersArray do
|
for i = 1, #playersArray do
|
||||||
Show(i..". "..playersArray[i])
|
Show(i..". "..playersArray[i])
|
||||||
end
|
end
|
||||||
|
@ -961,10 +961,10 @@ function core_page_summon()
|
||||||
Write(":")
|
Write(":")
|
||||||
local input = readInputNumber("")
|
local input = readInputNumber("")
|
||||||
if input == "" then
|
if input == "" then
|
||||||
warpcore.summon_all()
|
ship.summon_all()
|
||||||
else
|
else
|
||||||
input = tonumber(input)
|
input = tonumber(input)
|
||||||
warpcore.summon(input - 1)
|
ship.summon(input - 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -976,9 +976,9 @@ function core_page_jumpToBeacon()
|
||||||
rs.setOutput(alarm_side, true)
|
rs.setOutput(alarm_side, true)
|
||||||
if readConfirmation() then
|
if readConfirmation() then
|
||||||
rs.setOutput(alarm_side, false)
|
rs.setOutput(alarm_side, false)
|
||||||
warpcore.mode(4)
|
ship.mode(4)
|
||||||
warpcore.beaconFrequency(freq)
|
ship.beaconFrequency(freq)
|
||||||
warpcore.jump()
|
ship.jump()
|
||||||
end
|
end
|
||||||
rs.setOutput(alarm_side, false)
|
rs.setOutput(alarm_side, false)
|
||||||
end
|
end
|
||||||
|
@ -991,23 +991,23 @@ function core_page_jumpToGate()
|
||||||
rs.setOutput(alarm_side, true)
|
rs.setOutput(alarm_side, true)
|
||||||
if readConfirmation() then
|
if readConfirmation() then
|
||||||
rs.setOutput(alarm_side, false)
|
rs.setOutput(alarm_side, false)
|
||||||
warpcore.mode(6)
|
ship.mode(6)
|
||||||
warpcore.targetJumpgate(name)
|
ship.targetJumpgate(name)
|
||||||
warpcore.jump()
|
ship.jump()
|
||||||
end
|
end
|
||||||
rs.setOutput(alarm_side, false)
|
rs.setOutput(alarm_side, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
function core_page()
|
function core_page()
|
||||||
ShowTitle(label .. " - Warpcore status")
|
ShowTitle(label .. " - Ship status")
|
||||||
if warpcore ~= nil then
|
if ship ~= nil then
|
||||||
WriteLn("Core:")
|
WriteLn("Core:")
|
||||||
WriteLn(" x, y, z = " .. X .. ", " .. Y .. ", " .. Z)
|
WriteLn(" x, y, z = " .. X .. ", " .. Y .. ", " .. Z)
|
||||||
local energy, energyMax = warpcore.getEnergyLevel()
|
local energy, energyMax = ship.energy()
|
||||||
if energy == nil then energy = 0 end
|
if energy == nil then energy = 0 end
|
||||||
if energyMax == nil then energyMax = 1 end
|
if energyMax == nil then energyMax = 1 end
|
||||||
WriteLn(" Energy = " .. math.floor(energy / energyMax * 100) .. " % (" .. energy .. "EU)")
|
WriteLn(" Energy = " .. math.floor(energy / energyMax * 100) .. " % (" .. energy .. "EU)")
|
||||||
local playersString, playersArray = warpcore.getAttachedPlayers()
|
local playersString, playersArray = ship.getAttachedPlayers()
|
||||||
if playersString == "" then players = "-" end
|
if playersString == "" then players = "-" end
|
||||||
WriteLn(" Attached players = " .. playersString)
|
WriteLn(" Attached players = " .. playersString)
|
||||||
WriteLn("Dimensions:")
|
WriteLn("Dimensions:")
|
||||||
|
@ -1025,7 +1025,7 @@ function core_page()
|
||||||
WriteLn(" Summon after = No")
|
WriteLn(" Summon after = No")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
ShowWarning("No warpcore controller detected")
|
ShowWarning("No ship controller detected")
|
||||||
end
|
end
|
||||||
|
|
||||||
SetCursorPos(1, 15)
|
SetCursorPos(1, 15)
|
||||||
|
@ -1070,8 +1070,8 @@ function core_key(keycode)
|
||||||
rs.setOutput(alarm_side, true)
|
rs.setOutput(alarm_side, true)
|
||||||
if readConfirmation() then
|
if readConfirmation() then
|
||||||
rs.setOutput(alarm_side, false)
|
rs.setOutput(alarm_side, false)
|
||||||
warpcore.mode(5)
|
ship.mode(5)
|
||||||
warpcore.jump()
|
ship.jump()
|
||||||
end
|
end
|
||||||
rs.setOutput(alarm_side, false)
|
rs.setOutput(alarm_side, false)
|
||||||
return true
|
return true
|
||||||
|
@ -1318,7 +1318,7 @@ end
|
||||||
function reactor_laser(side)
|
function reactor_laser(side)
|
||||||
for key,reactorlaser in pairs(reactorlasers) do
|
for key,reactorlaser in pairs(reactorlasers) do
|
||||||
if (side == nil) or (reactorlaser.side() == side) then
|
if (side == nil) or (reactorlaser.side() == side) then
|
||||||
reactorlaser.sendLaser(data.reactor_laserAmount)
|
reactorlaser.stabilize(data.reactor_laserAmount)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1506,7 +1506,7 @@ function radar_page()
|
||||||
end
|
end
|
||||||
|
|
||||||
SetColorDefault()
|
SetColorDefault()
|
||||||
local energy = { radar.getEnergyLevel() }
|
local energy = { radar.energy() }
|
||||||
SetCursorPos(1, 12)
|
SetCursorPos(1, 12)
|
||||||
Write("Energy: ")
|
Write("Energy: ")
|
||||||
if energy ~= nil then
|
if energy ~= nil then
|
||||||
|
@ -1613,7 +1613,7 @@ function radar_scan()
|
||||||
draw_warning(monitor, "No radar")
|
draw_warning(monitor, "No radar")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if radar.getEnergyLevel() < (data.radar_radius * data.radar_radius) then
|
if radar.energy() < (data.radar_radius * data.radar_radius) then
|
||||||
draw_warning(monitor, "LOW POWER")
|
draw_warning(monitor, "LOW POWER")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -1623,8 +1623,10 @@ function radar_scan()
|
||||||
end
|
end
|
||||||
radar_timerId = os.startTimer(radar_timerLength)
|
radar_timerId = os.startTimer(radar_timerLength)
|
||||||
|
|
||||||
radar.scanRadius(data.radar_radius);
|
radar.radius(data.radar_radius)
|
||||||
|
if radar.start() then
|
||||||
draw_warning(monitor, "Scanning...")
|
draw_warning(monitor, "Scanning...")
|
||||||
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1633,11 +1635,13 @@ function radar_scanDone()
|
||||||
data.radar_results = {}
|
data.radar_results = {}
|
||||||
if (numResults ~= 0) then
|
if (numResults ~= 0) then
|
||||||
for i = 0, numResults do
|
for i = 0, numResults do
|
||||||
local frequency, x, y, z = radar.getResult(i)
|
local success, type, name, x, y, z = radar.getResult(i)
|
||||||
if frequency == "default" then
|
if success then
|
||||||
frequency = "?"
|
if name == "default" then
|
||||||
|
name = "?"
|
||||||
|
end
|
||||||
|
data.radar_results[i] = { x = x, y = y, z = z, name = name, type = type }
|
||||||
end
|
end
|
||||||
data.radar_results[i] = { x = x, y = y, z = z, frequency = frequency, kind = "core" }
|
|
||||||
end
|
end
|
||||||
data.radar_scale = data.radar_radius
|
data.radar_scale = data.radar_radius
|
||||||
end
|
end
|
||||||
|
@ -1713,13 +1717,13 @@ function radar_drawContact(monitor, contact)
|
||||||
screenX = math.floor(screenX * (screenWidth - 3) / 2 + ((screenWidth - 1) / 2) + 1.5)
|
screenX = math.floor(screenX * (screenWidth - 3) / 2 + ((screenWidth - 1) / 2) + 1.5)
|
||||||
screenY = math.floor(screenY * (screenHeight - 3) / 2 + ((screenHeight - 1) / 2) + 1.5)
|
screenY = math.floor(screenY * (screenHeight - 3) / 2 + ((screenHeight - 1) / 2) + 1.5)
|
||||||
|
|
||||||
if contact.kind == "self" then
|
if contact.type == "self" then
|
||||||
draw_text(monitor, screenX, screenY, Style.TextRadarself, Style.CRadarself, Style.BGRadarself)
|
draw_text(monitor, screenX, screenY, Style.TextRadarself, Style.CRadarself, Style.BGRadarself)
|
||||||
else
|
else
|
||||||
draw_text(monitor, screenX, screenY, Style.TextRadarother, Style.CRadarother, Style.BGRadarother)
|
draw_text(monitor, screenX, screenY, Style.TextRadarother, Style.CRadarother, Style.BGRadarother)
|
||||||
end
|
end
|
||||||
if visible then
|
if visible then
|
||||||
local text = contact.frequency
|
local text = contact.name
|
||||||
screenX = math.min(screenWidth - 1 - string.len(text), math.max(2, math.floor(screenX - string.len(text) / 2 + 0.5)))
|
screenX = math.min(screenWidth - 1 - string.len(text), math.max(2, math.floor(screenX - string.len(text) / 2 + 0.5)))
|
||||||
if screenY == (screenHeight - 1) then
|
if screenY == (screenHeight - 1) then
|
||||||
screenY = screenY - 1
|
screenY = screenY - 1
|
||||||
|
@ -1781,13 +1785,13 @@ function radar_drawMap()
|
||||||
-- status
|
-- status
|
||||||
local text = "Scan radius: " .. data.radar_radius
|
local text = "Scan radius: " .. data.radar_radius
|
||||||
if radar ~= nil then
|
if radar ~= nil then
|
||||||
text = text .. " | Energy: " .. radar.getEnergyLevel() .. " EU"
|
text = text .. " | Energy: " .. radar.energy() .. " EU"
|
||||||
end
|
end
|
||||||
text = text .. " | Scale: " .. data.radar_scale
|
text = text .. " | Scale: " .. data.radar_scale
|
||||||
draw_centeredText(monitor, screenHeight, text)
|
draw_centeredText(monitor, screenHeight, text)
|
||||||
-- results
|
-- results
|
||||||
SetCursorPos(1, 12)
|
SetCursorPos(1, 12)
|
||||||
radar_drawContact(monitor, {x = radar_x, y = radar_y, z = radar_z, frequency = "", kind = "self"})
|
radar_drawContact(monitor, {x = radar_x, y = radar_y, z = radar_z, name = "", type = "self"})
|
||||||
for i = 0, #data.radar_results - 1 do
|
for i = 0, #data.radar_results - 1 do
|
||||||
radar_drawContact(monitor, data.radar_results[i])
|
radar_drawContact(monitor, data.radar_results[i])
|
||||||
end
|
end
|
||||||
|
@ -1835,7 +1839,7 @@ reactor = nil
|
||||||
mininglasers = {}
|
mininglasers = {}
|
||||||
reactorlasers = {}
|
reactorlasers = {}
|
||||||
cloakingcores = {}
|
cloakingcores = {}
|
||||||
warpcore = nil
|
ship = nil
|
||||||
radar = nil
|
radar = nil
|
||||||
for key,side in pairs(sides) do
|
for key,side in pairs(sides) do
|
||||||
sleep(0)
|
sleep(0)
|
||||||
|
@ -1846,7 +1850,7 @@ for key,side in pairs(sides) do
|
||||||
lmonitor.setTextScale(monitor_textScale)
|
lmonitor.setTextScale(monitor_textScale)
|
||||||
elseif peripheral.getType(side) == "warpdriveShipController" then
|
elseif peripheral.getType(side) == "warpdriveShipController" then
|
||||||
WriteLn("Wrapping " .. side)
|
WriteLn("Wrapping " .. side)
|
||||||
warpcore = peripheral.wrap(side)
|
ship = peripheral.wrap(side)
|
||||||
elseif peripheral.getType(side) == "warpdriveEnanReactorCore" then
|
elseif peripheral.getType(side) == "warpdriveEnanReactorCore" then
|
||||||
WriteLn("Wrapping " .. side)
|
WriteLn("Wrapping " .. side)
|
||||||
reactor = peripheral.wrap(side)
|
reactor = peripheral.wrap(side)
|
||||||
|
@ -1866,7 +1870,7 @@ for key,side in pairs(sides) do
|
||||||
end
|
end
|
||||||
-- sleep(1)
|
-- sleep(1)
|
||||||
|
|
||||||
if not os.getComputerLabel() and (warpcore ~= nil or reactor ~= nil) then
|
if not os.getComputerLabel() and (ship ~= nil or reactor ~= nil) then
|
||||||
data_setName()
|
data_setName()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1886,12 +1890,12 @@ function connections_page()
|
||||||
WriteLn(#monitors .. " Monitors detected")
|
WriteLn(#monitors .. " Monitors detected")
|
||||||
end
|
end
|
||||||
|
|
||||||
if warpcore == nil then
|
if ship == nil then
|
||||||
SetColorDisabled()
|
SetColorDisabled()
|
||||||
WriteLn("No warpcore controller detected")
|
WriteLn("No ship controller detected")
|
||||||
else
|
else
|
||||||
SetColorSuccess()
|
SetColorSuccess()
|
||||||
WriteLn("Warpcore controller detected")
|
WriteLn("Ship controller detected")
|
||||||
end
|
end
|
||||||
|
|
||||||
if reactor == nil then
|
if reactor == nil then
|
||||||
|
@ -1940,7 +1944,7 @@ function connections_page()
|
||||||
WriteLn("No radar detected")
|
WriteLn("No radar detected")
|
||||||
else
|
else
|
||||||
SetColorSuccess()
|
SetColorSuccess()
|
||||||
WriteLn("Warpcore radar detected")
|
WriteLn("Radar detected")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,13 @@ if radius < 1 or radius > 9999 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
energy, energyMax = radar.getEnergyLevel()
|
energy, energyMax = radar.energy()
|
||||||
if energy < radius * radius then
|
if energy < radius * radius then
|
||||||
error("Low energy level... (" + energy + "/" + radius * radius + ")")
|
error("Low energy level... (" + energy + "/" + radius * radius + ")")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
radar.scanRadius(radius)
|
radar.radius(radius)
|
||||||
|
radar.start()
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
|
|
||||||
print("Scanning...")
|
print("Scanning...")
|
||||||
|
@ -58,8 +59,12 @@ print("took " .. seconds .. " seconds")
|
||||||
|
|
||||||
if count ~= nil and count > 0 then
|
if count ~= nil and count > 0 then
|
||||||
for i=0, count-1 do
|
for i=0, count-1 do
|
||||||
freq, x, y, z = radar.getResult(i)
|
success, type, name, x, y, z = radar.getResult(i)
|
||||||
print("Ship '" .. freq .. "' @ (" .. x .. " " .. y .. " " .. z .. ")")
|
if success then
|
||||||
|
print(type .. " " .. name .. " @ (" .. x .. " " .. y .. " " .. z .. ")")
|
||||||
|
else
|
||||||
|
print("Error " .. type)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print("Nothing was found =(")
|
print("Nothing was found =(")
|
||||||
|
|
|
@ -65,7 +65,7 @@ function drawContact(x, y, z, name, color)
|
||||||
end
|
end
|
||||||
|
|
||||||
function scanAndDraw()
|
function scanAndDraw()
|
||||||
local energy, energyMax = radar.getEnergyLevel()
|
local energy, energyMax = radar.energy()
|
||||||
if (energy < radius*radius) then
|
if (energy < radius*radius) then
|
||||||
hh = math.floor(h / 2)
|
hh = math.floor(h / 2)
|
||||||
hw = math.floor(w / 2)
|
hw = math.floor(w / 2)
|
||||||
|
@ -78,7 +78,8 @@ function scanAndDraw()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
radar.scanRadius(radius)
|
radar.radius(radius)
|
||||||
|
radar.start()
|
||||||
sleep(2)
|
sleep(2)
|
||||||
|
|
||||||
redraw()
|
redraw()
|
||||||
|
@ -87,9 +88,9 @@ function scanAndDraw()
|
||||||
|
|
||||||
if (numResults ~= 0) then
|
if (numResults ~= 0) then
|
||||||
for i = 0, numResults-1 do
|
for i = 0, numResults-1 do
|
||||||
freq, cx, cy, cz = radar.getResult(i)
|
success, type, name, cx, cy, cz = radar.getResult(i)
|
||||||
|
|
||||||
drawContact(cx, cy, cz, freq, colors.red)
|
drawContact(cx, cy, cz, name, colors.red)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -106,11 +107,11 @@ function redraw()
|
||||||
textOut(w - 3, 1, "[X]", colors.white, colors.red)
|
textOut(w - 3, 1, "[X]", colors.white, colors.red)
|
||||||
|
|
||||||
paintutils.drawLine(1, h, w, h, colors.black)
|
paintutils.drawLine(1, h, w, h, colors.black)
|
||||||
local energy, energyMax = radar.getEnergyLevel()
|
local energy, energyMax = radar.energy()
|
||||||
textOut(4, h, "Energy: " .. energy .. " EU | Scan radius: " .. radius, colors.white, colors.black)
|
textOut(4, h, "Energy: " .. energy .. " EU | Scan radius: " .. radius, colors.white, colors.black)
|
||||||
end
|
end
|
||||||
|
|
||||||
radarX, radarY, radarZ = radar.pos()
|
radarX, radarY, radarZ = radar.position()
|
||||||
mrun = true
|
mrun = true
|
||||||
while (mrun) do
|
while (mrun) do
|
||||||
scanAndDraw()
|
scanAndDraw()
|
||||||
|
|
|
@ -139,7 +139,7 @@ function CalcNewCoords(cx, cy, cz)
|
||||||
elseif SData.Direction == 2 then
|
elseif SData.Direction == 2 then
|
||||||
res.y = res.y - RealDistance
|
res.y = res.y - RealDistance
|
||||||
end
|
end
|
||||||
local dx, dy, dz = warp.getOrientation()
|
local dx, dy, dz = ship.getOrientation()
|
||||||
if dx ~= 0 then
|
if dx ~= 0 then
|
||||||
if SData.Direction == 0 then
|
if SData.Direction == 0 then
|
||||||
res.x = res.x + (RealDistance * dx)
|
res.x = res.x + (RealDistance * dx)
|
||||||
|
@ -168,9 +168,9 @@ function ShowInfo()
|
||||||
ShowTitle(Title)
|
ShowTitle(Title)
|
||||||
Show("Core:")
|
Show("Core:")
|
||||||
Show(" x, y, z = "..X..", "..Y..", "..Z)
|
Show(" x, y, z = "..X..", "..Y..", "..Z)
|
||||||
local energy, energyMax = warp.getEnergyLevel()
|
local energy, energyMax = ship.energy()
|
||||||
Show(" Energy = " .. math.floor(100 * energy / energyMax) .. " % (" .. energy .. "EU)")
|
Show(" Energy = " .. math.floor(100 * energy / energyMax) .. " % (" .. energy .. "EU)")
|
||||||
local playersString, playersArray = warp.getAttachedPlayers()
|
local playersString, playersArray = ship.getAttachedPlayers()
|
||||||
Show(" Attached players = " .. playersString)
|
Show(" Attached players = " .. playersString)
|
||||||
Show("Dimensions:")
|
Show("Dimensions:")
|
||||||
Show(" Front, Right, Up = "..GFront..", "..GRight..", "..GUp)
|
Show(" Front, Right, Up = "..GFront..", "..GRight..", "..GUp)
|
||||||
|
@ -201,13 +201,13 @@ end
|
||||||
function Warp()
|
function Warp()
|
||||||
rs.setOutput(Alarm, false)
|
rs.setOutput(Alarm, false)
|
||||||
sleep(1)
|
sleep(1)
|
||||||
warp.direction(SData.Direction)
|
ship.direction(SData.Direction)
|
||||||
if IsInHyper then
|
if IsInHyper then
|
||||||
warp.mode(2)
|
ship.mode(2)
|
||||||
else
|
else
|
||||||
warp.mode(1)
|
ship.mode(1)
|
||||||
end
|
end
|
||||||
warp.jump()
|
ship.jump()
|
||||||
end
|
end
|
||||||
|
|
||||||
function SetDistance()
|
function SetDistance()
|
||||||
|
@ -233,7 +233,7 @@ function SetDistance()
|
||||||
if not IsInHyper then
|
if not IsInHyper then
|
||||||
SData.Distance = SData.Distance - RealDistance
|
SData.Distance = SData.Distance - RealDistance
|
||||||
end
|
end
|
||||||
warp.distance(SData.Distance)
|
ship.distance(SData.Distance)
|
||||||
CalcRealDistance()
|
CalcRealDistance()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -286,15 +286,15 @@ function SetDimensions()
|
||||||
term.write(" Down ("..GDown..") : ")
|
term.write(" Down ("..GDown..") : ")
|
||||||
GDown = tonumber(read())
|
GDown = tonumber(read())
|
||||||
term.write("Setting dimensions...")
|
term.write("Setting dimensions...")
|
||||||
warp.dim_positive(GFront, GRight, GUp)
|
ship.dim_positive(GFront, GRight, GUp)
|
||||||
warp.dim_negative(GBack, GLeft, GDown)
|
ship.dim_negative(GBack, GLeft, GDown)
|
||||||
weight = warp.getShipSize()
|
weight = ship.getShipSize()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Summon()
|
function Summon()
|
||||||
Clear()
|
Clear()
|
||||||
ShowTitle("<==== Summon players ====>")
|
ShowTitle("<==== Summon players ====>")
|
||||||
local playersString, playersArray = warp.getAttachedPlayers()
|
local playersString, playersArray = ship.getAttachedPlayers()
|
||||||
if playersArray == nil then
|
if playersArray == nil then
|
||||||
Show("- no players attached -")
|
Show("- no players attached -")
|
||||||
sleep(1.0)
|
sleep(1.0)
|
||||||
|
@ -312,10 +312,10 @@ function Summon()
|
||||||
term.write(":")
|
term.write(":")
|
||||||
local input = read()
|
local input = read()
|
||||||
if input == "" then
|
if input == "" then
|
||||||
warp.summonAll()
|
ship.summonAll()
|
||||||
else
|
else
|
||||||
input = tonumber(input)
|
input = tonumber(input)
|
||||||
warp.summon(input - 1)
|
ship.summon(input - 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -328,9 +328,9 @@ function JumpToBeacon()
|
||||||
rs.setOutput(Alarm, true)
|
rs.setOutput(Alarm, true)
|
||||||
if Confirm() then
|
if Confirm() then
|
||||||
rs.setOutput(Alarm, false)
|
rs.setOutput(Alarm, false)
|
||||||
warp.mode(4)
|
ship.mode(4)
|
||||||
warp.beaconFrequency(freq)
|
ship.beaconFrequency(freq)
|
||||||
warp.jump()
|
ship.jump()
|
||||||
end
|
end
|
||||||
rs.setOutput(Alarm, false)
|
rs.setOutput(Alarm, false)
|
||||||
end
|
end
|
||||||
|
@ -344,9 +344,9 @@ function JumpToGate()
|
||||||
rs.setOutput(Alarm, true)
|
rs.setOutput(Alarm, true)
|
||||||
if Confirm() then
|
if Confirm() then
|
||||||
rs.setOutput(Alarm, false)
|
rs.setOutput(Alarm, false)
|
||||||
warp.mode(6)
|
ship.mode(6)
|
||||||
warp.targetJumpgate(name)
|
ship.targetJumpgate(name)
|
||||||
warp.jump()
|
ship.jump()
|
||||||
end
|
end
|
||||||
rs.setOutput(Alarm, false)
|
rs.setOutput(Alarm, false)
|
||||||
end
|
end
|
||||||
|
@ -358,7 +358,7 @@ function SetShipName()
|
||||||
term.write("Enter ship name: ")
|
term.write("Enter ship name: ")
|
||||||
SData.Shipname = tostring(read())
|
SData.Shipname = tostring(read())
|
||||||
os.setComputerLabel(SData.Shipname)
|
os.setComputerLabel(SData.Shipname)
|
||||||
warp.coreFrequency(SData.Shipname)
|
ship.coreFrequency(SData.Shipname)
|
||||||
SaveData()
|
SaveData()
|
||||||
os.reboot()
|
os.reboot()
|
||||||
end
|
end
|
||||||
|
@ -377,14 +377,14 @@ end
|
||||||
Side = { "bottom", "top", "back", "left", "right" }
|
Side = { "bottom", "top", "back", "left", "right" }
|
||||||
for i = 1,5 do
|
for i = 1,5 do
|
||||||
if peripheral.getType(Side[i]) == "warpdriveShipController" then
|
if peripheral.getType(Side[i]) == "warpdriveShipController" then
|
||||||
warp = peripheral.wrap(Side[i])
|
ship = peripheral.wrap(Side[i])
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
warp = nil
|
ship = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if warp == nil then
|
if ship == nil then
|
||||||
ShowWarning("No ship controller detected")
|
ShowWarning("No ship controller detected")
|
||||||
os.pullEvent("key")
|
os.pullEvent("key")
|
||||||
os.reboot()
|
os.reboot()
|
||||||
|
@ -400,34 +400,34 @@ end
|
||||||
Title = "<JumpShip \""..SData.Shipname.."\">"
|
Title = "<JumpShip \""..SData.Shipname.."\">"
|
||||||
|
|
||||||
if SData.Summon then
|
if SData.Summon then
|
||||||
warp.summonAll()
|
ship.summonAll()
|
||||||
end
|
end
|
||||||
|
|
||||||
GFront, GRight, GUp = warp.dim_positive()
|
GFront, GRight, GUp = ship.dim_positive()
|
||||||
GBack, GLeft, GDown = warp.dim_negative()
|
GBack, GLeft, GDown = ship.dim_negative()
|
||||||
IsInHyper = warp.isInHyperspace()
|
IsInHyper = ship.isInHyperspace()
|
||||||
repeat
|
repeat
|
||||||
sleep(0.3)
|
sleep(0.3)
|
||||||
pos = warp.pos()
|
pos = ship.position()
|
||||||
until pos ~= nil
|
until pos ~= nil
|
||||||
print("Ship core detected...")
|
print("Ship core detected...")
|
||||||
X, Y, Z = warp.pos()
|
X, Y, Z = ship.position()
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
sleep(0.3)
|
sleep(0.3)
|
||||||
isAttached = warp.isAttached()
|
isAttached = ship.isAttached()
|
||||||
until isAttached
|
until isAttached
|
||||||
print("Ship core linked...")
|
print("Ship core linked...")
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
sleep(0.3)
|
sleep(0.3)
|
||||||
weight = warp.getShipSize()
|
weight = ship.getShipSize()
|
||||||
until weight ~= nil
|
until weight ~= nil
|
||||||
print("Ship weight updated...")
|
print("Ship weight updated...")
|
||||||
|
|
||||||
CalcRealDistance()
|
CalcRealDistance()
|
||||||
|
|
||||||
warp.mode(1)
|
ship.mode(1)
|
||||||
|
|
||||||
mainloop = true
|
mainloop = true
|
||||||
while(mainloop) do
|
while(mainloop) do
|
||||||
|
@ -471,8 +471,8 @@ while(mainloop) do
|
||||||
rs.setOutput(Alarm, true)
|
rs.setOutput(Alarm, true)
|
||||||
if Confirm() then
|
if Confirm() then
|
||||||
rs.setOutput(Alarm, false)
|
rs.setOutput(Alarm, false)
|
||||||
warp.mode(5)
|
ship.mode(5)
|
||||||
warp.jump()
|
ship.jump()
|
||||||
end
|
end
|
||||||
rs.setOutput(Alarm, false)
|
rs.setOutput(Alarm, false)
|
||||||
elseif keycode == 45 then
|
elseif keycode == 45 then
|
||||||
|
@ -488,6 +488,6 @@ if SData.Summon then
|
||||||
end
|
end
|
||||||
Clear()
|
Clear()
|
||||||
print("wish you good")
|
print("wish you good")
|
||||||
warp.mode(0)
|
ship.mode(0)
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
os.shutdown()
|
os.shutdown()
|
|
@ -19,12 +19,13 @@ if radius < 1 or radius > 9999 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
energy, energyMax = radar.getEnergyLevel()
|
energy, energyMax = radar.energy()
|
||||||
if energy < radius * radius then
|
if energy < radius * radius then
|
||||||
print("Low energy level... (" + energy + "/" + radius * radius + ")")
|
print("Low energy level... (" + energy + "/" + radius * radius + ")")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
radar.scanRadius(radius)
|
radar.radius(radius)
|
||||||
|
radar.start()
|
||||||
os.sleep(0.5)
|
os.sleep(0.5)
|
||||||
|
|
||||||
print("Scanning...")
|
print("Scanning...")
|
||||||
|
@ -40,8 +41,12 @@ print("took " .. seconds .. " seconds")
|
||||||
|
|
||||||
if count ~= nil and count > 0 then
|
if count ~= nil and count > 0 then
|
||||||
for i=0, count-1 do
|
for i=0, count-1 do
|
||||||
freq, x, y, z = radar.getResult(i)
|
success, type, name, x, y, z = radar.getResult(i)
|
||||||
print("Ship '" .. freq .. "' @ (" .. x .. " " .. y .. " " .. z .. ")")
|
if success then
|
||||||
|
print(type .. " " .. name .. " @ (" .. x .. " " .. y .. " " .. z .. ")")
|
||||||
|
else
|
||||||
|
print("Error " .. type)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print("Nothing was found =(")
|
print("Nothing was found =(")
|
||||||
|
|
|
@ -66,7 +66,7 @@ function drawContact(x, y, z, name, color)
|
||||||
end
|
end
|
||||||
|
|
||||||
function scanAndDraw()
|
function scanAndDraw()
|
||||||
local energy, energyMax = radar.getEnergyLevel()
|
local energy, energyMax = radar.energy()
|
||||||
if (energy < radius * radius) then
|
if (energy < radius * radius) then
|
||||||
hh = math.floor(h / 2)
|
hh = math.floor(h / 2)
|
||||||
hw = math.floor(w / 2)
|
hw = math.floor(w / 2)
|
||||||
|
@ -77,7 +77,8 @@ function scanAndDraw()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
radar.scanRadius(radius)
|
radar.radius(radius)
|
||||||
|
radar.start()
|
||||||
os.sleep(2)
|
os.sleep(2)
|
||||||
|
|
||||||
redraw()
|
redraw()
|
||||||
|
@ -86,9 +87,9 @@ function scanAndDraw()
|
||||||
|
|
||||||
if (numResults ~= 0) then
|
if (numResults ~= 0) then
|
||||||
for i = 0, numResults-1 do
|
for i = 0, numResults-1 do
|
||||||
freq, cx, cy, cz = radar.getResult(i)
|
success, type, name, cx, cy, cz = radar.getResult(i)
|
||||||
|
|
||||||
drawContact(cx, cy, cz, freq, 0xFF0000)
|
drawContact(cx, cy, cz, name, 0xFF0000)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -107,11 +108,11 @@ function redraw()
|
||||||
|
|
||||||
textOut(w - 3, 1, "[X]", 0xFFFFFF, 0xFF0000)
|
textOut(w - 3, 1, "[X]", 0xFFFFFF, 0xFF0000)
|
||||||
|
|
||||||
local energy, energyMax = radar.getEnergyLevel()
|
local energy, energyMax = radar.energy()
|
||||||
textOut(4, h, "Energy: " .. energy .. " EU | Scan radius: " .. radius, 0xFFFFFF, 0x000000)
|
textOut(4, h, "Energy: " .. energy .. " EU | Scan radius: " .. radius, 0xFFFFFF, 0x000000)
|
||||||
end
|
end
|
||||||
|
|
||||||
radarX, radarY, radarZ = radar.pos()
|
radarX, radarY, radarZ = radar.position()
|
||||||
|
|
||||||
while component.isAvailable("warpdriveRadar") do
|
while component.isAvailable("warpdriveRadar") do
|
||||||
scanAndDraw()
|
scanAndDraw()
|
||||||
|
|
Loading…
Reference in a new issue