- Update sources

This commit is contained in:
ParticleG
2024-10-31 16:54:01 +08:00
parent d0c503e096
commit b555c44b8b
2 changed files with 15 additions and 9 deletions

View File

@@ -213,10 +213,11 @@ if JS then
]] ]]
), function(data) print("In callback: " .. data); res=data end) ), function(data) print("In callback: " .. data); res=data end)
repeat repeat
love.timer.sleep(0.01) love.timer.sleep(1)
JS.retrieveData(0.01) JS.retrieveData(1)
print("In lua: " .. res)
print(JS)
until res until res
print("In lua: " .. res)
return res return res
end end
end end

View File

@@ -1,6 +1,6 @@
local __requestQueue = {} __requestQueue = {}
local _requestCount = 0 _requestCount = 0
local _Request = _Request =
{ {
command = "", command = "",
currentTime = 0, currentTime = 0,
@@ -11,7 +11,7 @@ local os = love.system.getOS()
local __defaultErrorFunction = nil local __defaultErrorFunction = nil
local isDebugActive = false local isDebugActive = false
local JS = {} JS = {}
function JS.callJS(funcToCall) function JS.callJS(funcToCall)
if(os == "Web") then if(os == "Web") then
@@ -23,11 +23,16 @@ end
--If you pass arguments to the func beyond the string, it will perform automatically string.format --If you pass arguments to the func beyond the string, it will perform automatically string.format
--Return statement is possible inside this structure --Return statement is possible inside this structure
--This will return a string containing a function to be called by JS.callJS --This will return a string containing a function to be called by JS.callJS
local _unpack
if(_VERSION == "Lua 5.1" or _VERSION == "LuaJIT") then
_unpack = unpack
else
_unpack = table.unpack
end
function JS.stringFunc(str, ...) function JS.stringFunc(str, ...)
str = "(function(){"..str.."})()" str = "(function(){"..str.."})()"
if(#arg > 0) then if(#arg > 0) then
str = str:format(unpack(arg)) str = str:format(_unpack(arg))
end end
str = str:gsub("[\n\t]", "") str = str:gsub("[\n\t]", "")
return str return str