mousep.lua 924 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. -- title: simple mousep behavior
  2. -- author: pixelbath
  3. -- desc: shows how to register a single click
  4. -- script: lua
  5. -- input: mouse
  6. pt = 0
  7. function TIC()
  8. cls()
  9. --get mouse info
  10. x, y, p = mouse()
  11. --if pressed
  12. if p and pt == 0 then
  13. pt = 10
  14. end
  15. --draw stuff
  16. line(x, 0, x, 136, 8)
  17. line(0, y, 240, y, 8)
  18. if pt > 0 then
  19. print('pew!', x, y+pt-12, 12, 1, 1, 1)
  20. pt=pt-1
  21. end
  22. --show coordinates
  23. c = string.format('(%03i,%03i)', x, y)
  24. print(c, 2, 2, 15, 1, 1, 1)
  25. end
  26. -- <WAVES>
  27. -- 000:00000000ffffffff00000000ffffffff
  28. -- 001:0123456789abcdeffedcba9876543210
  29. -- 002:0123456789abcdef0123456789abcdef
  30. -- </WAVES>
  31. -- <SFX>
  32. -- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000
  33. -- </SFX>
  34. -- <PALETTE>
  35. -- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
  36. -- </PALETTE>