submit_definition = function(State) -- TODO: don't hang if you lose connection to client app here -- always clear error on 'F4' State.load_time_error = nil if empty_editor(State) then return end -- send definition to app and check for any load-time errors live.send_definition_to_app(State) local response = wait_for_response() Client_app_test_failures = json.decode(response) if Load_time_error then State.load_time_error = Load_time_error Load_time_error = nil end -- wait a little (~0.1s) for any immediate run-time errors for i=1,10 do if live.receive_run_time_error_from_app() then break end love.timer.sleep(0.01) end -- now both errors likely to be available to on.code_submit if on.code_submit then on.code_submit(State) end end