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B5TTVNZJYCN2AQC
LRDM35CEK3OHXOTB7TEFJRL7P6PQWO5ZG3F2BVA7DIDFHBPJQ7KAC
YONFBSVBBNIARWDVDBG56GDPTLC6N25TLDTCVVZZ6AHBZG42H7ZAC
WZZGVKSGCAEPDTHCT4IKNNAWDHUEATGOAT4FBLQUPF64CSJSNVJQC
ZM6AON3AYYLI75CD3P62YU62KKN4KWXLWPNWZ44XM4KCQ42JEUUQC
BJ5X5O4ACBBJ56LRBBSTCW6IBQP4HAEOOOPNH3SKTA4F66YTOIDAC
TVSDIF6DIKJNK6IHHNHLKEO56GY4HS7LVQGJQ4GMNS2RF4YJJ2NAC
Mode = 'error'
Error_message = ("This app hasn't been tested with LÖVE version %s; please use version %s if you run into errors. Press a key to try recovering.\n\n%s"):format(Version, Supported_versions[1], Error_message)
print(Error_message)
if Mode == 'error' then
love.graphics.setColor(0,0,1)
love.graphics.rectangle('fill', 0,0, App.screen.width, App.screen.height)
love.graphics.setColor(1,1,1)
love.graphics.printf(Error_message, 40,40, 600)
return
end
local possibly_mutated = live.run(buf)
if possibly_mutated then
Mode = 'run'
if Redo_initialization then
Redo_initialization = nil
love.run() -- won't actually replace the event loop;
-- we're just running it for its initialization side-effects
end
end
live.run(buf)
end
-- one iteration of the event loop when showing an error
-- return nil to continue the event loop, non-nil to quit
-- We don't run this within handle_error because a second error in
-- handle_error will crash.
function initialization_error_run_frame()
if love.event then
love.event.pump()
for name, a,b,c,d,e,f in love.event.poll() do
if name == 'quit' then
return a or 0
elseif name == 'keypressed' then
error_frame_keys_down[a] = true
-- C-c
if a == 'c' and (error_frame_keys_down.lctrl or error_frame_keys_down.rctrl) then
love.system.setClipboardText(Error_message)
end
elseif name == 'keyreleased' then
-- don't try to recover from initialization errors
error_frame_keys_down[a] = nil
end
end
end
local dt = love.timer.step()
Current_time = Current_time + dt
if Current_time - Live.previous_read > 0.1 then
local buf = live.receive_from_driver()
if buf then
local maybe_modified = live.run(buf)
if maybe_modified then
-- retry
local success = xpcall(function() App.initialize(love.arg.parseGameArguments(arg), arg) end, live.handle_initialization_error)
if success then
App.run_frame = main_run_frame
return
end
end
end
Live.previous_read = Current_time
end
love.graphics.origin()
love.graphics.clear(0,0,1)
love.graphics.setColor(1,1,1)
love.graphics.printf(Error_message, 40,40, 600)
love.graphics.present()
love.timer.sleep(0.001)
-- returning nil continues the loop
- create a couple of spuriously failing tests. Run with an untested version of LÖVE. Error message includes message about untested version.
- create a failing test. Start app. See test failure. Fix using driver.love
- include an error in on.initialize. Start app. See error message. Fix on.initialize using driver.love.