Advertisement
Nike622000

Untitled

Mar 8th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.06 KB | None | 0 0
  1. shell.run("config")
  2.  
  3. Menu = {}
  4. Menu[1] = {3,17,3,5,colors.gray,colors.blue,"Spiel Hosten",false}
  5. Menu[2] = {3,17,3,5,colors.gray,colors.blue,"Beitreten" ,false}
  6. Menu[3] = {3,17,3,5,colors.gray,colors.blue,"Menu" ,false}
  7.  
  8. local xMax,yMax = term.getSize()
  9.  
  10. Pos = 1
  11.  
  12. function Background(xP1,xP2,yP1,yP2,col)
  13. term.setBackgroundColor(col)
  14. for xPos = xP1,xP2 do
  15. for yPos = yP1,yP2 do
  16. term.setCursorPos(xPos,yPos)
  17. term.write(" ")
  18. end
  19. end
  20. end
  21.  
  22. function BackgroundWater(xP1,xP2,yP1,yP2)
  23. t = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
  24. i = 1
  25. for yPos = yP1,yP2 do
  26. term.setBackgroundColor(colors.gray)
  27. if i < 10 then
  28. term.setCursorPos(2,yPos)
  29. else
  30. term.setCursorPos(1,yPos)
  31. end
  32. term.write(i)
  33. i = i+1
  34. end
  35. i = 1
  36. for xPos = xP1,xP2 do
  37. term.setBackgroundColor(colors.gray)
  38. term.setCursorPos(xPos,1)
  39. term.write(t[i])
  40. i = i+1
  41. for yPos = yP1,yP2 do
  42. g = math.random(1,5)
  43. if g == 1 then
  44. col = colors.lightBlue
  45. else
  46. col = colors.blue
  47. end
  48. term.setBackgroundColor(col)
  49. term.setCursorPos(xPos,yPos)
  50. term.write(" ")
  51. end
  52. end
  53. end
  54.  
  55. Schiffe = {}
  56. Schiffe[1] = {7,"Flugzeugtraeger" ,false,false}
  57. Schiffe[2] = {5,"Panzerschiff" ,false,false}
  58. Schiffe[3] = {5,"Panzerschiff" ,false,false}
  59. Schiffe[4] = {3,"Zerstoerer" ,false,false}
  60. Schiffe[5] = {2,"Aufklaerungsboot",false,false}
  61.  
  62. while true do
  63.  
  64. for x = 1,#Schiffe do
  65. Schiffe[x][3] = false
  66. end
  67. Schiffe[Pos][3] = true
  68.  
  69. Background(1,xMax,1,yMax,colors.gray)
  70. BackgroundWater(3,xMax-23,2,yMax-1)
  71. Background(xMax-20,xMax-1,2,yMax-1,colors.lightGray)
  72. b = 0
  73. for a = 1,#Schiffe do
  74. if Schiffe[a][4] then
  75. term.setBackgroundColor(colors.red)
  76. for i = 0,Schiffe[a][1]-1 do
  77. if Schiffe[a][7] == "h" then
  78. term.setCursorPos(Schiffe[a][5]+i,Schiffe[a][6])
  79. term.write(" ")
  80. elseif Schiffe[a][7] == "v" then
  81. term.setCursorPos(Schiffe[a][5],Schiffe[a][6]+i)
  82. term.write(" ")
  83. end
  84. end
  85. end
  86. end
  87. for a = 1,#Schiffe do
  88. term.setBackgroundColor(colors.lightGray)
  89. term.setCursorPos(xMax-19,3+b)
  90. term.write(Schiffe[a][2])
  91. term.setCursorPos(xMax-19,4+b)
  92. if Schiffe[a][3] then
  93. term.setBackgroundColor(colors.blue)
  94. elseif Schiffe[a][3] == false then
  95. term.setBackgroundColor(colors.red)
  96. end
  97. if Schiffe[a][4] then
  98. term.setBackgroundColor(colors.lime)
  99. end
  100. if Schiffe[a][4] and Schiffe[a][3] then
  101. term.setBackgroundColor(colors.yellow)
  102. end
  103. for i = 1,Schiffe[a][1] do
  104. term.write(" ")
  105. end
  106. b = b+3
  107. end
  108.  
  109.  
  110. event,key = os.pullEvent("key")
  111. for b = 1,#Key do
  112. if Key[b][2] ~= nil then
  113. if key == Key[b][2] or key == Key[b][3] then
  114. if Key[b][1] == "UP" then
  115. Pos = Pos-1
  116. elseif Key[b][1] == "DOWN" then
  117. Pos = Pos+1
  118. elseif Key[b][1] == "SPACE" then
  119. g = 0
  120. for a = 1,#Schiffe do
  121. if Schiffe[a][4] then
  122. g = g + 1
  123. end
  124. end
  125. if g == #Schiffe then
  126. while true do
  127. Background(1,xMax,1,yMax,colors.gray)
  128. rednet.open(RedSide)
  129. Background(2,xMax-1,2,yMax-1)
  130. term.setTextColor(colors.white)
  131. for i = 1,#Menu do
  132. if Menu[i][8] then
  133. term.setBackgroundColor(Menu[i][6])
  134. else
  135. term.setBackgroundColor(Menu[i][5])
  136. end
  137. end
  138. for xPos = Menu[i][1],Menu[i][2] do
  139. for yPos = Menu[i][3],Menu[i][4] do
  140. term.setCursorPos(xPos,yPos)
  141. term.write(" ")
  142. end
  143. end
  144. term.setCursorPos(1+Menu[i][1]+((Menu[i][2]-Menu[i][1])/2)-#Menu[i][8]/2,Menu[i][3]+((Menu[i][4]-Menu[i][3])/2))
  145. term.write(Menu[i][8])
  146. end
  147. event,k = os.pullEvent("key")
  148. for l = 1,#Key do
  149. if Key[b][2] ~= nil then
  150. if k == Key[b][2] or Key[b][3] then
  151. if Key[b][1] == "UP" then
  152. P = P - 1
  153. elseif Key[b][1] == "DOWN" then
  154. P = P + 1
  155. elseif Key[b][1] == "BACK" then
  156. os.reboot()
  157. elseif Key[b][1] == "CONFIRM" then
  158.  
  159. end
  160. end
  161. end
  162. end
  163. end
  164. elseif Key[b][1] == "CONFIRM" then
  165. xP = 3
  166. yP = 2
  167. L = Schiffe[Pos][1]
  168. A = "h"
  169. br = false
  170. while true do
  171. xMi = 3
  172. yMi = 2
  173.  
  174. if A == "h" then
  175. xMa = xMax-22-L
  176. yMa = yMax-1
  177. else
  178. xMa = xMax-23
  179. yMa = yMax-L
  180. end
  181. if xP > xMa then
  182. xP = xMa
  183. elseif xP < xMi then
  184. xP = xMi
  185. end
  186. if yP > yMa then
  187. yP = yMa
  188. elseif yP < yMi then
  189. yP = yMi
  190. end
  191. term.setBackgroundColor(colors.red)
  192. for i = 0,L-1 do
  193. if A == "h" then
  194. term.setCursorPos(xP+i,yP)
  195. term.write(" ")
  196. elseif A == "v" then
  197. term.setCursorPos(xP,yP+i)
  198. term.write(" ")
  199. end
  200. end
  201. for a = 1,#Schiffe do
  202. if Schiffe[a][4] then
  203. term.setBackgroundColor(colors.gray)
  204. for i = 0,Schiffe[a][1]-1 do
  205. if Schiffe[a][7] == "h" then
  206. term.setCursorPos(Schiffe[a][5]+i,Schiffe[a][6])
  207. term.write(" ")
  208. elseif Schiffe[a][7] == "v" then
  209. term.setCursorPos(Schiffe[a][5],Schiffe[a][6]+i)
  210. term.write(" ")
  211. end
  212. end
  213. end
  214. end
  215.  
  216. event,key = os.pullEvent("key")
  217. for b = 1,#Key do
  218. if Key[b][2] ~= nil then
  219. if key == Key[b][2] or key == Key[b][3] then
  220. if Key[b][1] == "UP" then
  221. yP = yP-1
  222. elseif Key[b][1] == "DOWN" then
  223. yP = yP+1
  224. elseif Key[b][1] == "LEFT" then
  225. xP = xP-1
  226. elseif Key[b][1] == "RIGHT" then
  227. xP = xP+1
  228. elseif Key[b][1] == "BACK" then
  229. br = true
  230. elseif Key[b][1] == "CONFIRM" then
  231. Schiffe[Pos][4] = true
  232. br = true
  233. Schiffe[Pos][5] = xP
  234. Schiffe[Pos][6] = yP
  235. Schiffe[Pos][7] = A
  236. elseif Key[b][1] == "Q" then
  237. if A == "h" then
  238. A = "v"
  239. else
  240. A = "h"
  241. end
  242. end
  243. end
  244. end
  245. end
  246. BackgroundWater(3,xMax-23,2,yMax-1)
  247. if br then
  248. break
  249. end
  250. end
  251. --Schiffe[Pos][4] = true
  252. end
  253. end
  254. end
  255. end
  256. if Pos > #Schiffe then
  257. Pos = 1
  258. elseif Pos < 1 then
  259. Pos = #Schiffe
  260. end
  261. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement