Files
UnrealLuaDemo/Script/lua/Tests/UnLuaExamples/Ex07_CallLatentFunction.lua
T

38 lines
1.1 KiB
Lua

local Ex07_CallLatentFunction = UnLua.Class()
function Ex07_CallLatentFunction.ReceiveBeginPlay(self)
self.Overridden.ReceiveBeginPlay(self)
self.steps = {}
self.completed = false
local co = coroutine.create(function(actor)
actor:RunSequence()
end)
local ok, err = coroutine.resume(co, self)
if not ok then
UnLua.LogError(
"Ex07 coroutine failed:",
tostring(err)
)
end
end
function Ex07_CallLatentFunction.RunSequence(self)
self.steps[#self.steps + 1] = "Step1:Start"
UE.UKismetSystemLibrary.Delay(self, 0.5)
if not UE.UKismetSystemLibrary.IsValid(self) then
return
end
self.steps[#self.steps + 1] = "Step2:After0.5s"
UE.UKismetSystemLibrary.Delay(self, 1)
if not UE.UKismetSystemLibrary.IsValid(self) then
return
end
self.steps[#self.steps + 1] = "Step3:Done"
self.completed = true
end
function Ex07_CallLatentFunction.GetSteps(self)
return self.steps
end
function Ex07_CallLatentFunction.IsCompleted(self)
return self.completed
end
return Ex07_CallLatentFunction