kd8lvt

Cookie Clicker NOT MINE!!

Dec 6th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.35 KB | None | 0 0
  1. backcolor = 1
  2. textcolor = 188
  3. a = 1
  4. add = 1
  5. cost = 100
  6. fs.makeDir("cookies")
  7.  
  8. if not fs.exists("cookies/cookiea") then
  9.     mc = fs.open("cookies/cookiea", "w")
  10.     mc.write("0")
  11.     mc.close()
  12. end
  13. cc = fs.open("cookies/cookiea", "r")
  14. a = cc.readLine()
  15. cc.close()
  16.  
  17. if not fs.exists("cookies/background") then
  18.     shell.run("pastebin", "get", "1LaRjsPG", "cookies/background")
  19. end
  20.  
  21. function clear()
  22.     term.clear()
  23.     term.setCursorPos(1,1)
  24. end
  25.  
  26. function cookie()
  27.     term.setBackgroundColor(backcolor)
  28.     term.clear()
  29.     bground = paintutils.loadImage("cookies/background")
  30.     paintutils.drawImage(bground,1,1)
  31.     term.setCursorPos(1,1)
  32.     term.setBackgroundColor(backcolor)
  33.     term.setTextColor(textcolor)
  34.     print("Cookie clicker V0.1")
  35.     term.setCursorPos(25,1)
  36.     print("Reset cookie clicker")
  37.     term.setCursorPos(25,4)
  38.     print("Double click(100 cookies)")
  39.     term.setCursorPos(25,3)
  40.     print("Upgrades:")
  41.     term.setCursorPos(1,18)
  42.     print("Exit")
  43.     term.setCursorPos(4,16)
  44.     print(a)
  45. end
  46. cookie()
  47.  
  48. while true do
  49.     local event, button, X, Y = os.pullEventRaw()
  50.     if event == "mouse_click" then
  51.         if X >=25 and X <=45 and button == 1 and Y== 1 then
  52.             fs.delete("cookies/cookiea")
  53.             fs.delete("cookies/upgrade")
  54.             mc = fs.open("cookies/cookiea", "w")
  55.             mc.write("0")
  56.             mc.close()
  57.             a = 0
  58.             add = 1
  59.             cookie()
  60.         elseif X >=25 and X <=50 and button == 1 and Y== 4 then
  61.             clear()
  62.             if not fs.exists("cookies/upgrade") then
  63.                 if upg == true then
  64.                     clear()
  65.                     up = fs.open("cookies/upgrade", "w")
  66.                     up.write("true")
  67.                     up.close()
  68.                     upcc = a - cost
  69.                     fs.delete("cookies/cookiea")
  70.                     upc = fs.open("cookies/cookiea", "w")
  71.                     upc.write(upcc)
  72.                     upc.close()
  73.                 end
  74.             end
  75.             cookie()
  76.         elseif X>=1 and X<=4 and Y== 18 and button ==1 then
  77.             os.reboot()
  78.         elseif X >=4 and X <=16 and button == 1 and Y >=6 and Y <=13 then
  79.             clear()
  80.             if a == "100.0" then
  81.                 upg = true
  82.             end
  83.             if fs.exists("cookies/upgrade") then
  84.                 add = 2
  85.             end
  86.             a = a + add
  87.             fs.delete("cookies/cookiea")
  88.             ca = fs.open("cookies/cookiea", "w")
  89.             ca.write(a)
  90.             ca.close()
  91.             cc = fs.open("cookies/cookiea", "r")
  92.             a = cc.readLine()
  93.             cc.close()
  94.             cookie()
  95.             if a == "1.0" then
  96.                 term.setCursorPos(1,3)
  97.                 print("Wake and bake")
  98.             end
  99.             if a == "100.0" then
  100.                 term.setCursorPos(1,3)
  101.                 print("100 COOKIES")
  102.             end
  103.         end
  104.     end
  105. end
Add Comment
Please, Sign In to add comment