diff --git a/src/editor/engine/lua/RobloxShim.js b/src/editor/engine/lua/RobloxShim.js index cb71593..415c353 100644 --- a/src/editor/engine/lua/RobloxShim.js +++ b/src/editor/engine/lua/RobloxShim.js @@ -1698,8 +1698,21 @@ export function registerRobloxShim(lua, opts) { function __rbxl_yield_frame() coroutine.yield(0.05) end - if type(task) == 'table' then - task.wait = rbx_wait + -- task — JS-object из shim ('userdata'/'table'). Сохраняем + -- существующие методы (delay/spawn/defer) и добавляем wait. + if type(task) == 'table' or type(task) == 'userdata' then + local existing = task + local jsDelay = existing.delay + local jsSpawn = existing.spawn + local jsDefer = existing.defer + task = { + wait = rbx_wait, + delay = jsDelay or function(_, fn) if fn then fn() end end, + spawn = jsSpawn or function(fn) if fn then fn() end end, + defer = jsDefer or function(fn) if fn then fn() end end, + synchronize = function() end, + desynchronize = function() end, + } else task = { wait = rbx_wait } end