- Wait until data is available

This commit is contained in:
ParticleG
2024-10-31 16:23:07 +08:00
parent 881d43c56d
commit 9ec2182252

View File

@@ -93,7 +93,10 @@ SFX= require'Zframework.sfx'
IMG= require'Zframework.image' IMG= require'Zframework.image'
BGM= require'Zframework.bgm' BGM= require'Zframework.bgm'
VOC= require'Zframework.voice' VOC= require'Zframework.voice'
JS= SYSTEM == 'Web' and require'Zframework.js' or NULL
if SYSTEM=='Web' then
JS=require'Zframework.js'
end
local ms,kb=love.mouse,love.keyboard local ms,kb=love.mouse,love.keyboard
local KBisDown=kb.isDown local KBisDown=kb.isDown
@@ -197,7 +200,7 @@ if JS then
end end
love.system.getClipboardText = function () love.system.getClipboardText = function ()
local res="" local res
JS.newPromiseRequest(JS.stringFunc( JS.newPromiseRequest(JS.stringFunc(
[[ [[
window.navigator.clipboard window.navigator.clipboard
@@ -209,6 +212,7 @@ if JS then
}); });
]] ]]
), function(data) print("In callback: " .. data); res=data end) ), function(data) print("In callback: " .. data); res=data end)
repeat love.timer.sleep(0.01) until res
print("In lua: " .. res) print("In lua: " .. res)
return res return res
end end
@@ -742,10 +746,6 @@ function love.run()
local dt=time-lastFrame local dt=time-lastFrame
lastFrame=time lastFrame=time
if JS and JS.retrieveData(dt) then
return
end
-- EVENT -- EVENT
PUMP() PUMP()
for N,a,b,c,d,e in POLL() do for N,a,b,c,d,e in POLL() do