Updated scripts to LUA 5.3
OpenComputer 1.7.2 change LUA 5.3 to be default, the latest adds an integer type, formatting floatting with ".0", so we need to explicitly format all integers to string now
This commit is contained in:
parent
49e79b7ff1
commit
993825903c
12 changed files with 138 additions and 124 deletions
|
@ -351,7 +351,7 @@ local function format_integer(value, nbchar)
|
|||
local str = "?"
|
||||
if value ~= nil then
|
||||
if type(value) == "number" then
|
||||
str = string.format("%d", value)
|
||||
str = string.format("%d", math.floor(value))
|
||||
else
|
||||
str = type(value)
|
||||
end
|
||||
|
@ -403,9 +403,9 @@ end
|
|||
|
||||
----------- Input controls
|
||||
|
||||
local function input_readNumber(currentValue)
|
||||
local function input_readInteger(currentValue)
|
||||
local inputAbort = false
|
||||
local input = w.format_string(currentValue)
|
||||
local input = w.format_integer(currentValue)
|
||||
if input == "0" then
|
||||
input = ""
|
||||
end
|
||||
|
@ -1230,7 +1230,7 @@ w = {
|
|||
format_boolean = format_boolean,
|
||||
format_string = format_string,
|
||||
format_address = format_address,
|
||||
input_readNumber = input_readNumber,
|
||||
input_readInteger = input_readInteger,
|
||||
input_readText = input_readText,
|
||||
input_readConfirmation = input_readConfirmation,
|
||||
input_readEnum = input_readEnum,
|
||||
|
|
|
@ -5,7 +5,6 @@ local w = warpdriveCommons.w
|
|||
|
||||
----------- Accelerator support
|
||||
|
||||
local lhc_isEnabled = false
|
||||
local lhc_controlPoints = {}
|
||||
local lhc_parameters = {}
|
||||
local accelerator = nil
|
||||
|
@ -29,8 +28,8 @@ function lhc_boot(isDetailed)
|
|||
-- getting control points
|
||||
lhc_controlPoints = {}
|
||||
local count = accelerator.getControlPointsCount()
|
||||
lhc_controlChannels = { }
|
||||
countParameters = 0
|
||||
local lhc_controlChannels = { }
|
||||
local countParameters = 0
|
||||
|
||||
if count ~= nil and count > 0 then
|
||||
for i = 0, count - 1 do
|
||||
|
@ -134,9 +133,9 @@ function lhc_page_parameter()
|
|||
description = w.input_readText(description)
|
||||
|
||||
w.writeLn("")
|
||||
w.writeLn("Current threshold is " .. (threshold * 100) .. "%")
|
||||
w.writeLn("Current threshold is " .. w.format_integer(threshold * 100) .. "%")
|
||||
w.write("Enter parameter threshold: ")
|
||||
local new_threshold = w.input_readNumber(threshold * 100) / 100
|
||||
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)
|
||||
|
@ -257,7 +256,6 @@ function lhc_page()
|
|||
else
|
||||
local indexFirstLine, indexSelected = lhc_parameter_getIndexes()
|
||||
w.writeLn(indexSelected .. "/" .. #lhc_parameters)
|
||||
local indexCurrent = indexFirstLine
|
||||
local indexLastLine = math.min(indexFirstLine + lhc_parameter_lines, #lhc_parameters)
|
||||
for indexCurrent = indexFirstLine, indexLastLine do
|
||||
if indexCurrent == indexSelected then
|
||||
|
@ -402,5 +400,14 @@ w.page_register('1', lhc_page, lhc_key)
|
|||
lhc_register()
|
||||
|
||||
w.boot()
|
||||
w.run()
|
||||
local success, message = pcall(w.run)
|
||||
if not success then
|
||||
print("failed with message")
|
||||
print(message)
|
||||
w.sleep(3.0)
|
||||
print("rebooting...")
|
||||
w.reboot()
|
||||
else
|
||||
w.close()
|
||||
end
|
||||
w.close()
|
|
@ -103,7 +103,7 @@ function reactor_page()
|
|||
local instabilities = { reactor.instability() }
|
||||
for key, instability in pairs(instabilities) do
|
||||
w.setCursorPos(12, 2 + key)
|
||||
local stability = math.floor((100.0 - instability) * 10) / 10
|
||||
local stability = math.floor((100.0 - instability) * 10) / 10.0
|
||||
if stability >= data.reactor_targetStability then
|
||||
w.setColorSuccess()
|
||||
else
|
||||
|
@ -117,14 +117,14 @@ function reactor_page()
|
|||
w.setCursorPos(1, 7)
|
||||
w.write("Energy : ")
|
||||
if energy[2] ~= nil then
|
||||
w.write(w.format_integer(energy[1], 10) .. " / " .. energy[2] .. " RF +" .. w.format_integer(reactor_output, 5) .. " RF/t")
|
||||
w.write(w.format_integer(energy[1], 10) .. " / " .. w.format_integer(energy[2]) .. " RF +" .. w.format_integer(reactor_output, 5) .. " RF/t")
|
||||
else
|
||||
w.write("???")
|
||||
end
|
||||
w.setCursorPos(1, 8)
|
||||
w.write("Outputing: ")
|
||||
if energy[3] ~= nil then
|
||||
w.write(energy[3] .. " RF/t")
|
||||
w.write(w.format_integer(energy[3]) .. " RF/t")
|
||||
end
|
||||
|
||||
w.setColorNormal()
|
||||
|
@ -150,7 +150,7 @@ function reactor_page()
|
|||
side = side % 4
|
||||
w.setColorNormal()
|
||||
w.setCursorPos(4, 3 + side)
|
||||
w.write("Side " .. side .. ":")
|
||||
w.write("Side " .. w.format_integer(side) .. ":")
|
||||
w.setCursorPos(30, 3 + side)
|
||||
local energy = reactorlaser.wrap.energy()
|
||||
if not reactorlaser.wrap.hasReactor() then
|
||||
|
@ -287,7 +287,7 @@ function reactor_pulse(output)
|
|||
end
|
||||
if energy[3] ~= nil then
|
||||
w.setCursorPos(12, 8)
|
||||
w.write(energy[3] .. " RF/t ")
|
||||
w.write(w.format_integer(energy[3]) .. " RF/t ")
|
||||
end
|
||||
|
||||
if #reactorlasers ~= 0 then
|
||||
|
@ -325,22 +325,22 @@ function reactor_config()
|
|||
else
|
||||
w.setColorNormal()
|
||||
w.setCursorPos(1, 4)
|
||||
w.write("Reactor output rate (" .. data.reactor_rate .. " RF): ")
|
||||
data.reactor_rate = w.input_readNumber(data.reactor_rate)
|
||||
w.write("Reactor output rate (" .. w.format_integer(data.reactor_rate) .. " RF): ")
|
||||
data.reactor_rate = w.input_readInteger(data.reactor_rate)
|
||||
reactor_setMode()
|
||||
w.setCursorPos(1, 5)
|
||||
w.write("Reactor output rate set")
|
||||
|
||||
w.setCursorPos(1, 7)
|
||||
w.write("Laser energy level (" .. data.reactor_laserAmount .. "): ")
|
||||
data.reactor_laserAmount = w.input_readNumber(data.reactor_laserAmount)
|
||||
w.write("Laser energy level (" .. w.format_integer(data.reactor_laserAmount) .. "): ")
|
||||
data.reactor_laserAmount = w.input_readInteger(data.reactor_laserAmount)
|
||||
reactor_setLaser()
|
||||
w.setCursorPos(1, 8)
|
||||
w.write("Laser energy level set")
|
||||
|
||||
w.setCursorPos(1, 10)
|
||||
w.write("Reactor target stability (" .. data.reactor_targetStability .. "%): ")
|
||||
data.reactor_targetStability = w.input_readNumber(data.reactor_targetStability)
|
||||
w.write("Reactor target stability (" .. w.format_integer(data.reactor_targetStability) .. "%): ")
|
||||
data.reactor_targetStability = w.input_readInteger(data.reactor_targetStability)
|
||||
reactor_setTargetStability()
|
||||
w.setCursorPos(1, 11)
|
||||
w.write("Reactor target stability set")
|
||||
|
|
|
@ -137,28 +137,28 @@ function ship_writeMovement(prefix)
|
|||
local message = prefix
|
||||
local count = 0
|
||||
if ship_movement[1] > 0 then
|
||||
message = message .. ship_movement[1] .. " front"
|
||||
message = message .. w.format_integer(ship_movement[1]) .. " front"
|
||||
count = count + 1
|
||||
elseif ship_movement[1] < 0 then
|
||||
message = message .. (- ship_movement[1]) .. " back"
|
||||
message = message .. w.format_integer(- ship_movement[1]) .. " back"
|
||||
count = count + 1
|
||||
end
|
||||
if ship_movement[2] > 0 then
|
||||
if count > 0 then message = message .. ", " end
|
||||
message = message .. ship_movement[2] .. " up"
|
||||
message = message .. w.format_integer(ship_movement[2]) .. " up"
|
||||
count = count + 1
|
||||
elseif ship_movement[2] < 0 then
|
||||
if count > 0 then message = message .. ", " end
|
||||
message = message .. (- ship_movement[2]) .. " down"
|
||||
message = message .. w.format_integer(- ship_movement[2]) .. " down"
|
||||
count = count + 1
|
||||
end
|
||||
if ship_movement[3] > 0 then
|
||||
if count > 0 then message = message .. ", " end
|
||||
message = message .. ship_movement[3] .. " right"
|
||||
message = message .. w.format_integer(ship_movement[3]) .. " right"
|
||||
count = count + 1
|
||||
elseif ship_movement[3] < 0 then
|
||||
if count > 0 then message = message .. ", " end
|
||||
message = message .. (- ship_movement[3]) .. " left"
|
||||
message = message .. w.format_integer(- ship_movement[3]) .. " left"
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
|
@ -263,18 +263,18 @@ function ship_page_setDistanceAxis(line, axis, positive, negative, userEntry, sh
|
|||
w.status_showSuccess("" .. maxJumpDistance)
|
||||
maxJumpDistance = 0
|
||||
end
|
||||
local maximumDistance = shipLength + maxJumpDistance
|
||||
local maximumDistance = math.floor(shipLength + maxJumpDistance)
|
||||
w.setColorDisabled()
|
||||
w.setCursorPos(3, line + 1)
|
||||
w.write(positive .. " is " .. ( shipLength + 1) .. " to " .. maximumDistance .. " blocks ")
|
||||
w.write(positive .. " is " .. math.floor( shipLength + 1) .. " to " .. maximumDistance .. " blocks ")
|
||||
w.setCursorPos(3, line + 2)
|
||||
w.write(negative .. " is " .. (-shipLength - 1) .. " to " .. -maximumDistance .. " blocks ")
|
||||
w.write(negative .. " is " .. math.floor(-shipLength - 1) .. " to " .. -maximumDistance .. " blocks ")
|
||||
|
||||
w.setColorNormal()
|
||||
repeat
|
||||
w.setCursorPos(1, line)
|
||||
w.write(axis .. " movement: ")
|
||||
userEntry = w.input_readNumber(userEntry)
|
||||
userEntry = w.input_readInteger(userEntry)
|
||||
if userEntry ~= 0 and (math.abs(userEntry) <= shipLength or math.abs(userEntry) > maximumDistance) then
|
||||
w.status_showWarning("Wrong distance. Try again.")
|
||||
end
|
||||
|
@ -339,18 +339,18 @@ function ship_page_setDimensions()
|
|||
|
||||
w.setCursorPos(1, 3)
|
||||
w.setColorNormal()
|
||||
w.write(" Front (".. ship_front ..") : ")
|
||||
ship_front = w.input_readNumber(ship_front)
|
||||
w.write(" Right (".. ship_right ..") : ")
|
||||
ship_right = w.input_readNumber(ship_right)
|
||||
w.write(" Up (".. ship_up ..") : ")
|
||||
ship_up = w.input_readNumber(ship_up)
|
||||
w.write(" Back (".. ship_back ..") : ")
|
||||
ship_back = w.input_readNumber(ship_back)
|
||||
w.write(" Left (".. ship_left ..") : ")
|
||||
ship_left = w.input_readNumber(ship_left)
|
||||
w.write(" Down (".. ship_down ..") : ")
|
||||
ship_down = w.input_readNumber(ship_down)
|
||||
w.write(" Front (".. w.format_integer(ship_front) ..") : ")
|
||||
ship_front = w.input_readInteger(ship_front)
|
||||
w.write(" Right (".. w.format_integer(ship_right) ..") : ")
|
||||
ship_right = w.input_readInteger(ship_right)
|
||||
w.write(" Up (".. w.format_integer(ship_up) ..") : ")
|
||||
ship_up = w.input_readInteger(ship_up)
|
||||
w.write(" Back (".. w.format_integer(ship_back) ..") : ")
|
||||
ship_back = w.input_readInteger(ship_back)
|
||||
w.write(" Left (".. w.format_integer(ship_left) ..") : ")
|
||||
ship_left = w.input_readInteger(ship_left)
|
||||
w.write(" Down (".. w.format_integer(ship_down) ..") : ")
|
||||
ship_down = w.input_readInteger(ship_down)
|
||||
w.write("Setting dimensions...")
|
||||
ship_front, ship_right, ship_up = ship.dim_positive(ship_front, ship_right, ship_up)
|
||||
ship_back, ship_left, ship_down = ship.dim_negative(ship_back, ship_left, ship_down)
|
||||
|
@ -367,7 +367,7 @@ function ship_page_summon() -- no longer used
|
|||
w.setColorControl()
|
||||
w.writeFullLine("Press enter to exit")
|
||||
w.setColorNormal()
|
||||
w.input_readNumber("")
|
||||
w.input_readInteger("")
|
||||
return
|
||||
end
|
||||
local arrayPlayers = w.data_splitString(stringPlayers, ",")
|
||||
|
@ -380,7 +380,7 @@ function ship_page_summon() -- no longer used
|
|||
w.setColorNormal()
|
||||
|
||||
w.write(":")
|
||||
local input = w.input_readNumber("")
|
||||
local input = w.input_readInteger("")
|
||||
if input == "" then
|
||||
ship.targetName("")
|
||||
else
|
||||
|
@ -432,22 +432,22 @@ function ship_page_controls()
|
|||
end
|
||||
-- w.writeLn("")
|
||||
w.writeLn("Ship:")
|
||||
w.writeLn(" Current position = " .. ship_x .. ", " .. ship_y .. ", " .. ship_z)
|
||||
w.writeLn(" Current position = " .. w.format_integer(ship_x) .. ", " .. w.format_integer(ship_y) .. ", " .. w.format_integer(ship_z))
|
||||
local energy, energyMax = ship.energy()
|
||||
if energy == nil then energy = 0 end
|
||||
if energyMax == nil or energyMax == 0 then energyMax = 1 end
|
||||
w.writeLn(" Energy = " .. math.floor(energy / energyMax * 100) .. " % (" .. energy .. " EU)")
|
||||
w.writeLn(" Energy = " .. math.floor(energy / energyMax * 100) .. " % (" .. w.format_integer(energy) .. " EU)")
|
||||
|
||||
w.writeLn("")
|
||||
-- w.writeLn("")
|
||||
w.writeLn("Dimensions:")
|
||||
w.writeLn(" Front, Right, Up = " .. w.format_integer(ship_front) .. ", " .. w.format_integer(ship_right) .. ", " .. w.format_integer(ship_up) .. " blocks")
|
||||
w.writeLn(" Back, Left, Down = " .. w.format_integer(ship_back) .. ", " .. w.format_integer(ship_left) .. ", " .. w.format_integer(ship_down) .. " blocks")
|
||||
w.writeLn(" Size = " .. ship_shipSize .. " blocks")
|
||||
w.writeLn(" Size = " .. w.format_integer(ship_shipSize) .. " blocks")
|
||||
w.writeLn("")
|
||||
w.writeLn("Warp data:")
|
||||
ship_writeMovement(" Movement = ")
|
||||
w.writeLn(" Distance = " .. ship_actualDistance .. " m (" .. ship_energyRequired .. " EU, " .. math.floor(energy / ship_energyRequired) .. " jumps)")
|
||||
w.writeLn(" Distance = " .. w.format_integer(ship_actualDistance) .. " m (" .. w.format_integer(ship_energyRequired) .. " EU, " .. math.floor(energy / ship_energyRequired) .. " jumps)")
|
||||
w.writeLn(" Target position = " .. w.format_integer(ship_xTarget) .. ", " .. w.format_integer(ship_yTarget) .. ", " .. w.format_integer(ship_zTarget))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -249,7 +249,7 @@ function transporter_config()
|
|||
w.setCursorPos(1, 4)
|
||||
local energyFactor_PC = transporter.energyFactor() * 100
|
||||
w.write("Energy factor (" .. math.floor(energyFactor_PC * 10) / 10 .. " %): ")
|
||||
energyFactor_PC = w.input_readNumber(energyFactor_PC)
|
||||
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 .. " %")
|
||||
|
@ -259,7 +259,7 @@ function transporter_config()
|
|||
local remoteLocation = { transporter.remoteLocation() }
|
||||
local remoteLocation_default = "-"
|
||||
if remoteLocation[3] ~= nil then
|
||||
w.write("Remote location is currently set to " .. remoteLocation[1] .. ", " .. remoteLocation[2] .. ", " .. remoteLocation[3])
|
||||
w.write("Remote location is currently set to " .. w.format_integer(remoteLocation[1]) .. ", " .. w.format_integer(remoteLocation[2]) .. ", " .. w.format_integer(remoteLocation[3]))
|
||||
elseif remoteLocation[1] ~= nil then
|
||||
w.writeLn("Remote location is currently set to ")
|
||||
w.write(remoteLocation[1])
|
||||
|
@ -298,8 +298,8 @@ function transporter_config()
|
|||
w.writeFullLine(" ")
|
||||
|
||||
w.setCursorPos(1, 10)
|
||||
w.write("Remote location X coordinate (" .. remoteLocation[1] .. "): ")
|
||||
remoteLocation[1] = w.input_readNumber(remoteLocation[1])
|
||||
w.write("Remote location X coordinate (" .. w.format_integer(remoteLocation[1]) .. "): ")
|
||||
remoteLocation[1] = w.input_readInteger(remoteLocation[1])
|
||||
|
||||
w.setColorControl()
|
||||
w.setCursorPos(1, 16)
|
||||
|
@ -308,8 +308,8 @@ function transporter_config()
|
|||
|
||||
w.setColorNormal()
|
||||
w.setCursorPos(1, 11)
|
||||
w.write("Remote location Y coordinate (" .. remoteLocation[2] .. "): ")
|
||||
remoteLocation[2] = w.input_readNumber(remoteLocation[2])
|
||||
w.write("Remote location Y coordinate (" .. w.format_integer(remoteLocation[2]) .. "): ")
|
||||
remoteLocation[2] = w.input_readInteger(remoteLocation[2])
|
||||
|
||||
w.setColorControl()
|
||||
w.setCursorPos(1, 16)
|
||||
|
@ -318,8 +318,8 @@ function transporter_config()
|
|||
w.writeFullLine(" ")
|
||||
|
||||
w.setCursorPos(1, 12)
|
||||
w.write("Remote location Z coordinate (" .. remoteLocation[3] .. "): ")
|
||||
remoteLocation[3] = w.input_readNumber(remoteLocation[3])
|
||||
w.write("Remote location Z coordinate (" .. w.format_integer(remoteLocation[3]) .. "): ")
|
||||
remoteLocation[3] = w.input_readInteger(remoteLocation[3])
|
||||
|
||||
remoteLocation = { transporter.remoteLocation(remoteLocation[1], remoteLocation[2], remoteLocation[3]) }
|
||||
end
|
||||
|
|
|
@ -279,7 +279,7 @@ function laser_battery_config()
|
|||
w.setCursorPos(1, 7)
|
||||
w.clearLine()
|
||||
w.write("Battery beam frequency (" .. w.format_integer(headFrequency, 5) .. "): ")
|
||||
frequency = w.input_readNumber(headFrequency)
|
||||
frequency = w.input_readInteger(headFrequency)
|
||||
if frequency ~= 0 and (frequency < 0 or frequency > 65000) then
|
||||
w.status_showWarning("This is not a valid beam frequency. Try again.")
|
||||
end
|
||||
|
@ -593,7 +593,7 @@ function laser_station_config()
|
|||
repeat
|
||||
w.setCursorPos(1, 7)
|
||||
w.write("Camera video frequency (" .. w.format_integer(camVideoChannel, 5) .. "): ")
|
||||
channel = w.input_readNumber(camVideoChannel)
|
||||
channel = w.input_readInteger(camVideoChannel)
|
||||
if channel ~= 0 and (channel < 0 or channel > 268435455) then
|
||||
w.status_showWarning("This is not a valid video channel. Try again.")
|
||||
end
|
||||
|
|
|
@ -357,7 +357,7 @@ local function format_integer(value, nbchar)
|
|||
local str = "?"
|
||||
if value ~= nil then
|
||||
if type(value) == "number" then
|
||||
str = string.format("%d", value)
|
||||
str = string.format("%d", math.floor(value))
|
||||
else
|
||||
str = type(value)
|
||||
end
|
||||
|
@ -409,9 +409,9 @@ end
|
|||
|
||||
----------- Input controls
|
||||
|
||||
local function input_readNumber(currentValue)
|
||||
local function input_readInteger(currentValue)
|
||||
local inputAbort = false
|
||||
local input = w.format_string(currentValue)
|
||||
local input = w.format_integer(currentValue)
|
||||
if input == "0" then
|
||||
input = ""
|
||||
end
|
||||
|
@ -438,19 +438,19 @@ local function input_readNumber(currentValue)
|
|||
local keycode = params[4]
|
||||
|
||||
if keycode >= 2 and keycode <= 10 then -- 1 to 9
|
||||
input = input .. w.format_string(keycode - 1)
|
||||
input = input .. w.format_integer(keycode - 1)
|
||||
ignoreNextChar = true
|
||||
elseif keycode == 11 or keycode == 82 then -- 0 & keypad 0
|
||||
input = input .. "0"
|
||||
ignoreNextChar = true
|
||||
elseif keycode >= 79 and keycode <= 81 then -- keypad 1 to 3
|
||||
input = input .. w.format_string(keycode - 78)
|
||||
input = input .. w.format_integer(keycode - 78)
|
||||
ignoreNextChar = true
|
||||
elseif keycode >= 75 and keycode <= 77 then -- keypad 4 to 6
|
||||
input = input .. w.format_string(keycode - 71)
|
||||
input = input .. w.format_integer(keycode - 71)
|
||||
ignoreNextChar = true
|
||||
elseif keycode >= 71 and keycode <= 73 then -- keypad 7 to 9
|
||||
input = input .. w.format_string(keycode - 64)
|
||||
input = input .. w.format_integer(keycode - 64)
|
||||
ignoreNextChar = true
|
||||
elseif keycode == 14 then -- Backspace
|
||||
input = string.sub(input, 1, string.len(input) - 1)
|
||||
|
@ -1201,7 +1201,7 @@ w = {
|
|||
format_boolean = format_boolean,
|
||||
format_string = format_string,
|
||||
format_address = format_address,
|
||||
input_readNumber = input_readNumber,
|
||||
input_readInteger = input_readInteger,
|
||||
input_readText = input_readText,
|
||||
input_readConfirmation = input_readConfirmation,
|
||||
input_readEnum = input_readEnum,
|
||||
|
|
|
@ -4,7 +4,6 @@ local w = require("warpdriveCommons")
|
|||
|
||||
----------- Accelerator support
|
||||
|
||||
local lhc_isEnabled = false
|
||||
local lhc_controlPoints = {}
|
||||
local lhc_parameters = {}
|
||||
local accelerator = nil
|
||||
|
@ -28,8 +27,8 @@ function lhc_boot(isDetailed)
|
|||
-- getting control points
|
||||
lhc_controlPoints = {}
|
||||
local count = accelerator.getControlPointsCount()
|
||||
lhc_controlChannels = { }
|
||||
countParameters = 0
|
||||
local lhc_controlChannels = { }
|
||||
local countParameters = 0
|
||||
|
||||
if count ~= nil and count > 0 then
|
||||
for i = 0, count - 1 do
|
||||
|
@ -133,9 +132,9 @@ function lhc_page_parameter()
|
|||
description = w.input_readText(description)
|
||||
|
||||
w.writeLn("")
|
||||
w.writeLn("Current threshold is " .. (threshold * 100) .. "%")
|
||||
w.writeLn("Current threshold is " .. w.format_integer(threshold * 100) .. "%")
|
||||
w.write("Enter parameter threshold: ")
|
||||
local new_threshold = w.input_readNumber(threshold * 100) / 100
|
||||
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)
|
||||
|
@ -256,7 +255,6 @@ function lhc_page()
|
|||
else
|
||||
local indexFirstLine, indexSelected = lhc_parameter_getIndexes()
|
||||
w.writeLn(indexSelected .. "/" .. #lhc_parameters)
|
||||
local indexCurrent = indexFirstLine
|
||||
local indexLastLine = math.min(indexFirstLine + lhc_parameter_lines, #lhc_parameters)
|
||||
for indexCurrent = indexFirstLine, indexLastLine do
|
||||
if indexCurrent == indexSelected then
|
||||
|
@ -389,5 +387,14 @@ w.page_register('1', lhc_page, lhc_key)
|
|||
lhc_register()
|
||||
|
||||
w.boot()
|
||||
w.run()
|
||||
local success, message = pcall(w.run)
|
||||
if not success then
|
||||
print("failed with message")
|
||||
print(message)
|
||||
w.sleep(3.0)
|
||||
print("rebooting...")
|
||||
w.reboot()
|
||||
else
|
||||
w.close()
|
||||
end
|
||||
w.close()
|
|
@ -102,7 +102,7 @@ function reactor_page()
|
|||
local instabilities = { reactor.instability() }
|
||||
for key, instability in pairs(instabilities) do
|
||||
w.setCursorPos(12, 2 + key)
|
||||
local stability = math.floor((100.0 - instability) * 10) / 10
|
||||
local stability = math.floor((100.0 - instability) * 10) / 10.0
|
||||
if stability >= data.reactor_targetStability then
|
||||
w.setColorSuccess()
|
||||
else
|
||||
|
@ -116,14 +116,14 @@ function reactor_page()
|
|||
w.setCursorPos(1, 7)
|
||||
w.write("Energy : ")
|
||||
if energy[2] ~= nil then
|
||||
w.write(w.format_integer(energy[1], 10) .. " / " .. energy[2] .. " RF +" .. w.format_integer(reactor_output, 5) .. " RF/t")
|
||||
w.write(w.format_integer(energy[1], 10) .. " / " .. w.format_integer(energy[2]) .. " RF +" .. w.format_integer(reactor_output, 5) .. " RF/t")
|
||||
else
|
||||
w.write("???")
|
||||
end
|
||||
w.setCursorPos(1, 8)
|
||||
w.write("Outputing: ")
|
||||
if energy[3] ~= nil then
|
||||
w.write(energy[3] .. " RF/t")
|
||||
w.write(w.format_integer(energy[3]) .. " RF/t")
|
||||
end
|
||||
|
||||
w.setColorNormal()
|
||||
|
@ -149,7 +149,7 @@ function reactor_page()
|
|||
side = side % 4
|
||||
w.setColorNormal()
|
||||
w.setCursorPos(4, 3 + side)
|
||||
w.write("Side " .. side .. ":")
|
||||
w.write("Side " .. w.format_integer(side) .. ":")
|
||||
w.setCursorPos(30, 3 + side)
|
||||
local energy = reactorlaser.wrap.energy()
|
||||
if not reactorlaser.wrap.hasReactor() then
|
||||
|
@ -290,7 +290,7 @@ function reactor_pulse(output)
|
|||
end
|
||||
if energy[3] ~= nil then
|
||||
w.setCursorPos(12, 8)
|
||||
w.write(energy[3] .. " RF/t ")
|
||||
w.write(w.format_integer(energy[3]) .. " RF/t ")
|
||||
end
|
||||
|
||||
elseif reactor_pulseStep == 4 then
|
||||
|
@ -330,22 +330,22 @@ function reactor_config()
|
|||
else
|
||||
w.setColorNormal()
|
||||
w.setCursorPos(1, 4)
|
||||
w.write("Reactor output rate (" .. data.reactor_rate .. " RF): ")
|
||||
data.reactor_rate = w.input_readNumber(data.reactor_rate)
|
||||
w.write("Reactor output rate (" .. w.format_integer(data.reactor_rate) .. " RF): ")
|
||||
data.reactor_rate = w.input_readInteger(data.reactor_rate)
|
||||
reactor_setMode()
|
||||
w.setCursorPos(1, 5)
|
||||
w.write("Reactor output rate set")
|
||||
|
||||
w.setCursorPos(1, 7)
|
||||
w.write("Laser energy level (" .. data.reactor_laserAmount .. "): ")
|
||||
data.reactor_laserAmount = w.input_readNumber(data.reactor_laserAmount)
|
||||
w.write("Laser energy level (" .. w.format_integer(data.reactor_laserAmount) .. "): ")
|
||||
data.reactor_laserAmount = w.input_readInteger(data.reactor_laserAmount)
|
||||
reactor_setLaser()
|
||||
w.setCursorPos(1, 8)
|
||||
w.write("Laser energy level set")
|
||||
|
||||
w.setCursorPos(1, 10)
|
||||
w.write("Reactor target stability (" .. data.reactor_targetStability .. "%): ")
|
||||
data.reactor_targetStability = w.input_readNumber(data.reactor_targetStability)
|
||||
w.write("Reactor target stability (" .. w.format_integer(data.reactor_targetStability) .. "%): ")
|
||||
data.reactor_targetStability = w.input_readInteger(data.reactor_targetStability)
|
||||
reactor_setTargetStability()
|
||||
w.setCursorPos(1, 11)
|
||||
w.write("Reactor target stability set")
|
||||
|
|
|
@ -138,28 +138,28 @@ function ship_writeMovement(prefix)
|
|||
local message = prefix
|
||||
local count = 0
|
||||
if ship_movement[1] > 0 then
|
||||
message = message .. ship_movement[1] .. " front"
|
||||
message = message .. w.format_integer(ship_movement[1]) .. " front"
|
||||
count = count + 1
|
||||
elseif ship_movement[1] < 0 then
|
||||
message = message .. (- ship_movement[1]) .. " back"
|
||||
message = message .. w.format_integer(- ship_movement[1]) .. " back"
|
||||
count = count + 1
|
||||
end
|
||||
if ship_movement[2] > 0 then
|
||||
if count > 0 then message = message .. ", " end
|
||||
message = message .. ship_movement[2] .. " up"
|
||||
message = message .. w.format_integer(ship_movement[2]) .. " up"
|
||||
count = count + 1
|
||||
elseif ship_movement[2] < 0 then
|
||||
if count > 0 then message = message .. ", " end
|
||||
message = message .. (- ship_movement[2]) .. " down"
|
||||
message = message .. w.format_integer(- ship_movement[2]) .. " down"
|
||||
count = count + 1
|
||||
end
|
||||
if ship_movement[3] > 0 then
|
||||
if count > 0 then message = message .. ", " end
|
||||
message = message .. ship_movement[3] .. " right"
|
||||
message = message .. w.format_integer(ship_movement[3]) .. " right"
|
||||
count = count + 1
|
||||
elseif ship_movement[3] < 0 then
|
||||
if count > 0 then message = message .. ", " end
|
||||
message = message .. (- ship_movement[3]) .. " left"
|
||||
message = message .. w.format_integer(- ship_movement[3]) .. " left"
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
|
@ -264,18 +264,18 @@ function ship_page_setDistanceAxis(line, axis, positive, negative, userEntry, sh
|
|||
w.status_showSuccess("" .. maxJumpDistance)
|
||||
maxJumpDistance = 0
|
||||
end
|
||||
local maximumDistance = shipLength + maxJumpDistance
|
||||
local maximumDistance = math.floor(shipLength + maxJumpDistance)
|
||||
w.setColorDisabled()
|
||||
w.setCursorPos(3, line + 1)
|
||||
w.write(positive .. " is " .. ( shipLength + 1) .. " to " .. maximumDistance .. " blocks ")
|
||||
w.write(positive .. " is " .. math.floor( shipLength + 1) .. " to " .. maximumDistance .. " blocks ")
|
||||
w.setCursorPos(3, line + 2)
|
||||
w.write(negative .. " is " .. (-shipLength - 1) .. " to " .. -maximumDistance .. " blocks ")
|
||||
w.write(negative .. " is " .. math.floor(-shipLength - 1) .. " to " .. -maximumDistance .. " blocks ")
|
||||
|
||||
w.setColorNormal()
|
||||
repeat
|
||||
w.setCursorPos(1, line)
|
||||
w.write(axis .. " movement: ")
|
||||
userEntry = w.input_readNumber(userEntry)
|
||||
userEntry = w.input_readInteger(userEntry)
|
||||
if userEntry ~= 0 and (math.abs(userEntry) <= shipLength or math.abs(userEntry) > maximumDistance) then
|
||||
w.status_showWarning("Wrong distance. Try again.")
|
||||
end
|
||||
|
@ -344,18 +344,18 @@ function ship_page_setDimensions()
|
|||
|
||||
w.setCursorPos(1, 3)
|
||||
w.setColorNormal()
|
||||
w.write(" Front (".. ship_front ..") : ")
|
||||
ship_front = w.input_readNumber(ship_front)
|
||||
w.write(" Right (".. ship_right ..") : ")
|
||||
ship_right = w.input_readNumber(ship_right)
|
||||
w.write(" Up (".. ship_up ..") : ")
|
||||
ship_up = w.input_readNumber(ship_up)
|
||||
w.write(" Back (".. ship_back ..") : ")
|
||||
ship_back = w.input_readNumber(ship_back)
|
||||
w.write(" Left (".. ship_left ..") : ")
|
||||
ship_left = w.input_readNumber(ship_left)
|
||||
w.write(" Down (".. ship_down ..") : ")
|
||||
ship_down = w.input_readNumber(ship_down)
|
||||
w.write(" Front (".. w.format_integer(ship_front) ..") : ")
|
||||
ship_front = w.input_readInteger(ship_front)
|
||||
w.write(" Right (".. w.format_integer(ship_right) ..") : ")
|
||||
ship_right = w.input_readInteger(ship_right)
|
||||
w.write(" Up (".. w.format_integer(ship_up) ..") : ")
|
||||
ship_up = w.input_readInteger(ship_up)
|
||||
w.write(" Back (".. w.format_integer(ship_back) ..") : ")
|
||||
ship_back = w.input_readInteger(ship_back)
|
||||
w.write(" Left (".. w.format_integer(ship_left) ..") : ")
|
||||
ship_left = w.input_readInteger(ship_left)
|
||||
w.write(" Down (".. w.format_integer(ship_down) ..") : ")
|
||||
ship_down = w.input_readInteger(ship_down)
|
||||
w.write("Setting dimensions...")
|
||||
ship_front, ship_right, ship_up = ship.dim_positive(ship_front, ship_right, ship_up)
|
||||
ship_back, ship_left, ship_down = ship.dim_negative(ship_back, ship_left, ship_down)
|
||||
|
@ -372,7 +372,7 @@ function ship_page_summon() -- no longer used
|
|||
w.setColorControl()
|
||||
w.writeFullLine("Press enter to exit")
|
||||
w.setColorNormal()
|
||||
w.input_readNumber("")
|
||||
w.input_readInteger("")
|
||||
return
|
||||
end
|
||||
for i = 1, #arrayPlayers do
|
||||
|
@ -384,7 +384,7 @@ function ship_page_summon() -- no longer used
|
|||
w.setColorNormal()
|
||||
|
||||
w.write(":")
|
||||
local input = w.input_readNumber("")
|
||||
local input = w.input_readInteger("")
|
||||
if input == "" then
|
||||
ship.targetName("")
|
||||
else
|
||||
|
@ -436,22 +436,22 @@ function ship_page_controls()
|
|||
end
|
||||
-- w.writeLn("")
|
||||
w.writeLn("Ship:")
|
||||
w.writeLn(" Current position = " .. ship_x .. ", " .. ship_y .. ", " .. ship_z)
|
||||
w.writeLn(" Current position = " .. w.format_integer(ship_x) .. ", " .. w.format_integer(ship_y) .. ", " .. w.format_integer(ship_z))
|
||||
local energy, energyMax = ship.energy()
|
||||
if energy == nil then energy = 0 end
|
||||
if energyMax == nil or energyMax == 0 then energyMax = 1 end
|
||||
w.writeLn(" Energy = " .. math.floor(energy / energyMax * 100) .. " % (" .. energy .. " EU)")
|
||||
w.writeLn(" Energy = " .. math.floor(energy / energyMax * 100) .. " % (" .. w.format_integer(energy) .. " EU)")
|
||||
|
||||
w.writeLn("")
|
||||
-- w.writeLn("")
|
||||
w.writeLn("Dimensions:")
|
||||
w.writeLn(" Front, Right, Up = " .. w.format_integer(ship_front) .. ", " .. w.format_integer(ship_right) .. ", " .. w.format_integer(ship_up) .. " blocks")
|
||||
w.writeLn(" Back, Left, Down = " .. w.format_integer(ship_back) .. ", " .. w.format_integer(ship_left) .. ", " .. w.format_integer(ship_down) .. " blocks")
|
||||
w.writeLn(" Size = " .. ship_shipSize .. " blocks")
|
||||
w.writeLn(" Size = " .. w.format_integer(ship_shipSize) .. " blocks")
|
||||
w.writeLn("")
|
||||
w.writeLn("Warp data:")
|
||||
ship_writeMovement(" Movement = ")
|
||||
w.writeLn(" Distance = " .. ship_actualDistance .. " m (" .. ship_energyRequired .. " EU, " .. math.floor(energy / ship_energyRequired) .. " jumps)")
|
||||
w.writeLn(" Distance = " .. w.format_integer(ship_actualDistance) .. " m (" .. w.format_integer(ship_energyRequired) .. " EU, " .. math.floor(energy / ship_energyRequired) .. " jumps)")
|
||||
w.writeLn(" Target position = " .. w.format_integer(ship_xTarget) .. ", " .. w.format_integer(ship_yTarget) .. ", " .. w.format_integer(ship_zTarget))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -248,7 +248,7 @@ function transporter_config()
|
|||
w.setCursorPos(1, 4)
|
||||
local energyFactor_PC = transporter.energyFactor() * 100
|
||||
w.write("Energy factor (" .. math.floor(energyFactor_PC * 10) / 10 .. " %): ")
|
||||
energyFactor_PC = w.input_readNumber(energyFactor_PC)
|
||||
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 .. " %")
|
||||
|
@ -258,7 +258,7 @@ function transporter_config()
|
|||
local remoteLocation = { transporter.remoteLocation() }
|
||||
local remoteLocation_default = "-"
|
||||
if remoteLocation[3] ~= nil then
|
||||
w.write("Remote location is currently set to " .. remoteLocation[1] .. ", " .. remoteLocation[2] .. ", " .. remoteLocation[3])
|
||||
w.write("Remote location is currently set to " .. w.format_integer(remoteLocation[1]) .. ", " .. w.format_integer(remoteLocation[2]) .. ", " .. w.format_integer(remoteLocation[3]))
|
||||
elseif remoteLocation[1] ~= nil then
|
||||
w.write("Remote location is currently set to ")
|
||||
w.write(remoteLocation[1])
|
||||
|
@ -297,8 +297,8 @@ function transporter_config()
|
|||
w.writeFullLine(" ")
|
||||
|
||||
w.setCursorPos(1, 10)
|
||||
w.write("Remote location X coordinate (" .. remoteLocation[1] .. "): ")
|
||||
remoteLocation[1] = w.input_readNumber(remoteLocation[1])
|
||||
w.write("Remote location X coordinate (" .. w.format_integer(remoteLocation[1]) .. "): ")
|
||||
remoteLocation[1] = w.input_readInteger(remoteLocation[1])
|
||||
|
||||
w.setColorControl()
|
||||
w.setCursorPos(1, 16)
|
||||
|
@ -307,8 +307,8 @@ function transporter_config()
|
|||
|
||||
w.setColorNormal()
|
||||
w.setCursorPos(1, 11)
|
||||
w.write("Remote location Y coordinate (" .. remoteLocation[2] .. "): ")
|
||||
remoteLocation[2] = w.input_readNumber(remoteLocation[2])
|
||||
w.write("Remote location Y coordinate (" .. w.format_integer(remoteLocation[2]) .. "): ")
|
||||
remoteLocation[2] = w.input_readInteger(remoteLocation[2])
|
||||
|
||||
w.setColorControl()
|
||||
w.setCursorPos(1, 16)
|
||||
|
@ -317,8 +317,8 @@ function transporter_config()
|
|||
w.writeFullLine(" ")
|
||||
|
||||
w.setCursorPos(1, 12)
|
||||
w.write("Remote location Z coordinate (" .. remoteLocation[3] .. "): ")
|
||||
remoteLocation[3] = w.input_readNumber(remoteLocation[3])
|
||||
w.write("Remote location Z coordinate (" .. w.format_integer(remoteLocation[3]) .. "): ")
|
||||
remoteLocation[3] = w.input_readInteger(remoteLocation[3])
|
||||
|
||||
remoteLocation = { transporter.remoteLocation(remoteLocation[1], remoteLocation[2], remoteLocation[3]) }
|
||||
end
|
||||
|
|
|
@ -278,7 +278,7 @@ function laser_battery_config()
|
|||
w.setCursorPos(1, 7)
|
||||
w.clearLine()
|
||||
w.write("Battery beam frequency (" .. w.format_integer(headFrequency, 5) .. "): ")
|
||||
frequency = w.input_readNumber(headFrequency)
|
||||
frequency = w.input_readInteger(headFrequency)
|
||||
if frequency ~= 0 and (frequency < 0 or frequency > 65000) then
|
||||
w.status_showWarning("This is not a valid beam frequency. Try again.")
|
||||
end
|
||||
|
@ -592,7 +592,7 @@ function laser_station_config()
|
|||
repeat
|
||||
w.setCursorPos(1, 7)
|
||||
w.write("Camera video frequency (" .. w.format_integer(camVideoChannel, 5) .. "): ")
|
||||
channel = w.input_readNumber(camVideoChannel)
|
||||
channel = w.input_readInteger(camVideoChannel)
|
||||
if channel ~= 0 and (channel < 0 or channel > 268435455) then
|
||||
w.status_showWarning("This is not a valid video channel. Try again.")
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue