yield
Definition
-- @/=[C]:-1
function yield(...)
Callers
@/lua/console/bananabench-async.lua
do
coroutine.yield()
end
@/lua/ge/extensions/core/jobsystem.lua
...
job.yield() - give teh game time to render a new frame
...
...
job.yield()
...
maxdt is the time it will yield. So i.e. 1 second means that it will try to yield every time 1 second passed.
Important: It will not interrupt things, so if your code runs for 10 seconds without job.yield(), then the jobsystem cannot do anything. Consider adding more yield's.
--]==]
--print(" *** yield taken ***: " .. tostring(dt))
coroutine.yield()
res.hp:reset()
repeat
coroutine.yield()
local dt = res.hp:stop() / 1000
@/lua/ge/extensions/editor/dynamicDecals/settings.lua
local function updateShapeMeshesJob()
coroutine.yield()
shapeMeshes = api.getShapeMeshes()
@/lua/vehicle/extensions/escMeasurement.lua
-- end
-- coroutine.yield()
-- dt = 0
-- end
coroutine.yield()
end
@/lua/common/libs/luasocket/socket/smtp.lua
end
coroutine.yield(h)
end
if mesgt.body.preamble then
coroutine.yield(mesgt.body.preamble)
coroutine.yield("\r\n")
coroutine.yield(mesgt.body.preamble)
coroutine.yield("\r\n")
end
for i, m in base.ipairs(mesgt.body) do
coroutine.yield("\r\n--" .. bd .. "\r\n")
send_message(m)
-- send last boundary
coroutine.yield("\r\n--" .. bd .. "--\r\n\r\n")
-- send epilogue
if mesgt.body.epilogue then
coroutine.yield(mesgt.body.epilogue)
coroutine.yield("\r\n")
coroutine.yield(mesgt.body.epilogue)
coroutine.yield("\r\n")
end
local chunk, err = mesgt.body()
if err then coroutine.yield(nil, err)
elseif chunk then coroutine.yield(chunk)
if err then coroutine.yield(nil, err)
elseif chunk then coroutine.yield(chunk)
else break end
-- send body from string
coroutine.yield(mesgt.body)
end
@/lua/ge/extensions/editor/assetDeduplicator.lua
end
job.yield()
end
if not FS:isLinkFile(filename) then
job.yield()
local hash = FS:hashFileSHA1(filename)
local fileSize = FS:fileSize(filename)
job.yield()
job.yield()
job.yield()
job.yield()
cacheData['assets'][filename] = {hash, fileSize, isOfficialContentVPath(filename)}
job.processed = job.processed + 1
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
if not FS:isLinkFile(filename) then
job.yield()
local hash = FS:hashFileSHA1(filename)
local fileSize = FS:fileSize(filename)
job.yield()
job.yield()
job.yield()
job.yield()
cacheData['art'][filename] = {hash, fileSize, isOfficialContentVPath(filename)}
job.processed = job.processed + 1
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
end
job.yield()
job.yield()
job.yield()
job.yield()
end
if not FS:isLinkFile(filename) then
job.yield()
local hash = FS:hashFileSHA1(filename)
local fileSize = FS:fileSize(filename)
job.yield()
cacheData['stockLevels'][path][filename] = {hash, fileSize, isOfficialContentVPath(filename)}
job.processed = job.processed + 1
job.yield()
job.yield()
job.yield()
job.yield()
end
end
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
end
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
if not FS:isLinkFile(filename) then
job.yield()
local hash = FS:hashFileSHA1(filename)
local fileSize = FS:fileSize(filename)
job.yield()
cacheData['modLevels'][path][filename] = {hash, fileSize, isOfficialContentVPath(filename)}
job.processed = job.processed + 1
job.yield()
job.yield()
job.yield()
job.yield()
end
end
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
if not FS:isLinkFile(filename) then
job.yield()
local hash = FS:hashFileSHA1(filename)
local fileSize = FS:fileSize(filename)
job.yield()
job.yield()
job.yield()
job.yield()
cacheData['currentLevel'][currentLevelId][filename] = {hash, fileSize}
job.processed = job.processed + 1
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
end
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
for p in pairs(currentLevelData) do
job.yield()
currentLevelRoot = p:match("^(/levels/[^/]+/)")
end
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
end
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
end
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
end
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
list[#list + 1] = path
job.yield()
job.yield()
job.yield()
job.yield()
end
end
job.yield()
job.yield()
job.yield()
job.yield()
end
end
job.yield()
job.yield()
job.yield()
job.yield()
end
job.allfiles = job.allfiles + 1
job.yield()
end
end
job.yield()
end
end
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
end
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
entry.assets[#entry.assets + 1] = assetMatches[i]
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
entry.art[#entry.art + 1] = artMatches[i]
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
entry.stock[#entry.stock + 1] = stockMatches[i]
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
entry.mod[#entry.mod + 1] = modMatches[i]
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
job.yield()
end
end
job.yield()
job.yield()
job.yield()
job.yield()
job.processed = job.processed + 1
end
job.yield()
job.yield()
job.yield()
job.yield()
end
end
job.yield()
job.matches = matches
@/lua/ge/extensions/editor/assetBrowser.lua
shapePrev:fitToShape()
coroutine.yield()
coroutine.yield()
coroutine.yield()
coroutine.yield()
coroutine.yield()
coroutine.yield()
coroutine.yield()
shapePrev:renderWorld(var.meshPreviewCacheThumbnailRect)
shapePrev:renderWorld(var.meshPreviewCacheThumbnailRect)
coroutine.yield()
local bitmap = GBitmap()
if job.args[1].d then
coroutine.yield()
createFileStats(job.args[1].d)
if job.args[1].n then
coroutine.yield()
createFileStats(job.args[1].n)
if job.args[1].s then
coroutine.yield()
createFileStats(job.args[1].s)
else
coroutine.yield()
createInspectorData(job.args[1])
createInspectorData(job.args[1])
coroutine.yield()
createFileStats(job.args[1])
core_jobsystem.create(createAssetDataJob, 1, asset)
coroutine.yield()
end
createAssetData(file, job.args[2])
coroutine.yield()
end
createAssetData(file)
coroutine.yield()
end
for _, dir in ipairs(parent.dirs) do
coroutine.yield()
getDirs(dir)
coroutine.yield()
end
coroutine.yield()
getTextureSets(parent)
for _, dir in ipairs(parent.dirs) do
coroutine.yield()
getDirsAndFiles(dir)
coroutine.yield()
end
@/lua/ge/extensions/util/compileImposters.lua
while Engine.Platform.getSystemTimeMS() - startTime < (seconds * 1000) do
job.yield()
end
log('D', 'compileImposters', 'Moving on to next level.')
job.yield()
@/lua/ge/extensions/editor/assetManagementTool.lua
if idx % updateIntervalCount == 0 then
coroutine.yield()
end
progress = i / total
coroutine.yield()
message = "Gathering files from: " .. folder
coroutine.yield()
progress = (folderIndex - 1) / totalFolders
coroutine.yield()
updateCounter = 0
progress = (folderIndex - 1) / totalFolders
coroutine.yield()
message = "Adding duplicate files for: " .. asset.paths[1]
coroutine.yield()
updateCounter = 0
message = "Gathering link files from: " .. folder
coroutine.yield()
filenames = FS:findLinkFiles(folder, -1, true, false)
progress = (folderIndex - 1) / totalFolders
coroutine.yield()
updateCounter = 0
progress = (folderIndex - 1) / totalFolders
coroutine.yield()
message = "Gathering file hashes from common /assets folder..."
coroutine.yield()
filenames = FS:findFiles("/assets", "*.*", -1, true, false)
progress = (i - 1) / totalFileCount
coroutine.yield()
updateCounter = 0
if stopped then break end
coroutine.yield()
end
progress = (i - 1) / totalInvalidLinkFiles
coroutine.yield()
updateCounter = 0
message = "Gathering file names from: " .. searchPath
coroutine.yield()
filenames = FS:findFiles(searchPath, filter, depth, true, true)
progress = (i - 1) / totalFilenames
coroutine.yield()
updateCounter = 0
coroutine.yield()
message = "Gathering link file names from: " .. delinkPath
coroutine.yield()
local filenames = FS:findLinkFiles(delinkPath, depth, true, true)
progress = (i - 1) / totalFilenames
coroutine.yield()
updateCounter = 0
table.insert(delinkFilenames, fileInfo)
coroutine.yield()
message = "Gathering link file names from: " .. relinkPath
coroutine.yield()
local filenames = FS:findLinkFiles(relinkPath, depth, true, true)
progress = (i - 1) / totalFilenames
coroutine.yield()
updateCounter = 0
table.insert(relinkFilenames, fileInfo)
coroutine.yield()
@/lua/ge/extensions/tech/capturePlayer.lua
if response == nil then
job.yield()
elseif type ~= nil and response.type ~= type then
elseif type ~= nil and response.type ~= type then
job.yield()
else
if not processMore then
job.yield()
end
job.yield()
-- last request is forcefully waited for, so we know we can cleanup
@/lua/ge/extensions/util/docCreator.lua
FS:copyFile(v, outFilename)
job.yield()
end
end
job.yield()
end
@/lua/ge/extensions/editor/resourceChecker/resourceUtil.lua
end
if job then job.yield() end
end
if strEnds(fn, 'materials.cs') or strEnds(fn, 'materials.json') then
job.yield()
objects = loadMaterialObjectsFromFile(fn)
if obj.___type == "class" then
job.yield()
local name = obj:getName()
for k,v in pairs(isOld) do
job.yield()
table.insert(output, k.." in: "..v)
end
job.yield()
end
if mat and mat.persistentId then
job.yield()
outdatedFiles[path] = true
if abort(job) then return end
job.yield()
matData[fn] = {}
log('I', '', 'parsing all materials file: ' .. tostring(fn))
job.yield()
for _, obj in ipairs(objects) do
if abort(job) then return end
job.yield()
if obj.___type == "class" then
for m,d in pairs(v) do
job.yield()
local dir, basefilename, ext = path.splitWithoutExt(d)
if abort(job) then return end
job.yield()
matData[fn] = {}
for _, obj in ipairs(objects) do
job.yield()
if obj.___type == "class" then
if abort(job) then return end
job.yield()
if d and d ~= "" and FS:fileExists(d) then
if abort(job) then return end
job.yield()
objects = loadMaterialObjectsFromFile(fn)
if not tableIsEmpty(objects) then
job.yield()
log('I', '', 'parsing all materials file: ' .. tostring(fn))
if job.progress < 50 then job.progress = job.progress + 0.001 end
job.yield()
if obj.___type == "class" then
if job.progress < 75 then job.progress = job.progress + 0.01 end
job.yield()
local shapeLoader = ShapePreview()
if job.progress < 90 then job.progress = job.progress + 0.01 end
job.yield()
if (luaType(v[1]) == "table") then
if job.progress < 50 then job.progress = job.progress + 0.01 end
job.yield()
local m = scenetree.findObject(v)
if job.progress < 90 then job.progress = job.progress + 0.01 end
job.yield()
log('I', '', 'Found shape '..k )
if job.progress < 50 then job.progress = job.progress + 0.01 end
job.yield()
local m = scenetree.findObject(v)
if job.progress < 90 then job.progress = job.progress + 0.01 end
job.yield()
log('I', '', 'Found ForestItem '..k )
if abort(job) then return end
job.yield()
local m = scenetree.findObject(v)
if abort(job) then return end
job.yield()
table.insert(shapes, k)
if abort(job) then return end
job.yield()
if FS:fileSize(fn) > 0 then
for line in f:lines() do
job.yield()
if line:match('shapeName') then
for line in f:lines() do
job.yield()
local data = json.decode(line)
if abort(job) then return end
job.yield()
local m = scenetree.findObject(v)
if abort(job) then return end
job.yield()
if FS:fileExists(k) then
for _,v in pairs(meshNames2) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(objmatTable) do
job.yield()
if (luaType(v) == "table") then
for _,v in pairs(meshNames3) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(terrainMats) do
job.yield()
for _,vv in pairs(v) do
for _,v in pairs(meshNames4) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(meshNames5) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(meshNames6) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(meshNames7) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(meshNames8) do
job.yield()
local m = scenetree.findObject(v)
for _, fn in ipairs(materialFiles) do
job.yield()
for _,b in ipairs(blacklist) do
for path, mats in pairs(matTable) do
job.yield()
for k,v in pairs(mats) do
for k,_ in pairs(mats) do
job.yield()
k = string.lower(k)
for k,v in pairs(materialFilesdata) do
job.yield()
if not (mats[string.lower(k)] or mats[string.lower(v)]) then
for k,_ in pairs(unused) do
job.yield()
local m = scenetree.findObject(k)
for k,_ in pairs(unused) do
job.yield()
local m = scenetree.findObject(k)
for _,v in pairs(prefabInstances) do
job.yield()
local m = scenetree.findObject(v)
if abort(job) then return end
job.yield()
if FS:fileSize(fn) > 0 then
for line in f:lines() do
job.yield()
if line:match('shapeName') then
for line in f:lines() do
job.yield()
local data = json.decode(line)
if abort(job) then return end
job.yield()
local m = scenetree.findObject(v)
if abort(job) then return end
job.yield()
if FS:fileExists(k) then
for _,v in pairs(meshNames2) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(objmatTable) do
job.yield()
if (luaType(v) == "table") then
for _,v in pairs(meshNames3) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(terrainMats) do
job.yield()
for _,vv in pairs(v) do
for _,v in pairs(meshNames4) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(meshNames5) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(meshNames6) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(meshNames7) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(meshNames8) do
job.yield()
local m = scenetree.findObject(v)
for k,_ in pairs(mats) do
job.yield()
local mat = scenetree.findObject(k)
for k,v in pairs(mats) do
job.yield()
if v == true or v == false then
for k,v in pairs(mats) do
job.yield()
table.insert(shapes, {k.." used: "..tostring(v[2]).." times. Textures memory usage: "..string.format("%.2f", v[1]/1048576).." MB", v[1]})
for _,v in pairs(prefabInstances) do
job.yield()
local m = scenetree.findObject(v)
if abort(job) then return end
job.yield()
if FS:fileSize(fn) > 0 then
for line in f:lines() do
job.yield()
local data = json.decode(line)
if forestObject then
job.yield()
for _,v in pairs(forestObject:getData():getItems()) do
for _,v in pairs(meshNames) do
job.yield()
local m = scenetree.findObject(v)
if abort(job) then return end
job.yield()
if FS:fileExists(k) then
for k,v in pairs(staticInstances) do
job.yield()
local colMeshInst, visMeshInst = 0, 0
if abort(job) then return end
job.yield()
if FS:fileSize(fn) > 0 then
for line in f:lines() do
job.yield()
if line:match('shapeName') then
for line in f:lines() do
job.yield()
local data = json.decode(line)
if abort(job) then return end
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(meshNames2) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(forestFiles) do
job.yield()
if FS:fileSize(v) > 0 then
for _,v in pairs(meshNames3) do
job.yield()
local m = scenetree.findObject(v)
for k,v in pairs(forestModels) do
job.yield()
if forestInternals[k] then
for k,_ in pairs(models) do
job.yield()
local dir, basefilename, ext = path.splitWithoutExt(k)
for k,_ in pairs(models) do
job.yield()
k = string.lower(k)
for _,v in pairs(meshFiles) do
job.yield()
local dir, basefilename, ext = path.splitWithoutExt(v)
for k,_ in pairs(unused) do
job.yield()
if forestShapes[string.lower(k)] then
for k,_ in pairs(unused) do
job.yield()
if forestShapes[string.lower(k)] then
for _,v in pairs(meshNames) do
job.yield()
local m = scenetree.findObject(v)
if abort(job) then return end
job.yield()
local m = scenetree.findObject(v)
for k,f in pairs(m:getFields()) do
job.yield()
if f["type"] == "filename" then
for _,v in pairs(meshNames3) do
job.yield()
local m = scenetree.findObject(v)
for k,f in pairs(m:getFields()) do
job.yield()
if f["type"] == "filename" then
for _,v in pairs(meshNames4) do
job.yield()
local m = scenetree.findObject(v)
for k,f in pairs(m:getFields()) do
job.yield()
if f["type"] == "filename" then
for _,v in pairs(meshNames5) do
job.yield()
local m = scenetree.findObject(v)
for k,f in pairs(m:getFields()) do
job.yield()
if f["type"] == "filename" then
for _,v in pairs(meshNames6) do
job.yield()
local m = scenetree.findObject(v)
for _,v in pairs(meshNames7) do
job.yield()
local m = scenetree.findObject(v)
for k,f in pairs(m:getFields()) do
job.yield()
if f["type"] == "filename" then
for _,v in pairs(meshNames8) do
job.yield()
local m = scenetree.findObject(v)
for k,f in pairs(m:getFields()) do
job.yield()
if f["type"] == "filename" then
for k,v in pairs(meshNames9) do
job.yield()
if k == "previews" then
for k,_ in pairs(textures) do
job.yield()
if k and k ~= "" then
for _,v in pairs(texFiles) do
job.yield()
for _,b in ipairs(blacklist) do
for k,_ in pairs(unused) do
job.yield()
table.insert(shapes, k)
for k,_ in pairs(unused) do
job.yield()
table.insert(toRemove, k)
end
if job then job.yield() end
end)
end
if job then job.yield() end
end)
end
if job then job.yield() end
if abort(job) then return end
jsonWriteFile(file, materialFile, true)
job.yield()
if abort(job) then return end
if job.progress < 98 then job.progress = job.progress + 0.1 end
job.yield()
if abort(job) then return end
job.progress = 5
job.yield()
job.progress = 15
job.yield()
job.progress = 35
job.yield()
if abort(job) then return {} end
job.yield()
local sz = safeFileSize(p) or 0
job.progress = 55
job.yield()
if abort(job) then return end
job.yield()
local m = scenetree.findObject(v)
if abort(job) then return end
job.yield()
if strEnds(fn, 'prefab.json') then
if abort(job) then return end
job.yield()
local o = scenetree.findObject(name)
if abort(job) then return end
job.yield()
local cache = nil
if abort(job) then return end
job.yield()
local o = scenetree.findObject(name)
if abort(job) then return end
job.yield()
local o = scenetree.findObject(name)
if abort(job) then return end
job.yield()
local o = scenetree.findObject(name)
if abort(job) then return end
job.yield()
local o = scenetree.findObject(name)
if abort(job) then return end
job.yield()
local mat = scenetree.findObject(matName)
job.progress = 85
job.yield()
@/lua/ge/extensions/util/calibrateESC.lua
-- Replace the vehicle
job.yield()
log("I", logTag, "1")
core_vehicles.replaceVehicle(vehName, {config = config})
job.yield()
local newVehicle = oldVehicle
while newVehicle == oldVehicle or newVehicle == nil do
job.yield()
newVehicle = getPlayerVehicle(0)
end
job.yield()
end
@/lua/ge/extensions/core/modmanager.lua
end
job.yield()
end
end
--Engine.Platform.repaintCanvas() -- This repaint must happen *after* the first yield (rather than before); Otherwise imgui is not properly initialized, which can lead to crashes somewhere else. For instance, it made career imgui UI crash on the first frame after ctrl+L)
end
guihooks.trigger('checkUpdateCheckedMod', "SYNC "..tostring(core_modmanager.getModNameFromID(v.id) or v.filename:gsub(".zip","")) )
job.yield()
end
@/lua/vehicle/extensions/dynamicVehicleData.lua
while timer <= start + seconds do
coroutine.yield()
end
speed = electrics.values.airspeed
coroutine.yield()
end
coroutine.yield()
end
while not cruiseControl.hasReachedTargetSpeed do
coroutine.yield()
input.event("throttle", 0, 1)
coroutine.yield()
until (electrics.values.airspeed <= hundredKmh) --wait for the car to start slowing down before actually timing it
end
coroutine.yield()
end
end
coroutine.yield()
end
@/lua/ge/extensions/editor/api/dynamicDecals.lua
if not decalProjection then return end
coroutine.yield()
@/lua/ge/extensions/core/multiSpawn.lua
if job then
job.yield()
end
@/lua/ge/extensions/util/compileMeshes.lua
for i = 1, #files do
job.yield() -- lets give the game some time and space :)
local f = files[i]
log('D', 'work', 'allFilesCheckOnly : ' .. dumps(i).."/"..dumps(#allFilesCheckOnly))
--job.yield()
end
@/lua/ge/extensions/editor/levelValidator.lua
end
job.yield()
end
end
job.yield()
end
end
job.yield()
if forestData then
end
job.yield()
end
setNodesPlanted(node)
job.yield()
end
end
job.yield()
setNodesPlanted(node)
job.yield()
end
end
job.yield()
end
end
job.yield()
for _, node in pairs(forestItemNodes) do
table.insert(objectLogs, {logLevel = "W", type = "floating", forestItem = node.obj, message = "This forest item is floating: " .. node.obj:getKey(), onCheck = true})
job.yield()
end
-- Loop all objects
job.yield()
local objectHashes = {}
table.insert(objectLogs, {logLevel = "E", type = "spline", objectId = object:getID(), message = "This " .. object:getClassName() .. " has less than 2 nodes: " .. object:getID(), onCheck = true})
job.yield()
end
job.yield()
foundDuplicate = true
end
job.yield()
end
@/lua/ge/extensions/util/saveDynamicData.lua
-- Replace the vehicle
job.yield()
core_vehicles.replaceVehicle(vehName, {config = config})
job.yield()
job.sleep(3)
end
job.yield()
end