I'm trying to work out the difference between PassageReady and PassageDone in SugarCube. Is there any difference other than PassageDone happening marginally later than PassageReady?
In my story I use PassageDone for some things but wondering if PassageReady would be better. I use it to activate background image changes I want to happen 100ms after a passage is ready to be displayed, so it starts with a <<timedcontinue 100ms>> then the code. I find this makes it smoother than just plugging everything into the individual passages, and the browser seems more comfortable with the enforced order. It likes to work out what it's displaying in the passages before it implements my image display code.
Probably due to the timedcontinue there wouldn't be any practical difference, but just wondering how each work. I use PassageDone because I want the browser "done" with its passage display tasks before it starts looking at my other code.
Comments
I'm so glad you asked this out in public.
I know you could have asked TME (or even GreyElf) directly since this seems like such a high-level question.
I can think of maybe 7 people on this site who could answer it, while most of us don't even know what it is.
However, since you put it here, now I think I want to start coding it your way where before
it had never even occurred to me.
Thank you.
<<set $variable to 1>> in PassageReady and it would affect what's in the passage, whereas you'd put <<if $variable is 1>> in PassageDone and it would go off variables set in the passage?
I'm struggling to think of why you'd want to use PassageReady like that, but then it didn't occur to me to use PassageDone until not long ago, either.
The exact differences are outlined in the Passage Names section of the Special Names docs. To reiterate:
The PassageReady/PassageDone special passages and the Task objects (prehistory, predisplay, prerender, postrender, and postdisplay) are similar in that they both allow you to do dynamic things around the display of a passage (by navigation, the <<display>> macro does not trigger any of these).
The order of execution for passage display (again, via navigation) looks like this:
I'll stick with PassageDone to keep my code in the proper order.
And indeed, after cleaning up my code so that the browser only has to process what's absolutely necessary on passage transitions, I don't need it anymore. PassageDone in itself provides the necessary ordering.