Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | None | 0 0
  1. -- Scriptnaam: Optellen_H6.lua
  2. -- Auteur: Mark Broeren
  3. -- Datum: 07-02-2011
  4.  
  5. intX = 0
  6. intY = 0
  7. operator = "+"
  8.  
  9. function doEvent()
  10.     if Keys.newPress.A then
  11.     switchOperator(operator)
  12.         intX = intX+1
  13.     elseif Keys.newPress.B then
  14.         intX = intX-1
  15.     elseif Keys.newPress.X then
  16.         intY = intY+1
  17.     elseif Keys.newPress.Y then
  18.         intY = intY-1
  19.     elseif Keys.newPress.L then
  20.         switchOperator(operator)
  21.     elseif Keys.newPress.R then
  22.         switchOperator(operator)
  23.     end
  24. end
  25.  
  26. function switchOperator(currentOperator)
  27.     if currentOperator == "+" then
  28.         operator = "-"
  29.     elseif currentOperator == "-" then
  30.         operator = "*"
  31.     elseif currentOperator == "*" then
  32.         operator = "/"
  33.     end
  34. end
  35.    
  36.    
  37.  
  38. function berekenSom(parX, parY)
  39.     intAntwoord = parX + parY
  40.     return intAntwoord
  41. end
  42.  
  43. function drawScreen()
  44. startDrawing()
  45.     screen.print(SCREEN_UP,0,0,"Press START to stop")
  46.     screen.print(SCREEN_UP,0,10,"Press A, B, X, Y and see what happens")
  47.     screen.print(SCREEN_DOWN,10,100,"x: "..intX)
  48.     screen.print(SCREEN_DOWN,10,110,"y: "..intY)
  49.     screen.print(SCREEN_DOWN,10,120,"Operator: "..operator)
  50.     screen.print(SCREEN_DOWN,10,130,"Het antwoord van je optelling is: "..berekenSom(intX,intY))
  51. stopDrawing()
  52. end
  53.  
  54. while not Keys.newPress.Start do
  55.     Controls.read()
  56.     doEvent()
  57.     drawScreen()
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement