At this point I've added 100 lines of code to eliminate 2 global variables:
I think this is a worthwhile trade..
3CMM7CXD3QIQCCR3SXXFC4G3O73MDDQKB3G5MUFHQ5EOJLAZWD5AC 442XD5KJVHEBVDFOOL6EQJKSH26NIX2XULWNL7Q3WMF3YCICBP2AC OD3WUB5B7ZQDWBWAYNN6INLWIT5Z7UGMIPCLULS4UX5FVXWHTEZQC 5UNXE4KMGRIKURKCT7O7JZ7QXUWB2MMTJRZJCJ2CVPEDHC237UBAC MYEOA76OV2FPEYWVCSLANO62PG4V7KU2I4MRC2JL4AAGWHKSCIWAC F2P336NOB6PL52DRVGBHW7UG4NUJFRQJWJNMQNX4JE52N5BA7Y5QC OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC ULKNZUZKI5PQM36OHZAJHMZVXSEM7UUEOVZPI55B64UBU3UD3REAC AVTNUQYRBW7IX2YQ3KDLVQ23RGW3BAKTAE7P73ASBYNKOHMQMH5AC T7QIIGQ6YYTTYCVHVEAZSUQ3O4LYBHGPFL4K6D5TA4BA7PND4EJQC PJ5PQAQEEWQDDEPKP3RURCFDX7SSUIH4GZJCDZ6E6UU6G55KB7KAC QMSYY47GBRMJ3FALK2WXLIYZVQ24ZLQXVMEJLQGSU4WSC66D4AZQC QRUFNFPP3EDJDYTAJGUTY6CVIGNKNTSF53YN22RRVMHXDO6MUJOQC 36Z442IVPXHZ7D2QI26YLN3TDDEMDRQ2GKBYQAD6NUHQZVCCY4VAC TBWAE64A6IIDDXKB6LXDI6WQYAAUYP2QRH3KLM3PUILMVL2BFTTAC LXFHXL2NSH7KLRNNN66OPNSU4DXZ6UU2CUPXUHCFEISDB6BY7KDAC ORKN6EOBUFVAD2TXYW5OIKSL55RU24LOFDTTTXHDZUZ57QRDCY7QC IM6GSGVZTVICWIBWRCUXLIMXT3XE3H5LKJ3AITUA4AB3FTW5AJUAC 5WHW3IDOHOBXY3M3QPXNMHFFNXXD6RR5B2WL6TB5TTVNZJYCN2AQC 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' thenlove.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)returnend
local possibly_mutated = live.run(buf)if possibly_mutated thenMode = 'run'if Redo_initialization thenRedo_initialization = nillove.run() -- won't actually replace the event loop;-- we're just running it for its initialization side-effectsendend
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 thenlove.event.pump()for name, a,b,c,d,e,f in love.event.poll() doif name == 'quit' thenreturn a or 0elseif name == 'keypressed' thenerror_frame_keys_down[a] = true-- C-cif a == 'c' and (error_frame_keys_down.lctrl or error_frame_keys_down.rctrl) thenlove.system.setClipboardText(Error_message)endelseif name == 'keyreleased' then-- don't try to recover from initialization errorserror_frame_keys_down[a] = nilendendendlocal dt = love.timer.step()Current_time = Current_time + dtif Current_time - Live.previous_read > 0.1 thenlocal buf = live.receive_from_driver()if buf thenlocal maybe_modified = live.run(buf)if maybe_modified then-- retrylocal success = xpcall(function() App.initialize(love.arg.parseGameArguments(arg), arg) end, live.handle_initialization_error)if success thenApp.run_frame = main_run_framereturnendendendLive.previous_read = Current_timeendlove.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.