states_01.gm 351 B

12345678910111213141516171819202122232425
  1. global awake = function()
  2. {
  3. print("I'm awake!");
  4. };
  5. global resting = function()
  6. {
  7. print("I am resting");
  8. sig = block("wakeup");
  9. if (sig == "wakeup")
  10. {
  11. stateSet( awake );
  12. }
  13. };
  14. global init_state = function()
  15. {
  16. // Set a state on the thread
  17. // we're now using states
  18. stateSet( resting );
  19. };
  20. thread( init_state );
  21. sleep(1);
  22. signal("wakeup");