xXm0dzXx

Untitled

Jun 17th, 2012
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. --Dig Dug--
  2. local mined = {}
  3. local x,y = term.getSize()
  4. local round = 1
  5. local lives = 3
  6. local channel = "SinglePlayer"
  7. local Mult = false
  8. local Players = {}
  9. local noLagg = ""
  10. local PvP = {}
  11.  
  12. local currentX = x/2
  13. local currentY = 2
  14. local direction = ">"
  15.  
  16. for i = 1,x do
  17. noLagg = noLagg.. "X"
  18. end
  19.  
  20. local function cPrint(text)
  21. local x,y = term.getSize()
  22. x2,y2 = term.getCursorPos()
  23. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  24. write(text)
  25. end
  26.  
  27.  
  28. function drawCursor()
  29. term.clear() --Clears the screen
  30. if lives < 0 then
  31. term.setCursorPos(1,3)
  32. cPrint("GAME OVER")
  33. sleep(2)
  34. error()
  35. else
  36. for v = 2,y-2 do
  37. term.setCursorPos(1,v)
  38. write(noLagg)
  39. end
  40.  
  41. term.setCursorPos(4,2)
  42. write("Y")
  43.  
  44. for i = 1,lives do
  45. term.setCursorPos(i,y)
  46. write(">")
  47. end
  48.  
  49.  
  50. term.setCursorPos(x-string.len("RND: " ..round),y)
  51. write("RND: " ..round)
  52.  
  53. for i = 1,#mined do
  54. if mined[i] then
  55. mined[i] = tostring(mined[i])
  56. minedX, minedY = string.match(mined[i], "(%-?%d+)/(%-?%d+)")
  57. term.setCursorPos(tonumber(minedX),tonumber(minedY))
  58. write(" ")
  59. --if currentX == minedX and currentY == minedY-1 then
  60. -- currentY = minedY
  61. --end
  62. end
  63. end
  64. term.setCursorPos(x-1,1)
  65. write("@")
  66. if currentY == 1 then currentY = 2 end
  67. if currentX == x then
  68. currentX = x-1
  69. elseif currentX == 0 then
  70. currentX = 1
  71. end
  72.  
  73. if Mult then
  74.  
  75. for i,kik in pairs(Players) do
  76. v = tostring(kik)
  77. if v then
  78. minedX, minedY = string.match(v, "(%-?%d+)/(%-?%d+)")
  79. if tonumber(minedX) then
  80. term.setCursorPos(tonumber(minedX),tonumber(minedY))
  81. write("I")
  82. mined[#mined+1] = kik
  83. end
  84. end
  85. end
  86. end
  87.  
  88. if Mult then
  89. term.setCursorPos(4,2)
  90. write("Y")
  91. end
  92.  
  93. for i = 1,#PvP do
  94. if PvP[i] then
  95. PvP[i] = tostring(PvP[i])
  96. minedX, minedY = string.match(PvP[i], "(%-?%d+)/(%-?%d+)")
  97. term.setCursorPos(tonumber(minedX),tonumber(minedY))
  98. write("O")
  99. if tonumber(minedX) == currentX and tonumber(minedY) == currentY then
  100. term.setCursorPos(1,1)
  101. write("You just got blackhole'd!")
  102. sleep(1)
  103. local currentX = x/2
  104. local currentY = 2
  105. rednet.broadcast("[MM] ["..channel.."] " ..currentX.. "/" ..currentY)
  106. lives = lives-1
  107. end
  108. end
  109. end
  110.  
  111. term.setCursorPos(currentX, currentY)
  112. write(direction)
  113. end
  114. end
  115.  
  116. function begin()
  117. while true do
  118. drawCursor()
  119. local e,key,message = os.pullEvent()
  120. if e == "char" and key == "u" and Mult then
  121. STUPIDERROREMOVEVERAHOSRJHOSJRH = currentX+1
  122. PvP[#PvP+1] = STUPIDERROREMOVEVERAHOSRJHOSJRH.. "/" ..currentY
  123. rednet.broadcast("[MM] ["..channel.."] [Bomb] " ..STUPIDERROREMOVEVERAHOSRJHOSJRH.. "/" ..currentY)
  124. elseif e == "key" then
  125. if key == 17 or key == 200 then --up
  126. mined[#mined+1] = currentX.. "/" ..currentY
  127. currentY = currentY -1
  128. direction = "^"
  129. elseif key == 31 or key == 208 then --down
  130. if currentY < y-1 then
  131. mined[#mined+1] = currentX.. "/" ..currentY
  132. currentY = currentY +1
  133. end
  134. direction = "v"
  135. elseif key == 203 or key == 30 then --left
  136. mined[#mined+1] = currentX.. "/" ..currentY
  137. currentX = currentX -1
  138. direction = "<"
  139. elseif key == 205 or key == 32 then --right
  140. mined[#mined+1] = currentX.. "/" ..currentY
  141. currentX = currentX +1
  142. direction = ">"
  143. end
  144.  
  145. if Mult then
  146. rednet.broadcast("[MM] ["..channel.."] " ..currentX.. "/" ..currentY)
  147. end
  148.  
  149. if currentX == 4 and currentY == 2 then
  150. if Mult then
  151. term.setCursorPos(1,1)
  152. write("The flower ate you.")
  153. sleep(1)
  154. lives = lives-100000
  155. end
  156. end
  157. elseif Mult and e == "rednet_message" then
  158. if string.sub(message, 1, string.len("[MM] [" ..channel.."] [Bomb] ")) == "[MM] [" ..channel.."] [Bomb] " then
  159. PvP[#PvP+1] = string.sub(message, string.len("[MM] [" ..channel.."] [Bomb] *"), string.len(message))
  160. elseif string.sub(message, 1, string.len("[MM] [" ..channel.."] ")) == "[MM] [" ..channel.."] " then
  161. Players[key] = string.sub(message, string.len("[MM] [" ..channel.."] *"), string.len(message))
  162. end
  163. end
  164. end
  165. end
  166.  
  167. print("MineMined 1.6\n")
  168. print("1; Singleplayer")
  169. print("2; Multiplayer (BETA)\n")
  170. write("Selection: ")
  171. input = read()
  172. if input == "1" then
  173. begin()
  174. elseif input == "2" then
  175. write("\nChannel: ")
  176. channel = read()
  177. Mult = true
  178. rednet.open("top")
  179. begin()
  180. end
Advertisement
Add Comment
Please, Sign In to add comment