This commit is contained in:
ParticleG
2024-11-01 11:44:17 +08:00
parent 2e537807a7
commit f2e064e900
2 changed files with 1 additions and 11 deletions

View File

@@ -3,7 +3,6 @@ local getCHN,setCHN,triggerCHN=...
local CHN_demand,CHN_getCount=triggerCHN.demand,triggerCHN.getCount local CHN_demand,CHN_getCount=triggerCHN.demand,triggerCHN.getCount
local CHN_push,CHN_pop=triggerCHN.push,triggerCHN.pop local CHN_push,CHN_pop=triggerCHN.push,triggerCHN.pop
love.system = require'love.system'
JS=require'Zframework.js' JS=require'Zframework.js'
local yield=coroutine.yield local yield=coroutine.yield

View File

@@ -7,16 +7,13 @@ local _Request =
timeOut = 2, timeOut = 2,
id = '0' id = '0'
} }
local os = love.system.getOS()
local __defaultErrorFunction = nil local __defaultErrorFunction = nil
local isDebugActive = false local isDebugActive = false
local JS = {} local JS = {}
function JS.callJS(funcToCall) function JS.callJS(funcToCall)
if os == "Web" then print("callJavascriptFunction " .. funcToCall)
print("callJavascriptFunction " .. funcToCall)
end
end end
--You can pass a set of commands here and, it is a syntactic sugar for executing many commands inside callJS, as it only calls a function --You can pass a set of commands here and, it is a syntactic sugar for executing many commands inside callJS, as it only calls a function
@@ -108,9 +105,6 @@ end
--May only be used for functions that don't return a promise --May only be used for functions that don't return a promise
function JS.newRequest(funcToCall, onDataLoaded, onError, timeout, optionalId) function JS.newRequest(funcToCall, onDataLoaded, onError, timeout, optionalId)
if(os ~= "Web") then
return
end
table.insert(__requestQueue, _Request:new(false, funcToCall, onDataLoaded, onError, timeout or 5, optionalId or _requestCount)) table.insert(__requestQueue, _Request:new(false, funcToCall, onDataLoaded, onError, timeout or 5, optionalId or _requestCount))
end end
@@ -119,9 +113,6 @@ end
--Or it can be handled by Lua, it auto sets your data if you write the following command: --Or it can be handled by Lua, it auto sets your data if you write the following command:
-- _$_(yourStringOrFunctionHere) -- _$_(yourStringOrFunctionHere)
function JS.newPromiseRequest(funcToCall, onDataLoaded, onError, timeout, optionalId) function JS.newPromiseRequest(funcToCall, onDataLoaded, onError, timeout, optionalId)
if(os ~= "Web") then
return
end
optionalId = optionalId or _requestCount optionalId = optionalId or _requestCount
funcToCall = funcToCall:gsub("_$_%(", "FS.writeFile('"..love.filesystem.getSaveDirectory().."/__temp"..optionalId.."', ") funcToCall = funcToCall:gsub("_$_%(", "FS.writeFile('"..love.filesystem.getSaveDirectory().."/__temp"..optionalId.."', ")
table.insert(__requestQueue, _Request:new(true, funcToCall, onDataLoaded, onError, timeout or 5, optionalId)) table.insert(__requestQueue, _Request:new(true, funcToCall, onDataLoaded, onError, timeout or 5, optionalId))