Let’s say I got this setup:
main.collection
|potato.go
||potato.script
|hungry.go
||hungry.script
Now, in update in hungry.script
I need to run a function in potato.script
and then use its return value in hungry.script
.
The ideas I have so far are:
Sending a callback in the message to potato.script
. This will quickly end me up in callback hell though and I would prefer not using it, and it also makes things really weird because the callback would be run with the environment (hope that’s the proper term) for potato.script
when the code actually is in hungry.script
Putting the function I want to run in hungry.script
within a coroutine, sending the message to potato.script
and putting the coroutine in the message and then yielding. Then when potato.script
has called its function it would resume the coroutine and somehow shove the values back into it. Not sure this would work either.
What is the best way to do this?