Improved address formating in WeaponController
Improved fault tolerance in LUA library
This commit is contained in:
parent
21c8417b42
commit
fabeeb5afe
4 changed files with 38 additions and 10 deletions
|
@ -304,7 +304,11 @@ local function status_show(isWarning, text)
|
|||
status_clockTarget = w.event_clock() + 0.5
|
||||
end
|
||||
status_isWarning = isWarning
|
||||
status_text = text
|
||||
if text ~= nil then
|
||||
status_text = text
|
||||
else
|
||||
status_text = "???"
|
||||
end
|
||||
w.status_refresh()
|
||||
end
|
||||
end
|
||||
|
@ -407,6 +411,15 @@ local function format_string(value, nbchar)
|
|||
return str
|
||||
end
|
||||
|
||||
local function format_address(value)
|
||||
local str = "?"
|
||||
if value ~= nil then
|
||||
str = "" .. value
|
||||
end
|
||||
str = string.sub(str, 10, 100)
|
||||
return str
|
||||
end
|
||||
|
||||
----------- Input controls
|
||||
|
||||
local function input_readNumber(currentValue)
|
||||
|
@ -1213,6 +1226,7 @@ w = {
|
|||
format_integer = format_integer,
|
||||
format_boolean = format_boolean,
|
||||
format_string = format_string,
|
||||
format_address = format_address,
|
||||
input_readNumber = input_readNumber,
|
||||
input_readText = input_readText,
|
||||
input_readConfirmation = input_readConfirmation,
|
||||
|
|
|
@ -196,7 +196,7 @@ function laser_battery_page()
|
|||
w.write(w.format_integer(headFrequency, 5))
|
||||
w.setColorNormal()
|
||||
w.write(" @ " .. w.format_integer(headX, 7) .. " " .. w.format_integer(headY, 3) .. " " .. w.format_integer(headZ, 7)
|
||||
.. " " .. string.sub(laserbattery.headAddress, 10, 100))
|
||||
.. " " .. w.format_address(laserbattery.headAddress))
|
||||
end
|
||||
|
||||
w.setCursorPos(1, 5)
|
||||
|
@ -217,7 +217,7 @@ function laser_battery_page()
|
|||
w.write(w.format_integer(booster.beamFrequency(), 5))
|
||||
w.setColorNormal()
|
||||
w.write(" @ " .. w.format_integer(x - headX, 7) .. " " .. w.format_integer(y - headY, 3) .. " " .. w.format_integer(z - headZ, 7)
|
||||
.. " " .. string.sub(laserbattery.boosterAddresses[key], 10, 100))
|
||||
.. " " .. w.format_address(laserbattery.boosterAddresses[key]))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -425,7 +425,7 @@ function laser_battery_getDescription(laserbattery)
|
|||
end
|
||||
end
|
||||
end
|
||||
return string.sub(laserbattery.name .. " ", 1, 20)
|
||||
return w.format_string(laserbattery.name, 20)
|
||||
.. msg
|
||||
.. " @ " .. w.format_integer(x, 7) .. " " .. w.format_integer(y, 3) .. " " .. w.format_integer(z, 7)
|
||||
end
|
||||
|
@ -515,7 +515,7 @@ function laser_station_page()
|
|||
w.write(w.format_integer(camVideoChannel, 5))
|
||||
w.setColorNormal()
|
||||
w.write(" @ " .. w.format_integer(camX, 7) .. " " .. w.format_integer(camY, 3) .. " " .. w.format_integer(camZ, 7)
|
||||
.. " " .. string.sub(laserstation.cameraAddress, 10, 100))
|
||||
.. " " .. w.format_address(laserstation.cameraAddress, 10, 100))
|
||||
end
|
||||
|
||||
w.setCursorPos(1, 5)
|
||||
|
|
|
@ -312,7 +312,11 @@ local function status_show(isWarning, text)
|
|||
status_clockTarget = w.event_clock() + 0.5
|
||||
end
|
||||
status_isWarning = isWarning
|
||||
status_text = text
|
||||
if text ~= nil then
|
||||
status_text = text
|
||||
else
|
||||
status_text = "???"
|
||||
end
|
||||
w.status_refresh()
|
||||
end
|
||||
end
|
||||
|
@ -415,6 +419,15 @@ local function format_string(value, nbchar)
|
|||
return str
|
||||
end
|
||||
|
||||
local function format_address(value)
|
||||
local str = "?"
|
||||
if value ~= nil then
|
||||
str = "" .. value
|
||||
end
|
||||
str = string.sub(str, 10, 100)
|
||||
return str
|
||||
end
|
||||
|
||||
----------- Input controls
|
||||
|
||||
local function input_readNumber(currentValue)
|
||||
|
@ -1184,6 +1197,7 @@ w = {
|
|||
format_integer = format_integer,
|
||||
format_boolean = format_boolean,
|
||||
format_string = format_string,
|
||||
format_address = format_address,
|
||||
input_readNumber = input_readNumber,
|
||||
input_readText = input_readText,
|
||||
input_readConfirmation = input_readConfirmation,
|
||||
|
|
|
@ -195,7 +195,7 @@ function laser_battery_page()
|
|||
w.write(w.format_integer(headFrequency, 5))
|
||||
w.setColorNormal()
|
||||
w.write(" @ " .. w.format_integer(headX, 7) .. " " .. w.format_integer(headY, 3) .. " " .. w.format_integer(headZ, 7)
|
||||
.. " " .. string.sub(laserbattery.headAddress, 10, 100))
|
||||
.. " " .. w.format_address(laserbattery.headAddress))
|
||||
end
|
||||
|
||||
w.setCursorPos(1, 5)
|
||||
|
@ -216,7 +216,7 @@ function laser_battery_page()
|
|||
w.write(w.format_integer(booster.beamFrequency(), 5))
|
||||
w.setColorNormal()
|
||||
w.write(" @ " .. w.format_integer(x - headX, 7) .. " " .. w.format_integer(y - headY, 3) .. " " .. w.format_integer(z - headZ, 7)
|
||||
.. " " .. string.sub(laserbattery.boosterAddresses[key], 10, 100))
|
||||
.. " " .. w.format_address(laserbattery.boosterAddresses[key]))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -424,7 +424,7 @@ function laser_battery_getDescription(laserbattery)
|
|||
end
|
||||
end
|
||||
end
|
||||
return string.sub(laserbattery.name .. " ", 1, 20)
|
||||
return w.format_string(laserbattery.name, 20)
|
||||
.. msg
|
||||
.. " @ " .. w.format_integer(x, 7) .. " " .. w.format_integer(y, 3) .. " " .. w.format_integer(z, 7)
|
||||
end
|
||||
|
@ -514,7 +514,7 @@ function laser_station_page()
|
|||
w.write(w.format_integer(camVideoChannel, 5))
|
||||
w.setColorNormal()
|
||||
w.write(" @ " .. w.format_integer(camX, 7) .. " " .. w.format_integer(camY, 3) .. " " .. w.format_integer(camZ, 7)
|
||||
.. " " .. string.sub(laserstation.cameraAddress, 10, 100))
|
||||
.. " " .. w.format_address(laserstation.cameraAddress))
|
||||
end
|
||||
|
||||
w.setCursorPos(1, 5)
|
||||
|
|
Loading…
Reference in a new issue