From: Stephen Seo Date: Wed, 18 Jan 2023 07:24:36 +0000 (+0900) Subject: Re-fix first load bug (hopefully) X-Git-Url: https://git.seodisparate.com/stephenseo/LD53?a=commitdiff_plain;h=f7dc407bcbf36af3da4c8a5dc844d3c157702972;p=RockPaperScissorsDuel Re-fix first load bug (hopefully) --- diff --git a/wasm_build/client.js b/wasm_build/client.js index b083598..04d3196 100644 --- a/wasm_build/client.js +++ b/wasm_build/client.js @@ -1,5 +1,4 @@ -// Use setTimeout to give the .wasm binary time to load first. -setTimeout(() => { +function do_rune_init() { Rune.initClient({ visualUpdate: ({ newGame, yourPlayerId}) => { const { player1, player2, first_choices, second_choices, ready, matchup_done, pos, prev_pos, gameover, gameover_called, matchup_started } = newGame; @@ -56,4 +55,14 @@ Rune.initClient({ } }, }); -}, 500); +} + +let em_checking_interval_id = setInterval( + () => { + if (Module !== undefined && Module.ccall !== undefined) { + do_rune_init(); + clearInterval(em_checking_interval_id); + console.log("Rune initialized!"); + } + }, 500 +);