xXm0dzXx

Untitled

Apr 22nd, 2012
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local scroll = 0;
  2. local jump = 0;
  3. local char = ">";
  4. local coins = 0;
  5. local x,y = term.getSize()
  6. local level = 1;
  7. local portalBlue = false
  8.  
  9. local portalBlueX = 0
  10. local portalBlueY = 0
  11.  
  12. local portalRed = false
  13.  
  14. local portalRedX = 0
  15. local portalRedY = 0
  16.  
  17. function newPortal(type)
  18. if type == 1 then
  19. term.setCursorPos(portalRedX - scroll, portalRedY + jump)
  20. else
  21. term.setCursorPos(portalBlueX - scroll, portalBlueY + jump)
  22. end
  23.  
  24. if type == 1 and portalRed == true then
  25. if portalRedX - scroll ~= x-1 then
  26. if(portalRedX - scroll == x/2 and portalRedY + jump == y-10)then
  27. if portalBlue == true then scroll = (portalBlueX)end
  28. else
  29. write("O")
  30. end
  31. end
  32. elseif type == 2 and portalBlue == true then
  33. if portalBlueX - scroll ~= x-1 then
  34. if(portalBlueX - scroll == x/2 and portalBlueY + jump == y-10)then
  35. if portalRed == true then scroll = (portalRedX)end
  36. else
  37. write("0")
  38. end
  39. end
  40. end
  41. end
  42.  
  43. function floor(param1)
  44. for i=1,x-1 do
  45. term.setCursorPos(i, y-9 + jump)
  46. write(param1)
  47. end
  48. end
  49.  
  50. function newTeleporter(posX, posY, levelid, title)
  51. term.setCursorPos(posX - scroll, posY + jump)
  52. if posX - scroll ~= x-1 then --
  53. if(posX - scroll == x/2 and posY + jump == y-10)then
  54. level = levelid
  55. else
  56. write(title)
  57. end
  58. end
  59. end
  60.  
  61. function world()
  62. if(level == 1)then
  63. floor("A")
  64.  
  65. newTeleporter(x/2-3, y-10, 999, "X")
  66. elseif(level == 999)then
  67. floor("O")
  68. end
  69. end
  70.  
  71. function redraw()
  72. term.clear()
  73. term.setCursorPos(1,1)
  74. write("Coins: " ..coins.. " World: 0-" ..level.. " X: " ..scroll)
  75. newPortal(1)
  76. newPortal(2)
  77. term.setCursorPos(x/2, y-10)
  78. write(char)
  79.  
  80. world()
  81. end
  82.  
  83. while true do
  84. redraw()
  85. local event, a, b = os.pullEvent();
  86. if(event == "char" and a == "a")then
  87. scroll = scroll-1
  88. char = "<"
  89. elseif(event == "char" and a == "d")then
  90. scroll = scroll+1
  91. char = ">"
  92. elseif(event == "key" and a == 57)then
  93. jump = 1
  94. for i=1,4 do
  95. sleep(0.1)
  96. jump = i
  97. redraw()
  98. end
  99. for i=1,4 do
  100. sleep(0.1)
  101. jump = jump-i
  102. redraw()
  103. end
  104. jump = 0
  105. elseif(event == "char" and a == "o")then
  106. portalRed = true
  107. if char == ">" then
  108. portalRedX = x/2 + scroll +1
  109. portalRedY = y-10
  110. else
  111. portalRedX = x/2 + scroll -1
  112. portalRedY = y-10
  113. end
  114. elseif(event == "char" and a == "0")then
  115. portalBlue = true
  116. if char == ">" then
  117. portalBlueX = x/2 + scroll +1
  118. portalBlueY = y-10
  119. else
  120. portalBlueX = x/2 + scroll -1
  121. portalBlueY = y-10
  122. end
  123. elseif(event == "char" and a == "r")then
  124. portalBlue = false
  125. portalBlueX = 0
  126. portalBlueY = 0
  127. portalRed = false
  128. portalRedX = 0
  129. portalRedY = 0
  130. end
  131. end
Advertisement
Add Comment
Please, Sign In to add comment