Kind of lost with "spawn"


Hi, I’m lost and not sure what does “spawn” does, here:

pet.on(“spawn”, Spawn) #where Spawn is a function

What “spawn” between “” does?


It is the event that triggers the function.



What does the event spawn means? When in appears?


it just tells the pet : “sparky, when you spawn, do this function”, so “spawn” is the event, and Spawn is the name of the function, which you can change, but you can’t change the event, or it will give you an error


“spawn” is the trigger for the function Spawn that is defined somewhere else.

“spawn” is an event, just like “collide”.