Fixed invalid max jump distance in LUA scripts

This commit is contained in:
Unknown 2018-06-02 15:19:20 +02:00
parent 59006bb65a
commit 56848d4dcb
2 changed files with 30 additions and 20 deletions

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,25 +238,30 @@ 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)
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)

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,25 +239,30 @@ 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)
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)