I do have a scripted item i do remove immediately when the script starts to run. I have introduced a guard to ensure the item is evaluated only once. But even after 200 Frames sometimes the item gets still processed. Here a snippet of my script with debugging statements:
int inProgress
int hasBeenRemoved
int tokenCount
int frameCount
Begin GameMode
if (inProgress == 0)
set inProgress to 1
; some code goes here
set hasBeenRemoved to 1
set container to getContainer
container.removeItem MyToken 1
return
endif
set frameCount to frameCount + 1
if (frameCount >= 200)
set container to getContainer
set tokenCount to container.getItemCount MyToken
showMessage DebugMessage tokenCount hasBeenRemoved
container.removeItem MyToken tokenCount
endif
EndWhat I observe is that sometimes (half the times probably) the second if - endif block gets executed. As far as I do understand the Engine did ran the script 200 times. The message i show always has
tokenCount == 1
and
hasBeenRemoved == 1
That means the item was already removed, but the Engine still runs the item script. So my expectation was a synchronous garbage collection of item but derived from my observations i guess the item get asynchronous garbage collected, someone in the future. Who knows for sure what the reason for this behavior is?
Thanks a lot in advance, Harmlezz