Time for action – Do we really need to give labels to everything?
One label is special and indicates where state code should start executing; this one is called Begin
. Let's take a look at a few things we can do with state code, labels, and latent functions.
At the bottom of our
Seeking
state, underneath all of the functions, but before the closing}
symbol, let's write the following code:Begin: `log("Man I'm tired, I'm going to sleep."); Sleep(3.0); `log("French toast please!"); SomeOtherLabel: `log("You ever have a deja vu Joel?"); Sleep(3.0); GoTo('SomeOtherLabel');
When state code starts, it starts at the Begin
label. First we log something, then we use a latent function called Sleep
. Usually when code is running, it will prevent any other code from running until it's finished. This doesn't apply to latent functions, which won't stop other code from running while it's waiting on whatever function it's performing to finish.
After it's done sleeping, we log something else, then...