You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I expected 5 to be printed a second time here, rather than it becoming 0.
I can't explain the fact that a and #bare still the correct value after the yield, though.
PRINT: 1. #PathDump is:
PRINT: 5
PRINT: 2. #PathDump is:
PRINT: 0
PRINT: a is:
PRINT: 1
PRINT: #b is:
PRINT: 1
since I can't think of a normal way in Lua for coroutine.yield() to alter the local PathDump
-- no waypoint list, create one in several small steps to reduce laglocalPathDump= {}
ifOwner.MOMoveTargetandMovableMan:ValidMO(Owner.MOMoveTarget) thenOwner:DrawWaypoints(false)
-- copy the MovePath to a temporary table so we can yield safely while working on the pathforWptPosinOwner.MovePathdoprint("Inserting WptPos:")
print(WptPos)
table.insert(PathDump, WptPos)
end-- clear the path here so the graphical representation does not flicker on and off as muchOwner:ClearMovePath()
Owner:AddToMovePathEnd(Owner.MOMoveTarget.Pos)
elsecoroutine.yield() -- wait until next frame-- copy the MovePath to a temporary table so we can yield safely while working on the pathforWptPosinOwner.MovePathdotable.insert(PathDump, WptPos)
endendlocala=1localb= {"c"}
print("1. #PathDump is:")
print(#PathDump)
coroutine.yield() -- wait until next frameprint("2. #PathDump is:")
print(#PathDump)
print("a is:")
print(a)
print("#b is:")
print(#b)
I am 99% sure the mod didn't have this issue in pre5, as my mod updater script would've noticed this error in the log back then, caused by PathDump being empty:
BoS Initiate GoToWpt error:
Mods/bos.rte/Actors/Soldiers/MeleeHumanBehaviors.lua:1201: attempt to index field 'Pos' (a nil value)
MyNameIsTrez
changed the title
Yielding from a coroutine doesn't always seem to work as expected
Yielding from a coroutine seems to clear a local table
Feb 17, 2024
@Causeless I can confirm the issue didn't happen in Pre 5.0.
Here's benchmark.rte for pre5: Benchmark.rte.zip
And here's bos.rte for pre5. I commented out the printing of a and #b in this version: bos.rte.zip
I notice that in Pre 5.0, the LogConsole.txt starts off with non-zero values being printed every time:
PRINT: 1. #PathDump is:
PRINT: 4
PRINT: 1. #PathDump is:
PRINT: 7
PRINT: 1. #PathDump is:
PRINT: 5
PRINT: 1. #PathDump is:
PRINT: 5
PRINT: 1. #PathDump is:
PRINT: 8
whereas the Release 6.0 mod start off with zeros being printed every time:
PRINT: 1. #PathDump is:
PRINT: 0
PRINT: 1. #PathDump is:
PRINT: 0
PRINT: 1. #PathDump is:
PRINT: 0
PRINT: 1. #PathDump is:
PRINT: 0
PRINT: 1. #PathDump is:
PRINT: 5
I don't know whether this is unexpected though, since it might just be because the game is now more multithreaded.
Well, in pre5 the pathrequests would complete immediately in a blocking manner whereas in pre6 they are non-blocking and async. So starting with zeros is expected, it's just the game goes onto the next frame immediately instead of blocking and framespiking as it waits for the results. Though it is unexpected in this case that it's go from a positive value back to zero, unless the coroutine is restarting altogether.
Describe the bug
I expected 5 to be printed a second time here, rather than it becoming 0.
I can't explain the fact that
a
and#b
are still the correct value after the yield, though.since I can't think of a normal way in Lua for
coroutine.yield()
to alter thelocal PathDump
I am 99% sure the mod didn't have this issue in pre5, as my mod updater script would've noticed this error in the log back then, caused by
PathDump
being empty:To Reproduce
The text was updated successfully, but these errors were encountered: