# Pastebin 4KvmSnFU local function auth(client, data) -- Authentication here end local function run(client, data) -- Running code here end local dispatch = { ["auth"] = do_auth, ["run"] = do_run} ...... somewhere down in the code later: ...... local state = "auth" while true do data = get_next_packet() state = dispatch[state](client, data) end