feat: 50 игр на Lua + импорт Roblox для всех + поддержка Lua в плеере #39
@ -1744,20 +1744,20 @@ export function registerRobloxShim(lua, opts) {
|
|||||||
function __rbxl_drain_handler(fn, a1, a2, a3, a4)
|
function __rbxl_drain_handler(fn, a1, a2, a3, a4)
|
||||||
__rbxl_next_handler_id = __rbxl_next_handler_id + 1
|
__rbxl_next_handler_id = __rbxl_next_handler_id + 1
|
||||||
local handlerId = "handler_" .. __rbxl_next_handler_id
|
local handlerId = "handler_" .. __rbxl_next_handler_id
|
||||||
-- Оборачиваем call в pcall чтобы поглотить return value handler'а
|
__log("warn", "[drain] starting handler " .. handlerId)
|
||||||
-- (RayGun возвращает :connect(...) объект как последнее выражение,
|
|
||||||
-- что приводит к wasmoon promise-detection crash). pcall возвращает
|
|
||||||
-- (ok, ret1, ret2, ...) — мы их не используем.
|
|
||||||
local co = coroutine.create(function()
|
local co = coroutine.create(function()
|
||||||
-- Тот же watchdog что и в _startSingleScript.
|
|
||||||
debug.sethook(function()
|
debug.sethook(function()
|
||||||
coroutine.yield(0.016)
|
coroutine.yield(0.016)
|
||||||
end, "", 20000)
|
end, "", 20000)
|
||||||
pcall(fn, a1, a2, a3, a4)
|
local ok, err = pcall(fn, a1, a2, a3, a4)
|
||||||
|
if not ok then
|
||||||
|
__log("error", "[drain handler error] " .. tostring(err))
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
__rbxl_register_coroutine(handlerId, co)
|
__rbxl_register_coroutine(handlerId, co)
|
||||||
local ok, ret = coroutine.resume(co)
|
local ok, ret = coroutine.resume(co)
|
||||||
if not ok then
|
if not ok then
|
||||||
|
__log("error", "[drain resume error] " .. tostring(ret))
|
||||||
__rbxl_send_error(handlerId, tostring(ret))
|
__rbxl_send_error(handlerId, tostring(ret))
|
||||||
__rbxl_unregister_coroutine(handlerId)
|
__rbxl_unregister_coroutine(handlerId)
|
||||||
elseif type(ret) == 'number' then
|
elseif type(ret) == 'number' then
|
||||||
@ -1765,7 +1765,6 @@ export function registerRobloxShim(lua, opts) {
|
|||||||
elseif coroutine.status(co) == 'dead' then
|
elseif coroutine.status(co) == 'dead' then
|
||||||
__rbxl_unregister_coroutine(handlerId)
|
__rbxl_unregister_coroutine(handlerId)
|
||||||
end
|
end
|
||||||
-- Явно ничего не возвращаем чтобы wasmoon не оборачивал nil
|
|
||||||
end
|
end
|
||||||
`);
|
`);
|
||||||
// Кешируем ссылку на Lua-функцию запуска handler'а
|
// Кешируем ссылку на Lua-функцию запуска handler'а
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user