Advertisement
Jeyjey0

ComputerCraft CookieClicker with auto saves

Sep 1st, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.60 KB | None | 0 0
  1. function datenersteller()
  2. local cookie = 0
  3. local filePath = "save"
  4. local fileHandle = fs.open (filePath, 'w')
  5. fileHandle.write (textutils.serialize (cookie))
  6. fileHandle.close()
  7. local autocooker = 0
  8. local filePath = "auto"
  9. local fileHandle = fs.open (filePath, 'w')
  10. fileHandle.write (textutils.serialize (autocooker))
  11. fileHandle.close()
  12. local stop2 = 0
  13. local filePath = "stop"
  14. local fileHandle = fs.open (filePath, 'w')
  15. fileHandle.write (textutils.serialize (stop2))
  16. fileHandle.close()
  17. local price = 30
  18. local filePath = "preis"
  19. local fileHandle = fs.open (filePath, 'w')
  20. fileHandle.write (textutils.serialize (price))
  21. fileHandle.close()
  22. shell.run()
  23.  
  24. end
  25. if not fs.exists("stop") then
  26. datenersteller()
  27. end
  28. if not fs.exists("save") then
  29. datenersteller()
  30. end
  31. if not fs.exists("auto") then
  32. datenersteller()
  33. end
  34. term.clear()
  35. local stop2 = 0
  36. local filePath = "stop"
  37. local fileHandle = fs.open (filePath, 'w')
  38. fileHandle.write (textutils.serialize (stop2))
  39. fileHandle.close()
  40. term.setCursorPos(1, 1)
  41. print("Restart or Confirm pls click on one: ")
  42. print("RESTART")
  43. term.setCursorPos(1, 4)
  44. print("Confirm")
  45. local event2, button, x, y = os.pullEvent("mouse_click")
  46. if event2 == "mouse_click" and x >= 1 and x <= 8 and y >= 2 and y <= 2 then
  47. shell.run("delete save")
  48. shell.run("delete auto")
  49. shell.run("delete preis")
  50. if not fs.exists("stop") then
  51. datenersteller()
  52. end
  53. if not fs.exists("save") then
  54. datenersteller()
  55. end
  56. if not fs.exists("auto") then
  57. datenersteller()
  58. end
  59. term.clear()
  60. term.setCursorPos(1, 1)
  61. local cookie = 0
  62. local filePath = "save"
  63. local fileHandle = fs.open (filePath, 'r')
  64. cookie = textutils.unserialize (fileHandle.readAll())
  65. print("Cookies: ",cookie)
  66. fileHandle.close()
  67. term.setCursorPos(1, 2)
  68. local autocooker = 0
  69. local filePath = "auto"
  70. local fileHandle = fs.open (filePath, 'r')
  71. autocooker = textutils.unserialize (fileHandle.readAll())
  72. fileHandle.close()
  73.  
  74. print("AutoCookies pro Sec: ",autocooker)
  75. term.setCursorPos(25, 9)
  76. print("O")
  77. term.setCursorPos(51, 1)
  78. print("X")
  79. term.setCursorPos(2, 3)
  80. local price = 0
  81. local filePath = "preis"
  82. local fileHandle = fs.open (filePath, 'r')
  83. price = textutils.unserialize (fileHandle.readAll())
  84. fileHandle.close()
  85. print("AutoClicker","[",price,"]")
  86. local function click()
  87. while true do
  88. local event, button, x, y = os.pullEvent("mouse_click")
  89. if event == "mouse_click" and x >= 25 and x <= 25 and y >= 9 and y <= 9 then
  90. local filePath = "save"
  91. local fileHandle = fs.open (filePath, 'r')
  92. cookie = textutils.unserialize (fileHandle.readAll())
  93. fileHandle.close()
  94. cookie = cookie + 1
  95. local filePath = "save"
  96. local fileHandle = fs.open (filePath, 'w')
  97. fileHandle.write (textutils.serialize (cookie))
  98. fileHandle.close()
  99. local autocooker = nil
  100. local filePath = "auto"
  101. local fileHandle = fs.open (filePath, 'r')
  102. autocooker = textutils.unserialize (fileHandle.readAll())
  103. fileHandle.close()
  104. term.clear()
  105. term.setCursorPos(1,1)
  106. print("Cookies: ",cookie)
  107. term.setCursorPos(1, 2)
  108. print("AutoCookies pro Sec: ",autocooker)
  109. term.setCursorPos(25, 9)
  110. print("O")
  111. term.setCursorPos(51, 1)
  112. print("X")
  113. term.setCursorPos(2, 3)
  114. local price = 0
  115. local filePath = "preis"
  116. local fileHandle = fs.open (filePath, 'r')
  117. price = textutils.unserialize (fileHandle.readAll())
  118. fileHandle.close()
  119. print("AutoClicker","[",price,"]")
  120. elseif event == "mouse_click" and x >= 51 and x <= 51 and y >= 1 and y <= 1 then
  121. term.clear()
  122. local stop2 = 1
  123. local filePath = "stop"
  124. local fileHandle = fs.open (filePath, 'w')
  125. fileHandle.write (textutils.serialize (stop2))
  126. fileHandle.close()
  127. term.setCursorPos(1, 1)
  128. print("Saving your cookies")
  129. term.setCursorPos(1, 1)
  130. sleep(0.5)
  131. term.clear()
  132. term.setCursorPos(1, 1)
  133. print("Saving your cookies .")
  134. sleep(0.5)
  135. term.clear()
  136. term.setCursorPos(1, 1)
  137. print("Saving your cookies . .")
  138. sleep(0.5)
  139. term.clear()
  140. term.setCursorPos(1, 1)
  141. print("Saving your cookies . . .")
  142. sleep(0.5)
  143. term.clear()
  144. term.setCursorPos(1, 1)
  145. print("Saving your cookies . .")
  146. sleep(0.5)
  147. term.clear()
  148. term.setCursorPos(1, 1)
  149. print("Saving your cookies .")
  150. sleep(0.5)
  151. term.clear()
  152. term.setCursorPos(1, 1)
  153. print("Saving your cookies . .")
  154. sleep(0.5)
  155. term.clear()
  156. term.setCursorPos(1, 1)
  157. print("Saving your cookies . . .")
  158. local cookie = 0
  159. local filePath = "save"
  160. local fileHandle = fs.open (filePath, 'r')
  161. cookie = textutils.unserialize (fileHandle.readAll())
  162. fileHandle.close()
  163. local filePath = "save"
  164. local fileHandle = fs.open (filePath, 'w')
  165. fileHandle.write (textutils.serialize (cookie))
  166. fileHandle.close()
  167. sleep(0.3)
  168. term.clear()
  169. stp = shell.getRunningProgram()
  170. shell.run(stp)
  171. elseif event == "mouse_click" and x >= 2 and x <= 12 and y >= 3 and y <= 3 then
  172. local cookie = 0
  173. local filePath = "save"
  174. local fileHandle = fs.open (filePath, 'r')
  175. cookie = textutils.unserialize (fileHandle.readAll())
  176. fileHandle.close()
  177. local price = 0
  178. local filePath = "preis"
  179. local fileHandle = fs.open (filePath, 'r')
  180. price = textutils.unserialize (fileHandle.readAll())
  181. fileHandle.close()
  182. if cookie >= price then
  183. local cookie = cookie - price
  184. price = price + 3
  185. local filePath = "preis"
  186. local fileHandle = fs.open (filePath, 'w')
  187. fileHandle.write (textutils.serialize (price))
  188. fileHandle.close()
  189. local filePath = "save"
  190. local fileHandle = fs.open (filePath, 'w')
  191. fileHandle.write (textutils.serialize (cookie))
  192. fileHandle.close()
  193. term.clear()
  194. local autocooker = nil
  195. local filePath = "auto"
  196. local fileHandle = fs.open (filePath, 'r')
  197. autocooker = textutils.unserialize (fileHandle.readAll())
  198. fileHandle.close()
  199. autocooker = autocooker + 0.1
  200. local filePath = "auto"
  201. local fileHandle = fs.open (filePath, 'w')
  202. fileHandle.write (textutils.serialize (autocooker))
  203. fileHandle.close()
  204. term.setCursorPos(1, 1)
  205. print("Cookies: ",cookie)
  206. print("AutoCookies pro Sec: ",autocooker)
  207. term.setCursorPos(25, 9)
  208. print("O")
  209. term.setCursorPos(51, 1)
  210. print("X")
  211. term.setCursorPos(2, 3)
  212. local price = 0
  213. local filePath = "preis"
  214. local fileHandle = fs.open (filePath, 'r')
  215. price = textutils.unserialize (fileHandle.readAll())
  216. fileHandle.close()
  217. print("AutoClicker","[",price,"]")
  218. term.setCursorPos(1, 1)
  219. print("Cookies: ",cookie)
  220. elseif event == "mouse_click" and x >= 45 and x <= 51 and y >= 19 and y <= 19 then
  221. shell.run()
  222. end
  223.  
  224. end
  225. end
  226. end
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234. local function autoclick()
  235. while true do
  236. local stop2 = 0
  237. local filePath = "stop"
  238. local fileHandle = fs.open (filePath, 'r')
  239. stop2 = textutils.unserialize (fileHandle.readAll())
  240. fileHandle.close()
  241. local autocooker = nil
  242. local filePath = "auto"
  243. local fileHandle = fs.open (filePath, 'r')
  244. autocooker = textutils.unserialize (fileHandle.readAll())
  245. fileHandle.close()
  246. local filePath = "save"
  247. local fileHandle = fs.open (filePath, 'r')
  248. cookie = textutils.unserialize (fileHandle.readAll())
  249. fileHandle.close()
  250. if autocooker > 0 and stop2 == 0 then
  251. cookie = cookie + autocooker
  252. term.setCursorPos(1,1)
  253. local filePath = "save"
  254. local fileHandle = fs.open (filePath, 'w')
  255. fileHandle.write (textutils.serialize (cookie))
  256. fileHandle.close()
  257. print("Cookies: ",cookie)
  258. print("AutoCookies pro Sec: ",autocooker)
  259. term.setCursorPos(25, 9)
  260. print("O")
  261. term.setCursorPos(51, 1)
  262. print("X")
  263. term.setCursorPos(2, 3)
  264. local price = 0
  265. local filePath = "preis"
  266. local fileHandle = fs.open (filePath, 'r')
  267. price = textutils.unserialize (fileHandle.readAll())
  268. fileHandle.close()
  269. print("AutoClicker","[",price,"]")
  270. term.setCursorPos(1, 1)
  271. print("Cookies: ",cookie)
  272. sleep(1)
  273. else
  274. sleep(1)
  275.  
  276. end
  277. end
  278. end
  279.  
  280. parallel.waitForAny(click,autoclick)
  281.  
  282.  
  283.  
  284. elseif event2 == "mouse_click" and x >= 1 and x <= 8 and y >= 4 and y <= 4 then
  285. term.clear()
  286. term.setCursorPos(1, 1)
  287. local cookie = 0
  288. local filePath = "save"
  289. local fileHandle = fs.open (filePath, 'r')
  290. cookie = textutils.unserialize (fileHandle.readAll())
  291. print("Cookies: ",cookie)
  292. fileHandle.close()
  293. term.setCursorPos(1, 2)
  294. local autocooker = 0
  295. local filePath = "auto"
  296. local fileHandle = fs.open (filePath, 'r')
  297. autocooker = textutils.unserialize (fileHandle.readAll())
  298. fileHandle.close()
  299.  
  300. print("AutoCookies pro Sec: ",autocooker)
  301. term.setCursorPos(25, 9)
  302. print("O")
  303. term.setCursorPos(51, 1)
  304. print("X")
  305. term.setCursorPos(2, 3)
  306. local price = 0
  307. local filePath = "preis"
  308. local fileHandle = fs.open (filePath, 'r')
  309. price = textutils.unserialize (fileHandle.readAll())
  310. fileHandle.close()
  311. print("AutoClicker","[",price,"]")
  312. local function click()
  313. while true do
  314. local event, button, x, y = os.pullEvent("mouse_click")
  315. if event == "mouse_click" and x >= 25 and x <= 25 and y >= 9 and y <= 9 then
  316. local filePath = "save"
  317. local fileHandle = fs.open (filePath, 'r')
  318. cookie = textutils.unserialize (fileHandle.readAll())
  319. fileHandle.close()
  320. cookie = cookie + 1
  321. local filePath = "save"
  322. local fileHandle = fs.open (filePath, 'w')
  323. fileHandle.write (textutils.serialize (cookie))
  324. fileHandle.close()
  325. local autocooker = nil
  326. local filePath = "auto"
  327. local fileHandle = fs.open (filePath, 'r')
  328. autocooker = textutils.unserialize (fileHandle.readAll())
  329. fileHandle.close()
  330. term.clear()
  331. term.setCursorPos(1,1)
  332. print("Cookies: ",cookie)
  333. term.setCursorPos(1, 2)
  334. print("AutoCookies pro Sec: ",autocooker)
  335. term.setCursorPos(25, 9)
  336. print("O")
  337. term.setCursorPos(51, 1)
  338. print("X")
  339. term.setCursorPos(2, 3)
  340. local price = 0
  341. local filePath = "preis"
  342. local fileHandle = fs.open (filePath, 'r')
  343. price = textutils.unserialize (fileHandle.readAll())
  344. fileHandle.close()
  345. print("AutoClicker","[",price,"]")
  346. elseif event == "mouse_click" and x >= 51 and x <= 51 and y >= 1 and y <= 1 then
  347. term.clear()
  348. local stop2 = 1
  349. local filePath = "stop"
  350. local fileHandle = fs.open (filePath, 'w')
  351. fileHandle.write (textutils.serialize (stop2))
  352. fileHandle.close()
  353. term.setCursorPos(1, 1)
  354. print("Saving your cookies")
  355. term.setCursorPos(1, 1)
  356. sleep(0.5)
  357. term.clear()
  358. term.setCursorPos(1, 1)
  359. print("Saving your cookies .")
  360. sleep(0.5)
  361. term.clear()
  362. term.setCursorPos(1, 1)
  363. print("Saving your cookies . .")
  364. sleep(0.5)
  365. term.clear()
  366. term.setCursorPos(1, 1)
  367. print("Saving your cookies . . .")
  368. sleep(0.5)
  369. term.clear()
  370. term.setCursorPos(1, 1)
  371. print("Saving your cookies . .")
  372. sleep(0.5)
  373. term.clear()
  374. term.setCursorPos(1, 1)
  375. print("Saving your cookies .")
  376. sleep(0.5)
  377. term.clear()
  378. term.setCursorPos(1, 1)
  379. print("Saving your cookies . .")
  380. sleep(0.5)
  381. term.clear()
  382. term.setCursorPos(1, 1)
  383. print("Saving your cookies . . .")
  384. local cookie = 0
  385. local filePath = "save"
  386. local fileHandle = fs.open (filePath, 'r')
  387. cookie = textutils.unserialize (fileHandle.readAll())
  388. fileHandle.close()
  389. local filePath = "save"
  390. local fileHandle = fs.open (filePath, 'w')
  391. fileHandle.write (textutils.serialize (cookie))
  392. fileHandle.close()
  393. sleep(0.3)
  394. term.clear()
  395. error()
  396. elseif event == "mouse_click" and x >= 2 and x <= 12 and y >= 3 and y <= 3 then
  397. local cookie = 0
  398. local filePath = "save"
  399. local fileHandle = fs.open (filePath, 'r')
  400. cookie = textutils.unserialize (fileHandle.readAll())
  401. fileHandle.close()
  402. local price = 0
  403. local filePath = "preis"
  404. local fileHandle = fs.open (filePath, 'r')
  405. price = textutils.unserialize (fileHandle.readAll())
  406. fileHandle.close()
  407. if cookie >= price then
  408. local cookie = cookie - price
  409. price = price + 3
  410. local filePath = "preis"
  411. local fileHandle = fs.open (filePath, 'w')
  412. fileHandle.write (textutils.serialize (price))
  413. fileHandle.close()
  414. local filePath = "save"
  415. local fileHandle = fs.open (filePath, 'w')
  416. fileHandle.write (textutils.serialize (cookie))
  417. fileHandle.close()
  418. term.clear()
  419. local autocooker = nil
  420. local filePath = "auto"
  421. local fileHandle = fs.open (filePath, 'r')
  422. autocooker = textutils.unserialize (fileHandle.readAll())
  423. fileHandle.close()
  424. autocooker = autocooker + 0.1
  425. local filePath = "auto"
  426. local fileHandle = fs.open (filePath, 'w')
  427. fileHandle.write (textutils.serialize (autocooker))
  428. fileHandle.close()
  429. term.setCursorPos(1, 1)
  430. print("Cookies: ",cookie)
  431. print("AutoCookies pro Sec: ",autocooker)
  432. term.setCursorPos(25, 9)
  433. print("O")
  434. term.setCursorPos(51, 1)
  435. print("X")
  436. term.setCursorPos(2, 3)
  437. local price = 0
  438. local filePath = "preis"
  439. local fileHandle = fs.open (filePath, 'r')
  440. price = textutils.unserialize (fileHandle.readAll())
  441. fileHandle.close()
  442. print("AutoClicker","[",price,"]")
  443. term.setCursorPos(1, 1)
  444. print("Cookies: ",cookie)
  445. elseif event == "mouse_click" and x >= 45 and x <= 51 and y >= 19 and y <= 19 then
  446. shell.run()
  447. end
  448.  
  449. end
  450. end
  451. end
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459. local function autoclick()
  460. while true do
  461. local stop2 = 0
  462. local filePath = "stop"
  463. local fileHandle = fs.open (filePath, 'r')
  464. stop2 = textutils.unserialize (fileHandle.readAll())
  465. fileHandle.close()
  466. local autocooker = nil
  467. local filePath = "auto"
  468. local fileHandle = fs.open (filePath, 'r')
  469. autocooker = textutils.unserialize (fileHandle.readAll())
  470. fileHandle.close()
  471. local filePath = "save"
  472. local fileHandle = fs.open (filePath, 'r')
  473. cookie = textutils.unserialize (fileHandle.readAll())
  474. fileHandle.close()
  475. if autocooker > 0 and stop2 == 0 then
  476. cookie = cookie + autocooker
  477. term.setCursorPos(1,1)
  478. local filePath = "save"
  479. local fileHandle = fs.open (filePath, 'w')
  480. fileHandle.write (textutils.serialize (cookie))
  481. fileHandle.close()
  482. print("Cookies: ",cookie)
  483. print("AutoCookies pro Sec: ",autocooker)
  484. term.setCursorPos(25, 9)
  485. print("O")
  486. term.setCursorPos(51, 1)
  487. print("X")
  488. term.setCursorPos(2, 3)
  489. local price = 0
  490. local filePath = "preis"
  491. local fileHandle = fs.open (filePath, 'r')
  492. price = textutils.unserialize (fileHandle.readAll())
  493. fileHandle.close()
  494. print("AutoClicker","[",price,"]")
  495. term.setCursorPos(1, 1)
  496. print("Cookies: ",cookie)
  497. sleep(1)
  498. else
  499. sleep(1)
  500.  
  501. end
  502. end
  503. end
  504.  
  505. parallel.waitForAny(click,autoclick)
  506. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement