Merge remote-tracking branch 'origin/MC1.7' into MC1.10

This commit is contained in:
Unknown 2018-06-03 11:00:48 +02:00
commit d3b9c45e9e
18 changed files with 690 additions and 336 deletions

165
gradlew vendored

File diff suppressed because one or more lines are too long

View file

@ -7,18 +7,19 @@ import java.util.HashMap;
public enum EnumStarMapEntryType implements IStringSerializable {
UNDEFINED (0, "-undefined-"),
SHIP (1, "ship" ), // a ship core
JUMPGATE (2, "jumpgate" ), // a jump gate
PLANET (3, "planet" ), // a planet (a transition plane allowing to move to another dimension)
STAR (4, "star" ), // a star
STRUCTURE (5, "structure" ), // a structure from WorldGeneration (moon, asteroid field, etc.)
WARP_ECHO (6, "warp_echo" ), // remains of a warp
ACCELERATOR(7, "accelerator"), // an accelerator setup
TRANSPORTER(8, "transporter"); // a transporter room
UNDEFINED (0, "-undefined-", true ),
SHIP (1, "ship" , true ), // a ship core
JUMPGATE (2, "jumpgate" , true ), // a jump gate
PLANET (3, "planet" , true ), // a planet (a transition plane allowing to move to another dimension)
STAR (4, "star" , true ), // a star
STRUCTURE (5, "structure" , true ), // a structure from WorldGeneration (moon, asteroid field, etc.)
WARP_ECHO (6, "warp_echo" , true ), // remains of a warp
ACCELERATOR(7, "accelerator", false), // an accelerator setup
TRANSPORTER(8, "transporter", true ); // a transporter room
private final int id;
private final String name;
private final boolean hasRadarEcho;
// cached values
public static final int length;
@ -31,9 +32,10 @@ public enum EnumStarMapEntryType implements IStringSerializable {
}
}
EnumStarMapEntryType(final int id, final String name) {
EnumStarMapEntryType(final int id, final String name, final boolean hasRadarEcho) {
this.id = id;
this.name = name;
this.hasRadarEcho = hasRadarEcho;
}
public int getId() {
@ -49,4 +51,8 @@ public enum EnumStarMapEntryType implements IStringSerializable {
public static EnumStarMapEntryType getByName(final String name) {
return mapNames.get(name);
}
public boolean hasRadarEcho() {
return hasRadarEcho;
}
}

View file

@ -304,7 +304,7 @@ public class StarMapRegistry {
final int radius2 = radius * radius;
for (final Map.Entry<Integer, CopyOnWriteArraySet<StarMapRegistryItem>> entryDimension : registry.entrySet()) {
for (final StarMapRegistryItem starMapRegistryItem : entryDimension.getValue()) {
if (starMapRegistryItem.type == EnumStarMapEntryType.ACCELERATOR) {
if (!starMapRegistryItem.type.hasRadarEcho()) {
continue;
}
final Vector3 vectorItem = starMapRegistryItem.getUniversalCoordinates(tileEntity.getWorld().isRemote);

View file

@ -27,6 +27,7 @@ local styles = {
good = { front = colors.lime , back = colors.lightGray },
bad = { front = colors.red , back = colors.lightGray },
disabled = { front = colors.gray , back = colors.lightGray },
help = { front = colors.white , back = colors.blue },
header = { front = colors.orange , back = colors.black },
control = { front = colors.white , back = colors.blue },
selected = { front = colors.black , back = colors.lightBlue },
@ -415,8 +416,8 @@ local function input_readInteger(currentValue)
term.setCursorBlink(true)
repeat
w.status_tick()
w.setColorNormal()
w.setCursorPos(x, y)
w.setColorNormal()
w.write(input .. " ")
input = string.sub(input, -9)
w.setCursorPos(x + #input, y)
@ -519,8 +520,8 @@ local function input_readText(currentValue)
repeat
w.status_tick()
-- update display clearing extra characters
w.setColorNormal()
w.setCursorPos(x, y)
w.setColorNormal()
w.write(w.format_string(input, 37))
-- truncate input and set caret position
input = string.sub(input, -36)
@ -637,8 +638,8 @@ local function input_readEnum(currentValue, list, toValue, toDescription, noValu
term.setCursorBlink(true)
repeat
w.status_tick()
w.setColorNormal()
w.setCursorPos(x, y)
w.setColorNormal()
if #list == 0 then
inputKey = nil
end
@ -662,8 +663,8 @@ local function input_readEnum(currentValue, list, toValue, toDescription, noValu
end
w.setColorNormal()
w.write(input .. " ")
w.setColorDisabled()
w.setCursorPos(1, y + 1)
w.setColorDisabled()
w.write(inputDescription .. " ")
local params = { os.pullEventRaw() }
@ -923,7 +924,11 @@ local function data_setName()
-- ask for a new name
w.page_begin("<==== Set " .. component .. " name ====>")
w.writeLn("")
w.setCursorPos(1, 4)
w.setColorHelp()
w.writeFullLine(" Press enter to validate.")
w.setCursorPos(1, 3)
w.setColorNormal()
w.write("Enter " .. component .. " name: ")
data_name = w.input_readText(data_name)

View file

@ -47,14 +47,14 @@ function lhc_boot(isDetailed)
lhc_controlChannels[controlChannel] = "true"
countParameters = countParameters + 1
elseif isDetailed then
w.setColorWarning();
w.setColorWarning()
w.writeLn("Error " .. x)
w.setColorNormal();
w.setColorNormal()
w.sleep(0.5)
end
end
elseif isDetailed then
w.setColorWarning();
w.setColorWarning()
w.writeLn("No control point detected!")
w.sleep(0.5)
end
@ -85,24 +85,24 @@ function lhc_boot(isDetailed)
lhc_parameters[index] = { controlChannel, isEnabled, threshold, description }
index = index + 1
elseif isDetailed then
w.setColorWarning();
w.setColorWarning()
if controlChannelCheck ~= nil then
w.writeLn("Error " .. controlChannelCheck)
else
w.writeLn("Error nil?")
end
w.sleep(0.5)
w.setColorNormal();
w.setColorNormal()
end
if controlChannel ~= controlChannelCheck and isDetailed then
w.setColorWarning();
w.setColorWarning()
w.writeLn("Error: requested " .. controlChannel .. ", received " .. controlChannelCheck)
w.sleep(0.5)
w.setColorNormal();
w.setColorNormal()
end
end
elseif isDetailed then
w.setColorWarning();
w.setColorWarning()
w.writeLn("No control channel detected!")
w.sleep(0.5)
end
@ -127,18 +127,42 @@ function lhc_page_parameter()
end
end
end
w.writeLn("")
local _, y = w.getCursorPos()
-- description
w.setCursorPos(1, y + 3)
w.setColorHelp()
w.writeFullLine(" Press enter to validate.")
w.setCursorPos(1, y)
w.setColorNormal()
w.writeLn("Current description is '" .. description .. "'")
w.write("Enter a description: ")
description = w.input_readText(description)
w.writeLn("")
w.setCursorPos(1, y + 3)
w.setColorNormal()
w.writeFullLine(" ")
-- threshold
w.setCursorPos(1, y + 7)
w.setColorHelp()
w.writeFullLine(" Press enter to validate.")
w.setCursorPos(1, y + 4)
w.setColorNormal()
w.writeLn("Current threshold is " .. w.format_integer(threshold * 100) .. "%")
w.write("Enter parameter threshold: ")
local new_threshold = w.input_readInteger(threshold * 100) / 100
threshold = math.min(2.0, math.max(0.0, new_threshold))
lhc_parameters[indexSelected] = { controlChannel, isEnabled, threshold, description }
accelerator.parameter(controlChannel, isEnabled, threshold, description)
w.setCursorPos(1, y + 7)
w.setColorNormal()
w.writeFullLine(" ")
end
lhc_parameter_indexSelected = 1
@ -212,45 +236,45 @@ function lhc_page()
w.write(" Controller is ")
if isEnabled then
w.setColorGood();
w.setColorGood()
w.writeLn("Enabled")
else
w.setColorBad();
w.setColorBad()
w.writeLn("Disabled")
end
local energy, energyMax = accelerator.energy()
if energy == nil then energy = 0 end
if energyMax == nil or energyMax == 0 then energyMax = 1 end
w.setColorNormal();
w.setColorNormal()
w.write(" Energy level is ")
if isPowered then
w.setColorGood();
w.setColorGood()
elseif isEnabled then
w.setColorBad();
w.setColorBad()
else
w.setColorDisabled();
w.setColorDisabled()
end
w.writeLn(math.floor(energy / energyMax * 100) .. " % (" .. energy .. " EU)")
-- w.writeLn("")
w.setColorNormal();
w.setColorNormal()
w.write(" Magnets temperature is ")
if temperatureCurrent_K <= temperatureTarget_K then
w.setColorGood();
w.setColorGood()
elseif isEnabled then
w.setColorBad();
w.setColorBad()
else
w.setColorDisabled();
w.setColorDisabled()
end
w.write(string.format("%.1f K", math.floor(temperatureCurrent_K * 10) / 10))
w.setColorNormal();
w.setColorNormal()
w.writeLn(". Target is " .. temperatureTarget_K .. " K")
-- w.writeLn("")
w.write("Parameters: ")
if #lhc_parameters == 0 then
w.setColorDisabled();
w.setColorDisabled()
w.writeLn("")
w.writeCentered(" -no valid node detected-")
else

View file

@ -21,7 +21,7 @@ if cloakingCore == nil or cloakingCore.interfaced() == nil then
else
cloakingCore.tier(1)
cloakingCore.enable(true)
local isValid, message = cloakingCore.isAssemblyValid()
local isValid, message = cloakingCore.isAssemblyValid()
if isValid then
term.setBackgroundColor(colors.lime)
term.setTextColor(colors.blue)

View file

@ -124,29 +124,28 @@ function reactor_page()
w.write(w.format_integer(energy[3]) .. " RF/t")
end
w.setColorNormal()
w.setCursorPos(1, 9)
w.setColorNormal()
w.write("Activated: ")
local isEnabled = reactor.enable()
if isEnabled then w.setColorSuccess() else w.setColorNormal() end
w.write(w.format_boolean(isEnabled, "YES", "no"))
end
w.setCursorPos(30, 2)
if #reactorlasers == 0 then
w.setColorDisabled()
w.setCursorPos(30, 2)
w.write("Lasers not detected")
else
w.setColorNormal()
w.setCursorPos(30, 2)
w.write("Lasers")
for key, reactorlaser in pairs(reactorlasers) do
local side = reactorlaser.side
if side ~= nil then
side = side % 4
w.setColorNormal()
w.setCursorPos(4, 3 + side)
w.setColorNormal()
w.write("Side " .. w.format_integer(side) .. ":")
w.setCursorPos(30, 3 + side)
local energy = reactorlaser.wrap.energy()
@ -162,8 +161,8 @@ function reactor_page()
end
end
w.setColorNormal()
w.setCursorPos(1, 10)
w.setColorNormal()
w.write(" -----------------------------------------------")
w.setCursorPos(1, 11)
w.write("Output mode : ")
@ -177,14 +176,14 @@ function reactor_page()
else
w.write("rated at " .. reactor_rate .. " RF")
end
w.setColorNormal()
w.setCursorPos( 1, 12)
w.setColorNormal()
w.write("Target stability: " .. reactor_targetStability .. "%")
w.setCursorPos(30, 12)
w.write("Laser amount: " .. reactor_laserAmount)
w.setColorControl()
w.setCursorPos(1, 14)
w.setColorControl()
w.writeFullLine(" Start/stoP reactor (S/P), Use lasers (L)")
w.writeFullLine(" Output mode (O), Configuration (C)")
w.writeFullLine(" Target stability (+/-), Laser amount (U/J)")
@ -272,9 +271,9 @@ function reactor_pulse(output)
w.write(w.format_float(stability, 5) .. " %")
end
w.setColorNormal()
local energy = { reactor.energy() }
w.setCursorPos(12, 7)
w.setColorNormal()
if energy[2] ~= nil then
w.write(w.format_integer(energy[1], 10))
w.setCursorPos(39, 7)
@ -320,27 +319,50 @@ function reactor_config()
w.setColorDisabled()
w.write("Reactor not detected")
else
w.setColorNormal()
-- reactor output rate
w.setCursorPos(1, 6)
w.setColorHelp()
w.writeFullLine(" Enter a positive number.")
w.setCursorPos(1, 4)
w.setColorNormal()
w.write("Reactor output rate (" .. w.format_integer(reactor_rate) .. " RF): ")
reactor_rate = w.input_readInteger(reactor_rate)
reactor_setMode()
w.setCursorPos(1, 5)
w.write("Reactor output rate set")
w.setCursorPos(1, 6)
w.writeFullLine(" ")
-- laser amount
w.setCursorPos(1, 9)
w.setColorHelp()
w.writeFullLine(" Enter a positive number.")
w.setCursorPos(1, 7)
w.setColorNormal()
w.write("Laser energy level (" .. w.format_integer(reactor_laserAmount) .. "): ")
reactor_laserAmount = w.input_readInteger(reactor_laserAmount)
reactor_setLaser()
w.setCursorPos(1, 8)
w.write("Laser energy level set")
w.setCursorPos(1, 9)
w.writeFullLine(" ")
-- target stability
w.setCursorPos(1, 12)
w.setColorHelp()
w.writeFullLine(" Enter a positive number.")
w.setCursorPos(1, 10)
w.setColorNormal()
w.write("Reactor target stability (" .. w.format_integer(reactor_targetStability) .. "%): ")
reactor_targetStability = w.input_readInteger(reactor_targetStability)
reactor_setTargetStability()
w.setCursorPos(1, 11)
w.write("Reactor target stability set")
w.setCursorPos(1, 12)
w.writeFullLine(" ")
end
reactor_configPageLoaded = false
end

View file

@ -219,18 +219,18 @@ function ffield_projector_page()
w.write(" ")
end
local projector = ffield_projector_get(indexCurrent)
local description = ffield_projector_getDescription(projector);
local description = ffield_projector_getDescription(projector)
w.write(description)
w.writeLn("")
end
end
w.setColorNormal()
w.setCursorPos(1, 14)
w.setColorNormal()
w.write(" -----------------------------------------------")
w.setColorControl()
w.setCursorPos(1, 15)
w.setColorControl()
w.writeFullLine(" Start/stoP all force field projectors (S/P)")
w.writeFullLine(" Configure (C) or togglE (E) selected projector")
w.writeFullLine(" select force field projector (Up, Down)")
@ -243,14 +243,17 @@ function ffield_projector_config()
end
w.page_begin(w.data_getName() .. " - Projector configuration")
w.setColorNormal()
w.setCursorPos(1, 2)
w.setColorNormal()
projector.position.x, projector.position.y, projector.position.z = projector.device.position()
w.write("Projector @ " .. w.format_integer(projector.position.x, 7) .. " " .. w.format_integer(projector.position.y, 3) .. " " .. w.format_integer(projector.position.z, 7))
-- name
w.setColorNormal()
w.setCursorPos(1, 4)
w.setColorHelp()
w.writeFullLine(" Press enter to validate.")
w.setCursorPos(1, 3)
w.setColorNormal()
w.writeLn("Name (" .. projector.name .. "):")
projector.name = w.input_readText(projector.name)
w.setCursorPos(1, 3)
@ -263,12 +266,12 @@ function ffield_projector_config()
-- beam frequency
projector.beamFrequency = projector.device.beamFrequency()
w.setCursorPos(1, 6)
w.setColorDisabled()
w.write(" Valid values are 0 to 65000 ")
w.setColorNormal()
w.setColorHelp()
w.writeFullLine(" Enter a number between 0 and 65000.")
local frequency
repeat
w.setCursorPos(1, 5)
w.setColorNormal()
w.clearLine()
w.write("Beam frequency (" .. w.format_integer(projector.beamFrequency, 5) .. "): ")
frequency = w.input_readInteger(projector.beamFrequency)
@ -304,31 +307,30 @@ function ffield_config_xyz(yCursor, title, unit, help, method, factor)
z = factor * z
w.write(title .. " is currently set to " .. w.format_integer(x, 4) .. unit .. " " .. w.format_integer(y, 4) .. unit .. " " .. w.format_integer(z, 4) .. unit)
w.setColorControl()
w.setCursorPos(1, 16)
w.setColorHelp()
w.writeFullLine(" Enter X " .. help)
w.setColorNormal()
w.setCursorPos(1, yCursor + 3)
w.setColorNormal()
w.write(title .. " along X axis (" .. w.format_integer(x) .. "): ")
x = w.input_readInteger(x)
w.setColorNormal()
w.setColorControl()
w.setCursorPos(1, 16)
w.setColorHelp()
w.writeFullLine(" Enter Y " .. help)
w.setColorNormal()
w.setCursorPos(1, yCursor + 4)
w.setColorNormal()
w.write(title .. " along Y axis (" .. w.format_integer(y) .. "): ")
y = w.input_readInteger(y)
w.setColorControl()
w.setCursorPos(1, 16)
w.setColorHelp()
w.writeFullLine(" Enter Z " .. help)
w.setColorNormal()
w.setCursorPos(1, yCursor + 5)
w.setColorNormal()
w.write(title .. " along Z axis (" .. w.format_integer(z) .. "): ")
z = w.input_readInteger(z)
@ -339,8 +341,8 @@ function ffield_config_xyz(yCursor, title, unit, help, method, factor)
x = factor * x
y = factor * y
z = factor * z
w.setColorNormal()
w.setCursorPos(1, yCursor)
w.setColorNormal()
w.write(title .. " set to " .. w.format_integer(x, 4) .. unit .. " " .. w.format_integer(y, 4) .. unit .. " " .. w.format_integer(z, 4) .. unit)
w.setCursorPos(1, yCursor + 1)
w.clearLine()
@ -467,18 +469,18 @@ function ffield_relay_page()
w.write(" ")
end
local relay = ffield_relay_get(indexCurrent)
local description = ffield_relay_getDescription(relay);
local description = ffield_relay_getDescription(relay)
w.write(description)
w.writeLn("")
end
end
w.setColorNormal()
w.setCursorPos(1, 14)
w.setColorNormal()
w.write(" -----------------------------------------------")
w.setColorControl()
w.setCursorPos(1, 15)
w.setColorControl()
w.writeFullLine(" Start/stoP all force field relays (S/P)")
w.writeFullLine(" Configure (C) or togglE (E) selected relay")
w.writeFullLine(" select force field relay (Up, Down)")
@ -491,14 +493,17 @@ function ffield_relay_config()
end
w.page_begin(w.data_getName() .. " - Relay configuration")
w.setColorNormal()
w.setCursorPos(1, 2)
w.setColorNormal()
relay.position.x, relay.position.y, relay.position.z = relay.device.position()
w.write("Relay @ " .. w.format_integer(relay.position.x, 7) .. " " .. w.format_integer(relay.position.y, 3) .. " " .. w.format_integer(relay.position.z, 7))
-- name
w.setColorNormal()
w.setCursorPos(1, 4)
w.setColorHelp()
w.writeFullLine(" Press enter to validate.")
w.setCursorPos(1, 3)
w.setColorNormal()
w.writeLn("Name (" .. relay.name .. "):")
relay.name = w.input_readText(relay.name)
w.setCursorPos(1, 3)
@ -511,12 +516,12 @@ function ffield_relay_config()
-- beam frequency
relay.beamFrequency = relay.device.beamFrequency()
w.setCursorPos(1, 6)
w.setColorDisabled()
w.write(" Valid values are 0 to 65000 ")
w.setColorNormal()
w.setColorHelp()
w.writeFullLine(" Enter a number between 0 and 65000.")
local frequency
repeat
w.setCursorPos(1, 5)
w.setColorNormal()
w.clearLine()
w.write("Beam frequency (" .. w.format_integer(relay.beamFrequency, 5) .. "): ")
frequency = w.input_readInteger(relay.beamFrequency)

View file

@ -1548,8 +1548,8 @@ function radar_key(keycode)
radar_drawMap()
return true
elseif keycode == 199 then -- home
data.radar_offsetX = 0;
data.radar_offsetY = 0;
data.radar_offsetX = 0
data.radar_offsetY = 0
data.radar_scale = 20
for i = 0, #data.radar_results - 1 do
data.radar_scale = math.max(data.radar_scale, math.max(math.abs(radar_x - data.radar_results[i].x), math.abs(radar_z - data.radar_results[i].z)))
@ -1559,22 +1559,22 @@ function radar_key(keycode)
radar_drawMap()
return true
elseif keycode == 203 then -- left
data.radar_offsetX = data.radar_offsetX - 0.20 * data.radar_scale;
data.radar_offsetX = data.radar_offsetX - 0.20 * data.radar_scale
data_save()
radar_drawMap()
return true
elseif keycode == 205 then -- right
data.radar_offsetX = data.radar_offsetX + 0.20 * data.radar_scale;
data.radar_offsetX = data.radar_offsetX + 0.20 * data.radar_scale
data_save()
radar_drawMap()
return true
elseif keycode == 200 then -- up
data.radar_offsetY = data.radar_offsetY - 0.20 * data.radar_scale;
data.radar_offsetY = data.radar_offsetY - 0.20 * data.radar_scale
data_save()
radar_drawMap()
return true
elseif keycode == 208 then -- down
data.radar_offsetY = data.radar_offsetY + 0.20 * data.radar_scale;
data.radar_offsetY = data.radar_offsetY + 0.20 * data.radar_scale
data_save()
radar_drawMap()
return true
@ -1742,7 +1742,7 @@ function radar_scan()
end
function radar_scanDone()
local numResults = radar.getResultsCount();
local numResults = radar.getResultsCount()
data.radar_results = {}
if (numResults ~= 0) then
for i = 0, numResults do
@ -1785,14 +1785,14 @@ function draw_warning(monitor, text)
else
screenWidth, screenHeight = monitor.getSize()
end
local centerX = math.floor(screenWidth / 2);
local centerY = math.floor(screenHeight / 2);
local halfWidth = math.ceil(string.len(text) / 2);
local centerX = math.floor(screenWidth / 2)
local centerY = math.floor(screenHeight / 2)
local halfWidth = math.ceil(string.len(text) / 2)
local blank = string.sub(" ", - (string.len(text) + 2))
draw_text(monitor, centerX - halfWidth - 1, centerY - 1, blank, colors.white, colors.red);
draw_text(monitor, centerX - halfWidth - 1, centerY , " " .. text .. " ", colors.white, colors.red);
draw_text(monitor, centerX - halfWidth - 1, centerY + 1, blank, colors.white, colors.red);
draw_text(monitor, centerX - halfWidth - 1, centerY - 1, blank, colors.white, colors.red)
draw_text(monitor, centerX - halfWidth - 1, centerY , " " .. text .. " ", colors.white, colors.red)
draw_text(monitor, centerX - halfWidth - 1, centerY + 1, blank, colors.white, colors.red)
end
function draw_centeredText(monitor, y, text)
@ -1802,9 +1802,9 @@ function draw_centeredText(monitor, y, text)
else
screenWidth, screenHeight = monitor.getSize()
end
local x = math.floor(screenWidth / 2 - string.len(text) / 2 + 0.5);
local x = math.floor(screenWidth / 2 - string.len(text) / 2 + 0.5)
draw_text(monitor, x, y, text, nil, nil);
draw_text(monitor, x, y, text, nil, nil)
end
function radar_drawContact(monitor, contact)
@ -1918,7 +1918,7 @@ function radar_timerEvent()
radar_waitingNextScan = false
radar_scan() -- will restart timer
else
local numResults = radar.getResultsCount();
local numResults = radar.getResultsCount()
if numResults ~= -1 then
radar_scanDone()
if data.radar_autoscan then
@ -1978,7 +1978,7 @@ for key,side in pairs(sides) do
table.insert(cloakingcores, peripheral.wrap(side))
elseif componentType == "warpdriveRadar" then
Write("wrapping!")
radar = peripheral.wrap(side);
radar = peripheral.wrap(side)
elseif componentType == "monitor" then
Write("wrapping!")
lmonitor = peripheral.wrap(side)

View file

@ -116,7 +116,7 @@ function ship_boot()
ship_shipSize = ship.getShipSize()
w.sleep(0.05)
timeout = timeout - 1
until ship_shipSize ~= nil or timeout < 0
until (ship_shipSize ~= nil and ship_shipSize ~= 0) or timeout < 0
if timeout < 0 then
w.setColorWarning()
w.writeLn("failed")
@ -238,35 +238,40 @@ function ship_warp()
end
function ship_page_setMovement()
-- force manual jump so we get proper max jump distance
ship.enable(false)
ship.command("MANUAL")
local success, maxJumpDistance = ship.getMaxJumpDistance()
if success ~= true then
w.status_showWarning("" .. maxJumpDistance)
return
end
w.page_begin("<==== Set ship movement ====>")
w.setColorNormal()
w.setCursorPos(1, 3)
w.setColorNormal()
ship_writeMovement("Current movement is ")
w.setCursorPos(1, 5)
ship_movement[1] = ship_page_setDistanceAxis(4, "Forward/back", "Forward", "Backward", ship_movement[1], math.abs(ship_front + ship_back + 1))
ship_movement[2] = ship_page_setDistanceAxis(6, "Up/down" , "Up" , "Down" , ship_movement[2], math.abs(ship_up + ship_down + 1))
ship_movement[3] = ship_page_setDistanceAxis(8, "Right/left" , "Right" , "Left" , ship_movement[3], math.abs(ship_left + ship_right + 1))
ship_movement[1] = ship_page_setDistanceAxis(4, "Forward/back", "Forward", "Backward", ship_movement[1], math.abs(ship_front + ship_back + 1), maxJumpDistance)
ship_movement[2] = ship_page_setDistanceAxis(6, "Up/down" , "Up" , "Down" , ship_movement[2], math.abs(ship_up + ship_down + 1), maxJumpDistance)
ship_movement[3] = ship_page_setDistanceAxis(8, "Right/left" , "Right" , "Left" , ship_movement[3], math.abs(ship_left + ship_right + 1), maxJumpDistance)
ship_movement = { ship.movement(ship_movement[1], ship_movement[2], ship_movement[3]) }
ship_updateMovementStats()
end
function ship_page_setDistanceAxis(line, axis, positive, negative, userEntry, shipLength)
local success, maxJumpDistance = ship.getMaxJumpDistance()
if success ~= true then
w.status_showSuccess("" .. maxJumpDistance)
maxJumpDistance = 0
end
function ship_page_setDistanceAxis(line, axis, positive, negative, userEntry, shipLength, maxJumpDistance)
local maximumDistance = math.floor(shipLength + maxJumpDistance)
w.setColorControl()
w.setCursorPos(1, line + 2)
w.writeFullLine("Enter between " .. math.floor( shipLength + 1) .. " and " .. maximumDistance .. " to move " .. positive)
w.writeFullLine("Enter 0 to keep position on this axis")
w.writeFullLine("Enter between " .. -maximumDistance .. " and " .. math.floor(-shipLength - 1) .. " to move " .. negative)
w.setColorHelp()
w.writeFullLine(" Enter between " .. math.floor( shipLength + 1) .. " and " .. maximumDistance .. " to move " .. positive .. ".")
w.writeFullLine(" Enter 0 to keep position on this axis.")
w.writeFullLine(" Enter between " .. -maximumDistance .. " and " .. math.floor(-shipLength - 1) .. " to move " .. negative .. ".")
w.setColorNormal()
repeat
w.setCursorPos(1, line)
w.setColorNormal()
w.write(axis .. " movement: ")
userEntry = w.input_readInteger(userEntry)
if userEntry ~= 0 and (math.abs(userEntry) <= shipLength or math.abs(userEntry) > maximumDistance) then
@ -287,11 +292,11 @@ function ship_page_setRotation()
local inputAbort = false
local drun = true
w.page_begin("<==== Set ship rotation ====>")
w.setCursorPos(1, 15)
w.setColorControl()
w.writeFullLine(" Select ship rotation (Up, Down, Left, Right)")
w.writeFullLine(" Select Front to keep current orientation")
w.writeFullLine(" Press Enter to save your selection")
w.setCursorPos(1, 8)
w.setColorHelp()
w.writeFullLine(" Select ship rotation (Up, Down, Left, Right).")
w.writeFullLine(" Select Front to keep current orientation.")
w.writeFullLine(" Press Enter to save your selection.")
repeat
w.setCursorPos(1, 3)
w.setColorNormal()
@ -327,11 +332,11 @@ end
function ship_page_setDimensions()
w.page_begin("<==== Set ship dimensions ====>")
w.setCursorPos(1, 14)
w.setColorControl()
w.writeFullLine(" Enter ship size in blocks (0-9)")
w.writeFullLine(" First block next to Ship counts as 1")
w.writeFullLine(" Ship controller counts as 'Front = 1'")
w.writeFullLine(" Press Enter to save your selection")
w.setColorHelp()
w.writeFullLine(" Enter ship size in blocks (0-9).")
w.writeFullLine(" First block next to Ship counts as 1.")
w.writeFullLine(" Ship controller counts as 'Front = 1'.")
w.writeFullLine(" Press Enter to save your selection.")
w.setCursorPos(1, 3)
w.setColorNormal()
@ -360,8 +365,8 @@ function ship_page_summon() -- no longer used
if stringPlayers == "" then
w.writeLn("~ no players registered ~")
w.writeLn("")
w.setColorControl()
w.writeFullLine("Press enter to exit")
w.setColorHelp()
w.writeFullLine(" Press enter to exit.")
w.setColorNormal()
w.input_readInteger("")
return
@ -370,9 +375,9 @@ function ship_page_summon() -- no longer used
for i = 1, #arrayPlayers do
w.writeLn(i .. ". " .. arrayPlayers[i])
end
w.setColorControl()
w.writeFullLine("Enter player number")
w.writeFullLine("or press enter to summon everyone")
w.setColorHelp()
w.writeFullLine(" Enter player number")
w.writeFullLine(" or press enter to summon everyone.")
w.setColorNormal()
w.write(":")
@ -393,9 +398,9 @@ function ship_page_jumpToGate()
w.writeLn("Your ship should be already inside a jumpgate")
w.setCursorPos(1, 16)
w.setColorControl()
w.writeFullLine("Enter target jumpgate name (a-z, 0-9)")
w.writeFullLine("Press enter to save jumpgate name")
w.setColorHelp()
w.writeFullLine(" Enter target jumpgate name (a-z, 0-9).")
w.writeFullLine(" Press enter to save jumpgate name.")
w.setCursorPos(1, 5)
w.setColorNormal()
@ -547,7 +552,7 @@ function ship_page_crew()
w.setCursorPos(1, 16)
w.setColorControl()
w.writeFullLine(" Summon all crew (S), Toggle summon after jump (T)")
w.writeFullLine(" select crew (Up, Down), summon selected crew (enter)")
w.writeFullLine(" select crew (Up, Down), summon slctd crew (enter)")
end
function ship_key_crew(character, keycode)

View file

@ -63,21 +63,21 @@ function transporter_page()
w.setColorDisabled()
w.write("Transporter core not detected")
else
w.setColorDisabled()
w.setCursorPos(1, 2)
w.setColorDisabled()
local _, signature = transporter.transporterName()
if (signature ~= nil) then
w.writeCentered(2, "Signature is " .. signature)
end
w.setColorNormal()
w.setCursorPos(1, 3)
w.setColorNormal()
w.write("Beam frequency = ")
local beamFrequency = transporter.beamFrequency()
w.write(w.format_integer(beamFrequency, 6))
w.setColorNormal()
w.setCursorPos(1, 4)
w.setColorNormal()
w.write("Remote location = ")
local remoteLocation = { transporter.remoteLocation() }
if remoteLocation[3] ~= nil then
@ -88,13 +88,13 @@ function transporter_page()
w.write("-not defined-")
end
w.setColorNormal()
w.setCursorPos(1, 6)
w.setColorNormal()
local energyFactor_PC = transporter.energyFactor() * 100
w.write("Energy factor = " .. w.format_float(math.floor(energyFactor_PC * 10) / 10, 6) .. " %")
w.setColorNormal()
w.setCursorPos(1, 7)
w.setColorNormal()
w.write("Energy required = ")
local energyAcquiring, energyEnergizing = transporter.getEnergyRequired()
if energyAcquiring ~= nil then
@ -103,18 +103,18 @@ function transporter_page()
w.write("???")
end
w.setColorNormal()
w.setCursorPos(1, 8)
w.setColorNormal()
w.write("Energy stored = ")
local energy = { transporter.energy() }
transporter_page_writeEnergy(energy)
w.setColorNormal()
w.setCursorPos(1, 9)
w.setColorNormal()
w.write(" -----------------------------------------------")
w.setColorNormal()
w.setCursorPos(1, 10)
w.setColorNormal()
w.write("Room is ")
local isEnabled = transporter.enable()
if isEnabled then w.setColorSuccess() else w.setColorNormal() end
@ -122,8 +122,8 @@ function transporter_page()
w.setColorNormal()
w.write(".")
w.setColorNormal()
w.setCursorPos(28, 10)
w.setColorNormal()
w.write("Locking is ")
local isLockRequested = transporter.lock()
if isLockRequested then w.setColorSuccess() else w.setColorNormal() end
@ -131,14 +131,14 @@ function transporter_page()
w.setColorNormal()
w.write(".")
w.setColorNormal()
w.setCursorPos(1, 11)
w.setColorNormal()
w.write("Lock strength is ")
local lockStrength = transporter.getLockStrength()
transporter_page_writeLockStrength(lockStrength)
w.setColorNormal()
w.setCursorPos(28, 11)
w.setColorNormal()
w.write("Energize is ")
local isEnergizeRequested = transporter.energize()
if isEnergizeRequested then w.setColorSuccess() else w.setColorNormal() end
@ -146,8 +146,8 @@ function transporter_page()
w.setColorNormal()
w.write(".")
w.setColorNormal()
w.setCursorPos(1, 13)
w.setColorNormal()
w.write("Status is ")
local _, state, _, _, isJammed = transporter.state()
if isJammed then
@ -158,15 +158,15 @@ function transporter_page()
w.write(".")
end
w.setColorControl()
w.setCursorPos(1, 16)
w.setColorControl()
w.writeFullLine(" Start/stoP transporter (S/P), Configuration (C)")
w.writeFullLine(" Lock (L), Energize (E), Energy factor (+/-)")
end
function transporter_page_writeEnergy(energy)
w.setColorNormal()
w.setCursorPos(19, 8)
w.setColorNormal()
if energy[2] ~= nil then
w.write(w.format_integer(energy[1], 7) .. " / " .. energy[2] .. " EU ")
else
@ -245,17 +245,23 @@ function transporter_config()
w.setColorDisabled()
w.write("Transporter core not detected")
else
w.setColorNormal()
w.setCursorPos(1, 6)
w.setColorHelp()
w.writeFullLine(" Enter a number between 100 and 1000 %.")
w.setCursorPos(1, 4)
w.setColorNormal()
local energyFactor_PC = transporter.energyFactor() * 100
w.write("Energy factor (" .. math.floor(energyFactor_PC * 10) / 10 .. " %): ")
energyFactor_PC = w.input_readInteger(energyFactor_PC)
energyFactor_PC = transporter.energyFactor(energyFactor_PC / 100) * 100
w.setCursorPos(1, 5)
w.write("Energy factor set to " .. math.floor(energyFactor_PC * 10) / 10 .. " %")
w.writeLn("Energy factor set to " .. math.floor(energyFactor_PC * 10) / 10 .. " %")
w.writeFullLine(" ")
w.setColorNormal()
w.setCursorPos(1, 7)
w.setColorNormal()
local remoteLocation = { transporter.remoteLocation() }
local remoteLocation_default = "-"
if remoteLocation[3] ~= nil then
@ -269,16 +275,22 @@ function transporter_config()
remoteLocation[1] = "???"
end
w.setColorControl()
w.setCursorPos(1, 16)
w.writeFullLine(" Enter - as player name to use coordinates")
w.writeFullLine(" Press Enter to save your selection")
w.setCursorPos(1, 13)
w.setColorHelp()
w.writeFullLine(" Enter - as player name to use coordinates.")
w.writeFullLine(" Press Enter to save your selection.")
w.setColorNormal()
w.setCursorPos(1, 10)
w.setColorNormal()
w.write("Signature, player name or dash: ")
w.setCursorPos(1, 11)
local remoteLocation_new = w.input_readText(remoteLocation_default)
w.setCursorPos(1, 13)
w.setColorNormal()
w.writeFullLine(" ")
w.writeFullLine(" ")
if remoteLocation_new ~= "-" then
remoteLocation = { transporter.remoteLocation(remoteLocation_new) }
else
@ -286,43 +298,59 @@ function transporter_config()
remoteLocation[1], remoteLocation[2], remoteLocation[3] = transporter.position()
end
w.setCursorPos(1, 10)
w.setColorNormal()
w.setCursorPos(1, 11)
w.writeFullLine(" ")
w.setColorControl()
w.setCursorPos(1, 16)
w.writeFullLine(" Enter absolute X coordinate")
w.setColorNormal()
w.writeFullLine(" ")
-- X
w.setCursorPos(1, 12)
w.setColorHelp()
w.writeFullLine(" Enter absolute X coordinate.")
w.setCursorPos(1, 10)
w.setColorNormal()
w.write("Remote location X coordinate (" .. w.format_integer(remoteLocation[1]) .. "): ")
remoteLocation[1] = w.input_readInteger(remoteLocation[1])
w.setColorControl()
w.setCursorPos(1, 16)
w.writeFullLine(" Enter Y < 0 to target below planet")
w.writeFullLine(" Enter Y > 256 to target space above")
w.setColorNormal()
w.setCursorPos(1, 11)
w.write("Remote location Y coordinate (" .. w.format_integer(remoteLocation[2]) .. "): ")
remoteLocation[2] = w.input_readInteger(remoteLocation[2])
w.setColorControl()
w.setCursorPos(1, 16)
w.writeFullLine(" Enter absolute Z coordinate")
w.setCursorPos(1, 12)
w.setColorNormal()
w.writeFullLine(" ")
-- Y
w.setCursorPos(1, 13)
w.setColorHelp()
w.writeFullLine(" Enter Y < 0 to target below planet.")
w.writeFullLine(" Enter Y > 256 to target space above.")
w.setCursorPos(1, 11)
w.setColorNormal()
w.write("Remote location Y coordinate (" .. w.format_integer(remoteLocation[2]) .. "): ")
remoteLocation[2] = w.input_readInteger(remoteLocation[2])
w.setCursorPos(1, 13)
w.setColorNormal()
w.writeFullLine(" ")
w.writeFullLine(" ")
-- Z
w.setCursorPos(1, 14)
w.setColorHelp()
w.writeFullLine(" Enter absolute Z coordinate.")
w.setCursorPos(1, 12)
w.setColorNormal()
w.write("Remote location Z coordinate (" .. w.format_integer(remoteLocation[3]) .. "): ")
remoteLocation[3] = w.input_readInteger(remoteLocation[3])
w.setCursorPos(1, 14)
w.setColorNormal()
w.writeFullLine(" ")
remoteLocation = { transporter.remoteLocation(remoteLocation[1], remoteLocation[2], remoteLocation[3]) }
end
w.setCursorPos(1, 12)
w.setCursorPos(1, 13)
if remoteLocation[3] ~= nil then
w.write("Remote location updated to " .. w.format_integer(remoteLocation[1]) .. ", " .. w.format_integer(remoteLocation[2]) .. ", " .. w.format_integer(remoteLocation[3]))
elseif remoteLocation[1] ~= nil then

View file

@ -222,8 +222,8 @@ function laser_battery_page()
end
end
w.setColorNormal()
w.setCursorPos(1, 13)
w.setColorNormal()
w.write(" -----------------------------------------------")
w.setCursorPos(1, 14)
w.write(" Firing mode: " .. data.laser_firingMode)
@ -237,8 +237,8 @@ function laser_battery_page()
w.write("off")
end
w.setColorControl()
w.setCursorPos(1, 15)
w.setColorControl()
w.writeFullLine(" Add/Remove/Configure selected battery (A/R/C)")
w.writeFullLine(" select battery (Up, Down), Link lasers (L)")
w.writeFullLine(" change Firing mode (F), toggle Scatter mode (S)")
@ -250,8 +250,11 @@ function laser_battery_config()
return
end
w.page_begin(w.data_getName() .. " - Laser battery configuration")
w.setColorNormal()
w.setCursorPos(1, 4)
w.setColorHelp()
w.writeFullLine(" Press enter to validate.")
w.setCursorPos(1, 3)
w.setColorNormal()
w.writeLn("Battery name (" .. laserbattery.name .. "):")
laserbattery.name = w.input_readText(laserbattery.name)
w.setCursorPos(1, 3)
@ -262,8 +265,8 @@ function laser_battery_config()
if laserbattery.head == nil then
return
end
w.setColorDisabled()
w.setCursorPos(1, 4)
w.setColorDisabled()
local headX, headY, headZ = laserbattery.head.position()
local headFrequency = laserbattery.head.beamFrequency()
w.write("@ " .. w.format_integer(headX, 7) .. " " .. w.format_integer(headY, 3) .. " " .. w.format_integer(headZ, 7))
@ -271,12 +274,12 @@ function laser_battery_config()
w.write("With " .. #laserbattery.boosters .. " boosters")
w.setCursorPos(1, 8)
w.setColorDisabled()
w.write(" Valid values are 0 to 65000 ")
w.setColorNormal()
w.setColorHelp()
w.writeFullLine(" Enter a number between 0 and 65000.")
local frequency
repeat
w.setCursorPos(1, 7)
w.setColorNormal()
w.clearLine()
w.write("Battery beam frequency (" .. w.format_integer(headFrequency, 5) .. "): ")
frequency = w.input_readInteger(headFrequency)
@ -305,12 +308,12 @@ function laser_battery_linkLasers()
end
w.page_begin(w.data_getName() .. " - Linking lasers")
w.setColorDisabled()
w.setCursorPos(1, 3)
w.writeLn("Use Up/Down/Left/Right to select lasers.")
w.writeLn("Press backspace/delete to remove laser.")
w.writeLn("Press enter to validate.")
w.writeLn("Validate with '-no laser-' to stop adding lasers.")
w.setColorHelp()
w.writeFullLine(" Use Up/Down/Left/Right to select lasers.")
w.writeFullLine(" Press backspace/delete to remove laser.")
w.writeFullLine(" Press enter to validate.")
w.writeFullLine(" Validate with '-no laser-' to stop adding lasers.")
w.setColorNormal()
if laserbattery.boosters == nil then
@ -329,8 +332,8 @@ function laser_battery_linkLasers()
w.writeLn("Laser head (" .. laserbattery.headAddress .. "): ")
end
laserbattery.headAddress = w.input_readEnum(laserbattery.headAddress, laserAddresses_left, laser_getName, laser_getDescription, "-no laser-")
w.setColorNormal()
w.setCursorPos(1, 8)
w.setColorNormal()
w.clearLine()
if laserbattery.headAddress == nil then
w.writeLn("Laser head set to (not defined)")
@ -347,8 +350,8 @@ function laser_battery_linkLasers()
w.writeLn("Laser head set to " .. laserbattery.headAddress)
laserbattery.head = w.device_get(laserbattery.headAddress)
w.setColorDisabled()
w.setCursorPos(1, 9)
w.setColorDisabled()
local headX, headY, headZ = laserbattery.head.position()
local headFrequency = laserbattery.head.beamFrequency()
w.write("@ " .. w.format_integer(headX, 7) .. " " .. w.format_integer(headY, 3) .. " " .. w.format_integer(headZ, 7))
@ -357,8 +360,8 @@ function laser_battery_linkLasers()
local key = 1
local addressCurrent = nil
repeat
w.setColorNormal()
w.setCursorPos(1, 10 + (key % 5))
w.setColorNormal()
w.write("Booster #" .. key)
addressCurrent = nil
if key <= #laserbattery.boosterAddresses then
@ -387,8 +390,8 @@ function laser_battery_linkLasers()
laserbattery.boosterAddresses[key] = addressCurrent
laserbattery.boosters[key] = w.device_get(addressCurrent)
w.setColorNormal()
w.setCursorPos(1, 10 + (key % 5))
w.setColorNormal()
w.clearLine()
w.write("Booster #" .. key .. " set to " .. addressCurrent)
key = key + 1
@ -538,8 +541,8 @@ function laser_station_page()
end
end
w.setColorNormal()
w.setCursorPos(1, 13)
w.setColorNormal()
w.write(" -----------------------------------------------")
w.setCursorPos(1, 14)
w.write(" Firing mode: " .. data.laser_firingMode)
@ -553,8 +556,8 @@ function laser_station_page()
w.write("off")
end
w.setColorControl()
w.setCursorPos(1, 15)
w.setColorControl()
w.writeFullLine(" Add/Remove/Configure laser station (A/R/C)")
w.writeFullLine(" select station (Up, Down), Link batteries (L)")
w.writeFullLine(" change Firing mode (F), toggle Scatter mode (S)")
@ -566,8 +569,11 @@ function laser_station_config()
return
end
w.page_begin(w.data_getName() .. " - Laser station configuration")
w.setColorNormal()
w.setCursorPos(1, 4)
w.setColorHelp()
w.writeFullLine(" Press enter to validate.")
w.setCursorPos(1, 3)
w.setColorNormal()
w.writeLn("Laser station name (" .. laserstation.name .. "):")
laserstation.name = w.input_readText(laserstation.name)
w.setCursorPos(1, 3)
@ -586,12 +592,12 @@ function laser_station_config()
w.write("With " .. #laserstation.batteries .. " batteries")
w.setCursorPos(1, 8)
w.setColorDisabled()
w.write(" Valid values are 0 to 268435455 ")
w.setColorNormal()
w.setColorHelp()
w.writeFullLine(" Enter a number between 0 and 268435455.")
local channel
repeat
w.setCursorPos(1, 7)
w.setColorNormal()
w.write("Camera video channel (" .. w.format_integer(camVideoChannel, 5) .. "): ")
channel = w.input_readInteger(camVideoChannel)
if channel ~= 0 and (channel < 0 or channel > 268435455) then
@ -641,12 +647,12 @@ function laser_station_linkBatteries()
end
w.page_begin(w.data_getName() .. " - Linking batteries")
w.setColorDisabled()
w.setCursorPos(1, 3)
w.writeLn("Use Up/Down/Left/Right to select batteries.")
w.writeLn("Press backspace/delete to remove battery.")
w.writeLn("Press enter to validate.")
w.writeLn("Validate '-no battery-' to stop adding batteries.")
w.setColorHelp()
w.writeFullLine(" Use Up/Down/Left/Right to select batteries.")
w.writeFullLine(" Press backspace/delete to remove battery.")
w.writeFullLine(" Press enter to validate.")
w.writeFullLine(" Validate '-no battery-' to stop adding batteries.")
w.setColorNormal()
if laserstation.batteries == nil then
@ -667,12 +673,12 @@ function laser_station_linkBatteries()
else
laserstation.camera = w.device_get(laserstation.cameraAddress)
w.setColorNormal()
w.setCursorPos(1, 8)
w.setColorNormal()
w.clearLine()
w.writeLn("Laser camera set to " .. laserstation.cameraAddress)
w.setColorDisabled()
w.setCursorPos(1, 9)
w.setColorDisabled()
w.clearLine()
local camX, camY, camZ = laserstation.camera.position()
local camVideoChannel = laserstation.camera.videoChannel()
@ -686,8 +692,8 @@ function laser_station_linkBatteries()
laser_batteries_left[keyBattery] = laserbattery
end
repeat
w.setColorNormal()
w.setCursorPos(1, 10 + (key % 5))
w.setColorNormal()
w.write("Battery #" .. key)
nameCurrent = nil
if key <= #laserstation.batteries then
@ -714,8 +720,8 @@ function laser_station_linkBatteries()
end
laserstation.batteries[key] = { name = nameCurrent, enabled = true }
w.setColorNormal()
w.setCursorPos(1, 10 + (key % 5))
w.setColorNormal()
w.clearLine()
w.write("Battery #" .. key .. " set to " .. nameCurrent)
key = key + 1

View file

@ -55,6 +55,7 @@ local styles = {
good = { front = colors.lime , back = colors.lightGray },
bad = { front = colors.red , back = colors.lightGray },
disabled = { front = colors.gray , back = colors.lightGray },
help = { front = colors.white , back = colors.blue },
header = { front = colors.orange , back = colors.black },
control = { front = colors.white , back = colors.blue },
selected = { front = colors.black , back = colors.lightBlue },
@ -421,8 +422,8 @@ local function input_readInteger(currentValue)
term.setCursorBlink(true)
repeat
w.status_tick()
w.setColorNormal()
w.setCursorPos(x, y)
w.setColorNormal()
w.write(input .. " ")
input = string.sub(input, -9)
w.setCursorPos(x + #input, y)
@ -526,8 +527,8 @@ local function input_readText(currentValue)
repeat
w.status_tick()
-- update display clearing extra characters
w.setColorNormal()
w.setCursorPos(x, y)
w.setColorNormal()
w.write(w.format_string(input, 37))
-- truncate input and set caret position
input = string.sub(input, -36)
@ -646,8 +647,8 @@ local function input_readEnum(currentValue, list, toValue, toDescription, noValu
term.setCursorBlink(true)
repeat
w.status_tick()
w.setColorNormal()
w.setCursorPos(x, y)
w.setColorNormal()
if #list == 0 then
inputKey = nil
end
@ -671,8 +672,8 @@ local function input_readEnum(currentValue, list, toValue, toDescription, noValu
end
w.setColorNormal()
w.write(input .. " ")
w.setColorDisabled()
w.setCursorPos(1, y + 1)
w.setColorDisabled()
w.write(inputDescription .. " ")
local params = { event.pull() }
@ -904,7 +905,11 @@ local function data_setName()
-- ask for a new name
w.page_begin("<==== Set " .. component .. " name ====>")
w.writeLn("")
w.setCursorPos(1, 4)
w.setColorHelp()
w.writeFullLine(" Press enter to validate.")
w.setCursorPos(1, 3)
w.setColorNormal()
w.write("Enter " .. component .. " name: ")
data_name = w.input_readText(data_name)

View file

@ -46,14 +46,14 @@ function lhc_boot(isDetailed)
lhc_controlChannels[controlChannel] = "true"
countParameters = countParameters + 1
elseif isDetailed then
w.setColorWarning();
w.setColorWarning()
w.writeLn("Error " .. x)
w.setColorNormal();
w.setColorNormal()
w.sleep(0.5)
end
end
elseif isDetailed then
w.setColorWarning();
w.setColorWarning()
w.writeLn("No control point detected!")
w.sleep(0.5)
end
@ -84,24 +84,24 @@ function lhc_boot(isDetailed)
lhc_parameters[index] = { controlChannel, isEnabled, threshold, description }
index = index + 1
elseif isDetailed then
w.setColorWarning();
w.setColorWarning()
if controlChannelCheck ~= nil then
w.writeLn("Error " .. controlChannelCheck)
else
w.writeLn("Error nil?")
end
w.sleep(0.5)
w.setColorNormal();
w.setColorNormal()
end
if controlChannel ~= controlChannelCheck and isDetailed then
w.setColorWarning();
w.setColorWarning()
w.writeLn("Error: requested " .. controlChannel .. ", received " .. controlChannelCheck)
w.sleep(0.5)
w.setColorNormal();
w.setColorNormal()
end
end
elseif isDetailed then
w.setColorWarning();
w.setColorWarning()
w.writeLn("No control channel detected!")
w.sleep(0.5)
end
@ -126,18 +126,42 @@ function lhc_page_parameter()
end
end
end
w.writeLn("")
local _, y = w.getCursorPos()
-- description
w.setCursorPos(1, y + 3)
w.setColorHelp()
w.writeFullLine(" Press enter to validate.")
w.setCursorPos(1, y)
w.setColorNormal()
w.writeLn("Current description is '" .. description .. "'")
w.write("Enter a description: ")
description = w.input_readText(description)
w.writeLn("")
w.setCursorPos(1, y + 3)
w.setColorNormal()
w.writeFullLine(" ")
-- threshold
w.setCursorPos(1, y + 7)
w.setColorHelp()
w.writeFullLine(" Press enter to validate.")
w.setCursorPos(1, y + 4)
w.setColorNormal()
w.writeLn("Current threshold is " .. w.format_integer(threshold * 100) .. "%")
w.write("Enter parameter threshold: ")
local new_threshold = w.input_readInteger(threshold * 100) / 100
threshold = math.min(2.0, math.max(0.0, new_threshold))
lhc_parameters[indexSelected] = { controlChannel, isEnabled, threshold, description }
accelerator.parameter(controlChannel, isEnabled, threshold, description)
w.setCursorPos(1, y + 7)
w.setColorNormal()
w.writeFullLine(" ")
end
lhc_parameter_indexSelected = 1
@ -211,45 +235,45 @@ function lhc_page()
w.write(" Controller is ")
if isEnabled then
w.setColorGood();
w.setColorGood()
w.writeLn("Enabled")
else
w.setColorBad();
w.setColorBad()
w.writeLn("Disabled")
end
local energy, energyMax = accelerator.energy()
if energy == nil then energy = 0 end
if energyMax == nil or energyMax == 0 then energyMax = 1 end
w.setColorNormal();
w.setColorNormal()
w.write(" Energy level is ")
if isPowered then
w.setColorGood();
w.setColorGood()
elseif isEnabled then
w.setColorBad();
w.setColorBad()
else
w.setColorDisabled();
w.setColorDisabled()
end
w.writeLn(math.floor(energy / energyMax * 100) .. " % (" .. energy .. " EU)")
-- w.writeLn("")
w.setColorNormal();
w.setColorNormal()
w.write(" Magnets temperature is ")
if temperatureCurrent_K <= temperatureTarget_K then
w.setColorGood();
w.setColorGood()
elseif isEnabled then
w.setColorBad();
w.setColorBad()
else
w.setColorDisabled();
w.setColorDisabled()
end
w.write(string.format("%.1f K", math.floor(temperatureCurrent_K * 10) / 10))
w.setColorNormal();
w.setColorNormal()
w.writeLn(". Target is " .. temperatureTarget_K .. " K")
-- w.writeLn("")
w.write("Parameters: ")
if #lhc_parameters == 0 then
w.setColorDisabled();
w.setColorDisabled()
w.writeLn("")
w.writeCentered(" -no valid node detected-")
else

View file

@ -123,29 +123,28 @@ function reactor_page()
w.write(w.format_integer(energy[3]) .. " RF/t")
end
w.setColorNormal()
w.setCursorPos(1, 9)
w.setColorNormal()
w.write("Activated: ")
local isEnabled = reactor.enable()
if isEnabled then w.setColorSuccess() else w.setColorNormal() end
w.write(w.format_boolean(isEnabled, "YES", "no"))
end
w.setCursorPos(30, 2)
if #reactorlasers == 0 then
w.setColorDisabled()
w.setCursorPos(30, 2)
w.write("Lasers not detected")
else
w.setColorNormal()
w.setCursorPos(30, 2)
w.write("Lasers")
for key, reactorlaser in pairs(reactorlasers) do
local side = reactorlaser.side
if side ~= nil then
side = side % 4
w.setColorNormal()
w.setCursorPos(4, 3 + side)
w.setColorNormal()
w.write("Side " .. w.format_integer(side) .. ":")
w.setCursorPos(30, 3 + side)
local energy = reactorlaser.wrap.energy()
@ -161,8 +160,8 @@ function reactor_page()
end
end
w.setColorNormal()
w.setCursorPos(1, 10)
w.setColorNormal()
w.write(" -----------------------------------------------")
w.setCursorPos(1, 11)
w.write("Output mode : ")
@ -176,14 +175,14 @@ function reactor_page()
else
w.write("rated at " .. reactor_rate .. " RF")
end
w.setColorNormal()
w.setCursorPos( 1, 12)
w.setColorNormal()
w.write("Target stability: " .. reactor_targetStability .. "%")
w.setCursorPos(30, 12)
w.write("Laser amount: " .. reactor_laserAmount)
w.setColorControl()
w.setCursorPos(1, 18)
w.setColorControl()
w.writeFullLine(" Start/stoP reactor (S/P), Use lasers (L)")
w.writeFullLine(" Output mode (O), Configuration (C)")
w.writeFullLine(" Target stability (+/-), Laser amount (U/J)")
@ -275,9 +274,9 @@ function reactor_pulse(output)
end
elseif reactor_pulseStep == 2 then
w.setColorNormal()
local energy = { reactor.energy() }
w.setCursorPos(12, 7)
w.setColorNormal()
if energy[2] ~= nil then
w.write(w.format_integer(energy[1], 10))
w.setCursorPos(39, 7)
@ -325,27 +324,50 @@ function reactor_config()
w.setColorDisabled()
w.write("Reactor not detected")
else
w.setColorNormal()
-- reactor output rate
w.setCursorPos(1, 6)
w.setColorHelp()
w.writeFullLine(" Enter a positive number.")
w.setCursorPos(1, 4)
w.setColorNormal()
w.write("Reactor output rate (" .. w.format_integer(reactor_rate) .. " RF): ")
reactor_rate = w.input_readInteger(reactor_rate)
reactor_setMode()
w.setCursorPos(1, 5)
w.write("Reactor output rate set")
w.setCursorPos(1, 6)
w.writeFullLine(" ")
-- laser amount
w.setCursorPos(1, 9)
w.setColorHelp()
w.writeFullLine(" Enter a positive number.")
w.setCursorPos(1, 7)
w.setColorNormal()
w.write("Laser energy level (" .. w.format_integer(reactor_laserAmount) .. "): ")
reactor_laserAmount = w.input_readInteger(reactor_laserAmount)
reactor_setLaser()
w.setCursorPos(1, 8)
w.write("Laser energy level set")
w.setCursorPos(1, 9)
w.writeFullLine(" ")
-- target stability
w.setCursorPos(1, 12)
w.setColorHelp()
w.writeFullLine(" Enter a positive number.")
w.setCursorPos(1, 10)
w.setColorNormal()
w.write("Reactor target stability (" .. w.format_integer(reactor_targetStability) .. "%): ")
reactor_targetStability = w.input_readInteger(reactor_targetStability)
reactor_setTargetStability()
w.setCursorPos(1, 11)
w.write("Reactor target stability set")
w.setCursorPos(1, 12)
w.writeFullLine(" ")
end
reactor_configPageLoaded = false
end

View file

@ -117,7 +117,7 @@ function ship_boot()
ship_shipSize = ship.getShipSize()
w.sleep(0.05)
timeout = timeout - 1
until ship_shipSize ~= nil or timeout < 0
until (ship_shipSize ~= nil and ship_shipSize ~= 0) or timeout < 0
if timeout < 0 then
w.setColorWarning()
w.writeLn("failed")
@ -239,35 +239,40 @@ function ship_warp()
end
function ship_page_setMovement()
-- force manual jump so we get proper max jump distance
ship.enable(false)
ship.command("MANUAL")
local success, maxJumpDistance = ship.getMaxJumpDistance()
if success ~= true then
w.status_showWarning("" .. maxJumpDistance)
return
end
w.page_begin("<==== Set ship movement ====>")
w.setColorNormal()
w.setCursorPos(1, 3)
w.setColorNormal()
ship_writeMovement("Current movement is ")
w.setCursorPos(1, 5)
ship_movement[1] = ship_page_setDistanceAxis(4, "Forward/back", "Forward", "Backward", ship_movement[1], math.abs(ship_front + ship_back + 1))
ship_movement[2] = ship_page_setDistanceAxis(6, "Up/down" , "Up" , "Down" , ship_movement[2], math.abs(ship_up + ship_down + 1))
ship_movement[3] = ship_page_setDistanceAxis(8, "Right/left" , "Right" , "Left" , ship_movement[3], math.abs(ship_left + ship_right + 1))
ship_movement[1] = ship_page_setDistanceAxis(4, "Forward/back", "Forward", "Backward", ship_movement[1], math.abs(ship_front + ship_back + 1), maxJumpDistance)
ship_movement[2] = ship_page_setDistanceAxis(6, "Up/down" , "Up" , "Down" , ship_movement[2], math.abs(ship_up + ship_down + 1), maxJumpDistance)
ship_movement[3] = ship_page_setDistanceAxis(8, "Right/left" , "Right" , "Left" , ship_movement[3], math.abs(ship_left + ship_right + 1), maxJumpDistance)
ship_movement = { ship.movement(ship_movement[1], ship_movement[2], ship_movement[3]) }
ship_updateMovementStats()
end
function ship_page_setDistanceAxis(line, axis, positive, negative, userEntry, shipLength)
local success, maxJumpDistance = ship.getMaxJumpDistance()
if success ~= true then
w.status_showSuccess("" .. maxJumpDistance)
maxJumpDistance = 0
end
function ship_page_setDistanceAxis(line, axis, positive, negative, userEntry, shipLength, maxJumpDistance)
local maximumDistance = math.floor(shipLength + maxJumpDistance)
w.setColorControl()
w.setCursorPos(1, line + 2)
w.writeFullLine("Enter between " .. math.floor( shipLength + 1) .. " and " .. maximumDistance .. " to move " .. positive)
w.writeFullLine("Enter 0 to keep position on this axis")
w.writeFullLine("Enter between " .. -maximumDistance .. " and " .. math.floor(-shipLength - 1) .. " to move " .. negative)
w.setColorHelp()
w.writeFullLine(" Enter between " .. math.floor( shipLength + 1) .. " and " .. maximumDistance .. " to move " .. positive .. ".")
w.writeFullLine(" Enter 0 to keep position on this axis.")
w.writeFullLine(" Enter between " .. -maximumDistance .. " and " .. math.floor(-shipLength - 1) .. " to move " .. negative .. ".")
w.setColorNormal()
repeat
w.setCursorPos(1, line)
w.setColorNormal()
w.write(axis .. " movement: ")
userEntry = w.input_readInteger(userEntry)
if userEntry ~= 0 and (math.abs(userEntry) <= shipLength or math.abs(userEntry) > maximumDistance) then
@ -288,11 +293,11 @@ function ship_page_setRotation()
local inputAbort = false
local drun = true
w.page_begin("<==== Set ship rotation ====>")
w.setCursorPos(1, 19)
w.setColorControl()
w.writeFullLine(" Select ship rotation (Up, Down, Left, Right)")
w.writeFullLine(" Select Front to keep current orientation")
w.writeFullLine(" Press Enter to save your selection")
w.setCursorPos(1, 11)
w.setColorHelp()
w.writeFullLine(" Select ship rotation (Up, Down, Left, Right).")
w.writeFullLine(" Select Front to keep current orientation.")
w.writeFullLine(" Press Enter to save your selection.")
repeat
w.setCursorPos(1, 3)
w.setColorNormal()
@ -332,11 +337,11 @@ end
function ship_page_setDimensions()
w.page_begin("<==== Set ship dimensions ====>")
w.setCursorPos(1, 18)
w.setColorControl()
w.writeFullLine(" Enter ship size in blocks (0-9)")
w.writeFullLine(" First block next to Ship counts as 1")
w.writeFullLine(" Ship controller counts as 'Front = 1'")
w.writeFullLine(" Press Enter to save your selection")
w.setColorHelp()
w.writeFullLine(" Enter ship size in blocks (0-9).")
w.writeFullLine(" First block next to Ship counts as 1.")
w.writeFullLine(" Ship controller counts as 'Front = 1'.")
w.writeFullLine(" Press Enter to save your selection.")
w.setCursorPos(1, 3)
w.setColorNormal()
@ -365,8 +370,8 @@ function ship_page_summon() -- no longer used
if stringPlayers == nil or #arrayPlayers == 0 then
w.writeLn("~ no players registered ~")
w.writeLn("")
w.setColorControl()
w.writeFullLine("Press enter to exit")
w.setColorHelp()
w.writeFullLine(" Press enter to exit.")
w.setColorNormal()
w.input_readInteger("")
return
@ -374,9 +379,9 @@ function ship_page_summon() -- no longer used
for i = 1, #arrayPlayers do
w.writeLn(i .. ". " .. arrayPlayers[i])
end
w.setColorControl()
w.writeFullLine("Enter player number")
w.writeFullLine("or press enter to summon everyone")
w.setColorHelp()
w.writeFullLine(" Enter player number")
w.writeFullLine(" or press enter to summon everyone.")
w.setColorNormal()
w.write(":")
@ -397,9 +402,9 @@ function ship_page_jumpToGate()
w.writeLn("Your ship should be already inside a jumpgate")
w.setCursorPos(1, 20)
w.setColorControl()
w.writeFullLine("Enter target jumpgate name (a-z, 0-9)")
w.writeFullLine("Press enter to save jumpgate name")
w.setColorHelp()
w.writeFullLine(" Enter target jumpgate name (a-z, 0-9).")
w.writeFullLine(" Press enter to save jumpgate name.")
w.setCursorPos(1, 5)
w.setColorNormal()

View file

@ -62,21 +62,21 @@ function transporter_page()
w.setColorDisabled()
w.write("Transporter core not detected")
else
w.setColorDisabled()
w.setCursorPos(1, 2)
w.setColorDisabled()
local _, signature = transporter.transporterName()
if (signature ~= nil) then
w.writeCentered(2, "Signature is " .. signature)
end
w.setColorNormal()
w.setCursorPos(1, 3)
w.setColorNormal()
w.write("Beam frequency = ")
local beamFrequency = transporter.beamFrequency()
w.write(w.format_integer(beamFrequency, 6))
w.setColorNormal()
w.setCursorPos(1, 4)
w.setColorNormal()
w.write("Remote location = ")
local remoteLocation = { transporter.remoteLocation() }
if remoteLocation[3] ~= nil then
@ -87,13 +87,13 @@ function transporter_page()
w.write("-not defined-")
end
w.setColorNormal()
w.setCursorPos(1, 6)
w.setColorNormal()
local energyFactor_PC = transporter.energyFactor() * 100
w.write("Energy factor = " .. w.format_float(math.floor(energyFactor_PC * 10) / 10, 6) .. " %")
w.setColorNormal()
w.setCursorPos(1, 7)
w.setColorNormal()
w.write("Energy required = ")
local energyAcquiring, energyEnergizing = transporter.getEnergyRequired()
if energyAcquiring ~= nil then
@ -102,18 +102,18 @@ function transporter_page()
w.write("???")
end
w.setColorNormal()
w.setCursorPos(1, 8)
w.setColorNormal()
w.write("Energy stored = ")
local energy = { transporter.energy() }
transporter_page_writeEnergy(energy)
w.setColorNormal()
w.setCursorPos(1, 9)
w.setColorNormal()
w.write(" -----------------------------------------------")
w.setColorNormal()
w.setCursorPos(1, 10)
w.setColorNormal()
w.write("Room is ")
local isEnabled = transporter.enable()
if isEnabled then w.setColorSuccess() else w.setColorNormal() end
@ -121,8 +121,8 @@ function transporter_page()
w.setColorNormal()
w.write(".")
w.setColorNormal()
w.setCursorPos(28, 10)
w.setColorNormal()
w.write("Locking is ")
local isLockRequested = transporter.lock()
if isLockRequested then w.setColorSuccess() else w.setColorNormal() end
@ -130,14 +130,14 @@ function transporter_page()
w.setColorNormal()
w.write(".")
w.setColorNormal()
w.setCursorPos(1, 11)
w.setColorNormal()
w.write("Lock strength is ")
local lockStrength = transporter.getLockStrength()
transporter_page_writeLockStrength(lockStrength)
w.setColorNormal()
w.setCursorPos(28, 11)
w.setColorNormal()
w.write("Energize is ")
local isEnergizeRequested = transporter.energize()
if isEnergizeRequested then w.setColorSuccess() else w.setColorNormal() end
@ -145,8 +145,8 @@ function transporter_page()
w.setColorNormal()
w.write(".")
w.setColorNormal()
w.setCursorPos(1, 13)
w.setColorNormal()
w.write("Status is ")
local _, state, _, _, isJammed = transporter.state()
if isJammed then
@ -157,15 +157,15 @@ function transporter_page()
w.write(".")
end
w.setColorControl()
w.setCursorPos(1, 20)
w.setColorControl()
w.writeFullLine(" Start/stoP transporter (S/P), Configuration (C)")
w.writeFullLine(" Lock (L), Energize (E), Energy factor (+/-)")
end
function transporter_page_writeEnergy(energy)
w.setColorNormal()
w.setCursorPos(19, 8)
w.setColorNormal()
if energy[2] ~= nil then
w.write(w.format_integer(energy[1], 7) .. " / " .. energy[2] .. " EU ")
else
@ -244,17 +244,23 @@ function transporter_config()
w.setColorDisabled()
w.write("Transporter core not detected")
else
w.setColorNormal()
w.setCursorPos(1, 6)
w.setColorHelp()
w.writeFullLine(" Enter a number between 100 and 1000 %.")
w.setCursorPos(1, 4)
w.setColorNormal()
local energyFactor_PC = transporter.energyFactor() * 100
w.write("Energy factor (" .. math.floor(energyFactor_PC * 10) / 10 .. " %): ")
energyFactor_PC = w.input_readInteger(energyFactor_PC)
energyFactor_PC = transporter.energyFactor(energyFactor_PC / 100) * 100
w.setCursorPos(1, 5)
w.write("Energy factor set to " .. math.floor(energyFactor_PC * 10) / 10 .. " %")
w.writeLn("Energy factor set to " .. math.floor(energyFactor_PC * 10) / 10 .. " %")
w.writeFullLine(" ")
w.setColorNormal()
w.setCursorPos(1, 7)
w.setColorNormal()
local remoteLocation = { transporter.remoteLocation() }
local remoteLocation_default = "-"
if remoteLocation[3] ~= nil then
@ -268,16 +274,22 @@ function transporter_config()
remoteLocation[1] = "???"
end
w.setColorControl()
w.setCursorPos(1, 16)
w.writeFullLine(" Enter - as player name to use coordinates")
w.writeFullLine(" Press Enter to save your selection")
w.setCursorPos(1, 13)
w.setColorHelp()
w.writeFullLine(" Enter - as player name to use coordinates.")
w.writeFullLine(" Press Enter to save your selection.")
w.setColorNormal()
w.setCursorPos(1, 10)
w.setColorNormal()
w.write("Signature, player name or dash: ")
w.setCursorPos(1, 11)
local remoteLocation_new = w.input_readText(remoteLocation_default)
w.setCursorPos(1, 13)
w.setColorNormal()
w.writeFullLine(" ")
w.writeFullLine(" ")
if remoteLocation_new ~= "-" then
remoteLocation = { transporter.remoteLocation(remoteLocation_new) }
else
@ -285,39 +297,55 @@ function transporter_config()
remoteLocation[1], remoteLocation[2], remoteLocation[3] = transporter.position()
end
w.setCursorPos(1, 10)
w.setColorNormal()
w.setCursorPos(1, 11)
w.writeFullLine(" ")
w.setColorControl()
w.setCursorPos(1, 16)
w.writeFullLine(" Enter absolute X coordinate")
w.setColorNormal()
w.writeFullLine(" ")
-- X
w.setCursorPos(1, 12)
w.setColorHelp()
w.writeFullLine(" Enter absolute X coordinate.")
w.setCursorPos(1, 10)
w.setColorNormal()
w.write("Remote location X coordinate (" .. w.format_integer(remoteLocation[1]) .. "): ")
remoteLocation[1] = w.input_readInteger(remoteLocation[1])
w.setColorControl()
w.setCursorPos(1, 16)
w.writeFullLine(" Enter Y < 0 to target below planet")
w.writeFullLine(" Enter Y > 256 to target space above")
w.setColorNormal()
w.setCursorPos(1, 11)
w.write("Remote location Y coordinate (" .. w.format_integer(remoteLocation[2]) .. "): ")
remoteLocation[2] = w.input_readInteger(remoteLocation[2])
w.setColorControl()
w.setCursorPos(1, 16)
w.writeFullLine(" Enter absolute Z coordinate")
w.setCursorPos(1, 12)
w.setColorNormal()
w.writeFullLine(" ")
-- Y
w.setCursorPos(1, 13)
w.setColorHelp()
w.writeFullLine(" Enter Y < 0 to target below planet.")
w.writeFullLine(" Enter Y > 256 to target space above.")
w.setCursorPos(1, 11)
w.setColorNormal()
w.write("Remote location Y coordinate (" .. w.format_integer(remoteLocation[2]) .. "): ")
remoteLocation[2] = w.input_readInteger(remoteLocation[2])
w.setCursorPos(1, 13)
w.setColorNormal()
w.writeFullLine(" ")
w.writeFullLine(" ")
-- Z
w.setCursorPos(1, 14)
w.setColorHelp()
w.writeFullLine(" Enter absolute Z coordinate.")
w.setCursorPos(1, 12)
w.setColorNormal()
w.write("Remote location Z coordinate (" .. w.format_integer(remoteLocation[3]) .. "): ")
remoteLocation[3] = w.input_readInteger(remoteLocation[3])
w.setCursorPos(1, 14)
w.setColorNormal()
w.writeFullLine(" ")
remoteLocation = { transporter.remoteLocation(remoteLocation[1], remoteLocation[2], remoteLocation[3]) }
end

View file

@ -221,8 +221,8 @@ function laser_battery_page()
end
end
w.setColorNormal()
w.setCursorPos(1, 14)
w.setColorNormal()
w.write(" -----------------------------------------------")
w.setCursorPos(1, 16)
w.write(" Firing mode: " .. data.laser_firingMode)
@ -236,8 +236,8 @@ function laser_battery_page()
w.write("off")
end
w.setColorControl()
w.setCursorPos(1, 19)
w.setColorControl()
w.writeFullLine(" Add/Remove/Configure selected battery (A/R/C)")
w.writeFullLine(" select battery (Up, Down), Link lasers (L)")
w.writeFullLine(" change Firing mode (F), toggle Scatter mode (S)")
@ -249,8 +249,11 @@ function laser_battery_config()
return
end
w.page_begin(w.data_getName() .. " - Laser battery configuration")
w.setColorNormal()
w.setCursorPos(1, 4)
w.setColorHelp()
w.writeFullLine(" Press enter to validate.")
w.setCursorPos(1, 3)
w.setColorNormal()
w.writeLn("Battery name (" .. laserbattery.name .. "):")
laserbattery.name = w.input_readText(laserbattery.name)
w.setCursorPos(1, 3)
@ -261,8 +264,8 @@ function laser_battery_config()
if laserbattery.head == nil then
return
end
w.setColorDisabled()
w.setCursorPos(1, 4)
w.setColorDisabled()
local headX, headY, headZ = laserbattery.head.position()
local headFrequency = laserbattery.head.beamFrequency()
w.write("@ " .. w.format_integer(headX, 7) .. " " .. w.format_integer(headY, 3) .. " " .. w.format_integer(headZ, 7))
@ -270,12 +273,12 @@ function laser_battery_config()
w.write("With " .. #laserbattery.boosters .. " boosters")
w.setCursorPos(1, 8)
w.setColorDisabled()
w.write(" Valid values are 0 to 65000 ")
w.setColorNormal()
w.setColorHelp()
w.writeFullLine(" Enter a number between 0 and 65000.")
local frequency
repeat
w.setCursorPos(1, 7)
w.setColorNormal()
w.clearLine()
w.write("Battery beam frequency (" .. w.format_integer(headFrequency, 5) .. "): ")
frequency = w.input_readInteger(headFrequency)
@ -304,12 +307,12 @@ function laser_battery_linkLasers()
end
w.page_begin(w.data_getName() .. " - Linking lasers")
w.setColorDisabled()
w.setCursorPos(1, 3)
w.writeLn("Use Up/Down/Left/Right to select lasers.")
w.writeLn("Press backspace/delete to remove laser.")
w.writeLn("Press enter to validate.")
w.writeLn("Validate with '-no laser-' to stop adding lasers.")
w.setColorHelp()
w.writeFullLine(" Use Up/Down/Left/Right to select lasers.")
w.writeFullLine(" Press backspace/delete to remove laser.")
w.writeFullLine(" Press enter to validate.")
w.writeFullLine(" Validate with '-no laser-' to stop adding lasers.")
w.setColorNormal()
if laserbattery.boosters == nil then
@ -328,8 +331,8 @@ function laser_battery_linkLasers()
w.writeLn("Laser head (" .. laserbattery.headAddress .. "): ")
end
laserbattery.headAddress = w.input_readEnum(laserbattery.headAddress, laserAddresses_left, laser_getName, laser_getDescription, "-no laser-")
w.setColorNormal()
w.setCursorPos(1, 8)
w.setColorNormal()
w.clearLine()
if laserbattery.headAddress == nil then
w.writeLn("Laser head set to (not defined)")
@ -346,8 +349,8 @@ function laser_battery_linkLasers()
w.writeLn("Laser head set to " .. laserbattery.headAddress)
laserbattery.head = w.device_get(laserbattery.headAddress)
w.setColorDisabled()
w.setCursorPos(1, 9)
w.setColorDisabled()
local headX, headY, headZ = laserbattery.head.position()
local headFrequency = laserbattery.head.beamFrequency()
w.write("@ " .. w.format_integer(headX, 7) .. " " .. w.format_integer(headY, 3) .. " " .. w.format_integer(headZ, 7))
@ -356,8 +359,8 @@ function laser_battery_linkLasers()
local key = 1
local addressCurrent = nil
repeat
w.setColorNormal()
w.setCursorPos(1, 10 + (key % 5))
w.setColorNormal()
w.write("Booster #" .. key)
addressCurrent = nil
if key <= #laserbattery.boosterAddresses then
@ -386,8 +389,8 @@ function laser_battery_linkLasers()
laserbattery.boosterAddresses[key] = addressCurrent
laserbattery.boosters[key] = w.device_get(addressCurrent)
w.setColorNormal()
w.setCursorPos(1, 10 + (key % 5))
w.setColorNormal()
w.clearLine()
w.write("Booster #" .. key .. " set to " .. addressCurrent)
key = key + 1
@ -537,8 +540,8 @@ function laser_station_page()
end
end
w.setColorNormal()
w.setCursorPos(1, 14)
w.setColorNormal()
w.write(" -----------------------------------------------")
w.setCursorPos(1, 16)
w.write(" Firing mode: " .. data.laser_firingMode)
@ -552,8 +555,8 @@ function laser_station_page()
w.write("off")
end
w.setColorControl()
w.setCursorPos(1, 19)
w.setColorControl()
w.writeFullLine(" Add/Remove/Configure laser station (A/R/C)")
w.writeFullLine(" select station (Up, Down), Link batteries (L)")
w.writeFullLine(" change Firing mode (F), toggle Scatter mode (S)")
@ -565,8 +568,11 @@ function laser_station_config()
return
end
w.page_begin(w.data_getName() .. " - Laser station configuration")
w.setColorNormal()
w.setCursorPos(1, 4)
w.setColorHelp()
w.writeFullLine(" Press enter to validate.")
w.setCursorPos(1, 3)
w.setColorNormal()
w.writeLn("Laser station name (" .. laserstation.name .. "):")
laserstation.name = w.input_readText(laserstation.name)
w.setCursorPos(1, 3)
@ -585,12 +591,12 @@ function laser_station_config()
w.write("With " .. #laserstation.batteries .. " batteries")
w.setCursorPos(1, 8)
w.setColorDisabled()
w.write(" Valid values are 0 to 268435455 ")
w.setColorNormal()
w.setColorHelp()
w.writeFullLine(" Enter a number between 0 and 268435455.")
local channel
repeat
w.setCursorPos(1, 7)
w.setColorNormal()
w.write("Camera video channel (" .. w.format_integer(camVideoChannel, 5) .. "): ")
channel = w.input_readInteger(camVideoChannel)
if channel ~= 0 and (channel < 0 or channel > 268435455) then
@ -640,12 +646,12 @@ function laser_station_linkBatteries()
end
w.page_begin(w.data_getName() .. " - Linking batteries")
w.setColorDisabled()
w.setCursorPos(1, 3)
w.writeLn("Use Up/Down/Left/Right to select batteries.")
w.writeLn("Press backspace/delete to remove battery.")
w.writeLn("Press enter to validate.")
w.writeLn("Validate '-no battery-' to stop adding batteries.")
w.setColorHelp()
w.writeFullLine(" Use Up/Down/Left/Right to select batteries.")
w.writeFullLine(" Press backspace/delete to remove battery.")
w.writeFullLine(" Press enter to validate.")
w.writeFullLine(" Validate '-no battery-' to stop adding batteries.")
w.setColorNormal()
if laserstation.batteries == nil then
@ -666,12 +672,12 @@ function laser_station_linkBatteries()
else
laserstation.camera = w.device_get(laserstation.cameraAddress)
w.setColorNormal()
w.setCursorPos(1, 8)
w.setColorNormal()
w.clearLine()
w.writeLn("Laser camera set to " .. laserstation.cameraAddress)
w.setColorDisabled()
w.setCursorPos(1, 9)
w.setColorDisabled()
w.clearLine()
local camX, camY, camZ = laserstation.camera.position()
local camVideoChannel = laserstation.camera.videoChannel()
@ -685,8 +691,8 @@ function laser_station_linkBatteries()
laser_batteries_left[keyBattery] = laserbattery
end
repeat
w.setColorNormal()
w.setCursorPos(1, 10 + (key % 5))
w.setColorNormal()
w.write("Battery #" .. key)
nameCurrent = nil
if key <= #laserstation.batteries then
@ -713,8 +719,8 @@ function laser_station_linkBatteries()
end
laserstation.batteries[key] = { name = nameCurrent, enabled = true }
w.setColorNormal()
w.setCursorPos(1, 10 + (key % 5))
w.setColorNormal()
w.clearLine()
w.write("Battery #" .. key .. " set to " .. nameCurrent)
key = key + 1