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 24 additions and 2 deletions
Showing only changes of commit 3e20107125 - Show all commits

View File

@ -129,11 +129,17 @@ export class LuaSharedSandbox {
// Регистрируем coroutine в __rbxl_coroutines с id для возобновления. // Регистрируем coroutine в __rbxl_coroutines с id для возобновления.
// Скрипт оборачиваем в coroutine. task.wait()→coroutine.yield(sec) возвращает // Скрипт оборачиваем в coroutine. task.wait()→coroutine.yield(sec) возвращает
// delay из resume → планируем следующий resume через scheduleResume. // delay из resume → планируем следующий resume через scheduleResume.
// Fallback Parent = workspace для скриптов без target (или с невалидным
// target). Это спасает массу Roblox-скриптов которые делают
// script.Parent.Parent — если бы Parent был nil, упало бы сразу.
const parentExpr = primId != null
? `(__rbxl_get_part_by_id(${Number(primId)}) or workspace)`
: 'workspace';
const wrapped = ` const wrapped = `
do do
local script = { local script = {
Name = ${JSON.stringify(scriptName)}, Name = ${JSON.stringify(scriptName)},
Parent = ${primId != null ? `__rbxl_get_part_by_id(${Number(primId)})` : 'nil'}, Parent = ${parentExpr},
ClassName = "Script", ClassName = "Script",
Disabled = false, Disabled = false,
Source = nil, Source = nil,

View File

@ -191,7 +191,23 @@ function makeInstanceMethods() {
while (p) { if (p.ClassName === cls) return p; p = p.Parent; } while (p) { if (p.ClassName === cls) return p; p = p.Parent; }
return undefined; return undefined;
}, },
WaitForChild: function (name) { return this.FindFirstChild(name); }, WaitForChild: function (name) {
// В Roblox WaitForChild блокирует пока ребёнок не появится. У нас
// нет yield с произвольных JS-функций, поэтому возвращаем либо
// существующего ребёнка, либо ленивый stub-Folder чтобы избежать
// падений типа "attempt to index a nil value" в импортированных
// скриптах. Stub автоматически добавляется в Children.
const existing = this.FindFirstChild(name);
if (existing) return existing;
try {
const stub = newInstance('Folder', String(name));
stub.Parent = this;
if (this.Children) this.Children.push(stub);
return stub;
} catch (_) {
return undefined;
}
},
IsA: function (cls) { return this.ClassName === cls || cls === 'Instance'; }, IsA: function (cls) { return this.ClassName === cls || cls === 'Instance'; },
GetFullName: function () { GetFullName: function () {
const parts = []; const parts = [];