fsm.lua 620 B

12345678910111213141516171819202122232425262728293031
  1. -- title: fsm
  2. -- author: pixelbath
  3. -- desc: test implementation of the barest-bones finite state machine
  4. local t = 0
  5. local state_update = nil
  6. function state1_update()
  7. print("state1_update()", 0, 16)
  8. if btnp(4) then
  9. state_update = state2_update
  10. end
  11. end
  12. function state2_update()
  13. print("state2_update()", 0, 16)
  14. if btnp(4) then
  15. state_update = state1_update
  16. end
  17. end
  18. state_update = state1_update
  19. function TIC()
  20. cls(0)
  21. state_update()
  22. end
  23. -- <PALETTE>
  24. -- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
  25. -- </PALETTE>