From b555c44b8bd0e2fc55826c51ada92dc6f560d908 Mon Sep 17 00:00:00 2001 From: ParticleG Date: Thu, 31 Oct 2024 16:54:01 +0800 Subject: [PATCH] - Update sources --- Zframework/init.lua | 7 ++++--- Zframework/js.lua | 17 +++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index 0bf93131..8604a7e3 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -213,10 +213,11 @@ if JS then ]] ), function(data) print("In callback: " .. data); res=data end) repeat - love.timer.sleep(0.01) - JS.retrieveData(0.01) + love.timer.sleep(1) + JS.retrieveData(1) + print("In lua: " .. res) + print(JS) until res - print("In lua: " .. res) return res end end diff --git a/Zframework/js.lua b/Zframework/js.lua index e594fb4e..f353eb46 100644 --- a/Zframework/js.lua +++ b/Zframework/js.lua @@ -1,6 +1,6 @@ -local __requestQueue = {} -local _requestCount = 0 -local _Request = +__requestQueue = {} +_requestCount = 0 +_Request = { command = "", currentTime = 0, @@ -11,7 +11,7 @@ local os = love.system.getOS() local __defaultErrorFunction = nil local isDebugActive = false -local JS = {} +JS = {} function JS.callJS(funcToCall) 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 --Return statement is possible inside this structure --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, ...) str = "(function(){"..str.."})()" if(#arg > 0) then - str = str:format(unpack(arg)) + str = str:format(_unpack(arg)) end str = str:gsub("[\n\t]", "") return str