feat: 50 игр на Lua + импорт Roblox для всех + поддержка Lua в плеере #39

Merged
min merged 215 commits from feat/lua-50-games-bundle into main 2026-06-09 21:59:25 +00:00
2 changed files with 9 additions and 13 deletions
Showing only changes of commit 38d135586b - Show all commits

View File

@ -115,8 +115,8 @@ export class LuaSharedSandbox {
// Запускаем main-loop сразу — он начнёт tick'ать как только будут coroutines.
this._lastTickAt = performance.now();
this._startMainLoop();
// Init батчами по 20 с yield между ними, чтобы UI не подвисал на 700+ скриптах.
const BATCH_SIZE = 20;
// Init батчами по 5 с задержкой 20мс между ними, чтобы UI отзывался.
const BATCH_SIZE = 5;
let idx = 0;
const initBatch = () => {
if (this._isStopped) return;
@ -130,7 +130,7 @@ export class LuaSharedSandbox {
}
idx = end;
if (idx < pending.length) {
setTimeout(initBatch, 0);
setTimeout(initBatch, 20);
} else {
// eslint-disable-next-line no-console
console.log(`[LuaSharedSandbox] all ${pending.length} scripts kicked off`);
@ -199,13 +199,11 @@ export class LuaSharedSandbox {
})
local co = coroutine.create(function()
-- WATCHDOG: каждые 100000 инструкций yield 1 кадр.
-- Защищает от tight-loop. yield обёрнут в pcall так как
-- внутри C-call boundary yield бросает ошибку но в этом
-- случае tight-loop наш hook просто будет вызываться позже
-- (когда Lua вернётся из C-call) и yield сработает.
-- НЕ оборачиваем в pcall внутри C-call boundary yield
-- упадёт ошибкой, что прервёт скрипт. Это лучше чем виснуть.
debug.sethook(function()
pcall(coroutine.yield, 0.016)
end, "", 100000)
coroutine.yield(0.016)
end, "", 20000)
-- pcall защищает от runtime-ошибок которые иначе крашат
-- coroutine и могут повредить WASM-стейт. Возвраты
-- handler'а намеренно поглощаются.

View File

@ -1642,11 +1642,9 @@ export function registerRobloxShim(lua, opts) {
-- (ok, ret1, ret2, ...) мы их не используем.
local co = coroutine.create(function()
-- Тот же watchdog что и в _startSingleScript.
-- yield обёрнут в pcall: внутри C-call boundary yield бросает
-- ошибку, но hook будет вызван позже когда Lua вернётся.
debug.sethook(function()
pcall(coroutine.yield, 0.016)
end, "", 100000)
coroutine.yield(0.016)
end, "", 20000)
pcall(fn, a1, a2, a3, a4)
end)
__rbxl_register_coroutine(handlerId, co)