Legebatterie

Apps--masterMind

Jan 19th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. cheatID=666
  2.  
  3. term.setBackgroundColor(colors.white)
  4. term.clear()
  5.  
  6. paintutils.drawFilledBox(3,3,35,17,colors.lightGray)
  7.  
  8.  
  9. for i=1,12 do
  10. paintutils.drawBox(i*3,3,i*3,18,colors.black)
  11. end
  12.  
  13. for i=1,6 do
  14. paintutils.drawBox(3,i*3,36,i*3,colors.black)
  15. end
  16.  
  17. paintutils.drawFilledBox(40,1,51,19,colors.black)
  18.  
  19.  
  20. paintutils.drawBox(45,3,48,4,colors.red)
  21. paintutils.drawBox(45,5,48,6,colors.blue)
  22. paintutils.drawBox(45,7,48,8,colors.yellow)
  23. paintutils.drawBox(45,9,48,10,colors.purple)
  24. paintutils.drawBox(45,11,48,12,colors.green)
  25. paintutils.drawBox(45,13,48,14,colors.orange)
  26. paintutils.drawBox(45,15,48,16,colors.brown)
  27. paintutils.drawBox(45,17,48,18,colors.white)
  28.  
  29. term.setTextColor(colors.white)
  30. term.setBackgroundColor(colors.black)
  31. term.setCursorPos(43,1)
  32. write("confirm")
  33.  
  34.  
  35. term.setTextColor(colors.black)
  36. term.setBackgroundColor(colors.white)
  37. term.setCursorPos(1,1)
  38. write("hint")
  39.  
  40.  
  41.  
  42.  
  43. nTOc={"red","blue","yellow","purple","green","orange","brown","white"}
  44. sol={}
  45.  
  46. sol[1]=nTOc[math.random(1,8)]
  47.  
  48. sol[2]=nTOc[math.random(1,8)]
  49. while sol[1]==sol[2] do
  50. sol[2]=nTOc[math.random(1,8)]
  51. end
  52.  
  53. sol[3]=nTOc[math.random(1,8)]
  54. while sol[1]==sol[3] or sol[2]==sol[3] do
  55. sol[3]=nTOc[math.random(1,8)]
  56. end
  57.  
  58. sol[4]=nTOc[math.random(1,8)]
  59. while sol[1]==sol[4] or sol[2]==sol[4] or sol[3]==sol[4] do
  60. sol[4]=nTOc[math.random(1,8)]
  61. end
  62.  
  63. sol[5]=nTOc[math.random(1,8)]
  64. while sol[1]==sol[5] or sol[2]==sol[5] or sol[3]==sol[5] or sol[4]==sol[5] do
  65. sol[5]=nTOc[math.random(1,8)]
  66. end
  67.  
  68. rednet.open("top")
  69. rednet.send(cheatID,sol)
  70. rednet.close("top")
  71.  
  72. guessedFieldX=1
  73. currentColor="red"
  74. Field={}
  75. victory=false
  76. confirmed=false
  77. round=0
  78.  
  79. while victory==false do
  80. round=round+1
  81. confirmed=false
  82. guessedFieldX=guessedFieldX+3
  83.  
  84. while confirmed==false do
  85. event,n,x,y=os.pullEvent("mouse_click")
  86.  
  87. if x>44 and x<49 then
  88. if y>=3 and y<=4 then
  89. currentColor="red"
  90. elseif y>=5 and y<=6 then
  91. currentColor="blue"
  92. elseif y>=7 and y<=8 then
  93. currentColor="yellow"
  94. elseif y>=9 and y<=10 then
  95. currentColor="purple"
  96. elseif y>=11 and y<=12 then
  97. currentColor="green"
  98. elseif y>=13 and y<=14 then
  99. currentColor="orange"
  100. elseif y>=15 and y<=16 then
  101. currentColor="brown"
  102. elseif y>=17 and y<=18 then
  103. currentColor="white"
  104. end
  105.  
  106. term.setTextColor(colors[currentColor])
  107. term.setBackgroundColor(colors.black)
  108. term.setCursorPos(43,1)
  109. write("confirm")
  110.  
  111. end
  112.  
  113. if y>=4 and y<=5 and x<=33 then
  114. guessedFieldY=4
  115. paintutils.drawBox(guessedFieldX,guessedFieldY,guessedFieldX+1,guessedFieldY+1,colors[currentColor])
  116. Field[(guessedFieldY-1)/3]=currentColor
  117.  
  118. elseif y>=7 and y<=8 and x<=33 then
  119. guessedFieldY=7
  120. paintutils.drawBox(guessedFieldX,guessedFieldY,guessedFieldX+1,guessedFieldY+1,colors[currentColor])
  121. Field[(guessedFieldY-1)/3]=currentColor
  122.  
  123. elseif y>=10 and y<=11 and x<=33 then
  124. guessedFieldY=10
  125. paintutils.drawBox(guessedFieldX,guessedFieldY,guessedFieldX+1,guessedFieldY+1,colors[currentColor])
  126. Field[(guessedFieldY-1)/3]=currentColor
  127.  
  128. elseif y>=13 and y<=14 and x<=33 then
  129. guessedFieldY=13
  130. paintutils.drawBox(guessedFieldX,guessedFieldY,guessedFieldX+1,guessedFieldY+1,colors[currentColor])
  131. Field[(guessedFieldY-1)/3]=currentColor
  132.  
  133. elseif y>=16 and y<=17 and x<=33 then
  134. guessedFieldY=16
  135. paintutils.drawBox(guessedFieldX,guessedFieldY,guessedFieldX+1,guessedFieldY+1,colors[currentColor])
  136. Field[(guessedFieldY-1)/3]=currentColor
  137. end
  138.  
  139. if y==1 and x>42 and x<49 then
  140. confirmed=true
  141. end
  142.  
  143. if y==1 and x<8 then
  144. hintY=math.random(1,5)*3+1
  145. paintutils.drawBox(guessedFieldX,hintY,guessedFieldX+1,hintY+1,colors[sol[(hintY-1)/3]])
  146. Field[(hintY-1)/3]=sol[(hintY-1)/3]
  147. end
  148. end
  149.  
  150. if confirmed then
  151. gray=0
  152. lightGray=0
  153.  
  154. --GRAY
  155. for i=1,5 do
  156. if sol[i]==Field[i] then
  157. gray=gray+1
  158. end
  159. end
  160.  
  161. --lightGray
  162. for i=1,5 do
  163. for j=1,5 do
  164. if Field[j]==sol[i] then
  165. lightGray=lightGray+1
  166. end
  167. end
  168. end
  169.  
  170. lightGray=lightGray-gray
  171. if lightGray<0 then lightGray=0 end
  172.  
  173. term.setBackgroundColor(colors.gray)
  174. term.setTextColor(colors.blue)
  175. term.setCursorPos(guessedFieldX,2)
  176. write(gray)
  177.  
  178.  
  179. term.setBackgroundColor(colors.lightGray)
  180. term.setTextColor(colors.blue)
  181. term.setCursorPos(guessedFieldX+1,2)
  182. write(lightGray)
  183.  
  184. if gray==5 then victory=true
  185. end
  186.  
  187. end
  188. end
  189.  
  190. sleep(2)
  191. term.setBackgroundColor(colors.green)
  192. term.clear()
  193. term.setTextColor(colors.black)
  194. term.setCursorPos(16,8)
  195. print("Victory in ",round," turnes")
  196. sleep(4)
Add Comment
Please, Sign In to add comment