Advertisement
Guest User

cc

a guest
Oct 31st, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.15 KB | None | 0 0
  1. local icon_cookie = paintutils.loadImage("cookie")
  2. upgrade = 1
  3. upgradecost = 10
  4. cookie = 0
  5. c1 = colors.cyan
  6. c2 = colors.white
  7. c3 = colors.black
  8.  
  9. function drawScreen()
  10.   term.setBackgroundColor(c2)
  11.   term.clear()
  12.   term.setCursorPos(1,1)
  13.   term.setBackgroundColor(c1)
  14.   term.clearLine()
  15.   term.setCursorPos(1,2)
  16.   term.clearLine()
  17.   term.setCursorPos(1,3)
  18.   term.clearLine()
  19.   term.setCursorPos(3,2)
  20.   print(" "..cookie.." COOKIES")
  21.   term.setCursorPos(1,19)
  22.   term.clearLine()
  23.   term.setCursorPos(4,6)
  24.   term.setBackgroundColor(c2)
  25.   paintutils.drawImage(icon_cookie,10,6)
  26.   term.setCursorPos(3,19)
  27.   term.setBackgroundColor(c1)
  28.   write("[ UPGRADE ] [ EXIT ]")
  29. end
  30. function upgrades()
  31.   term.setBackgroundColor(c2)
  32.   term.setTextColor(c3)
  33.   term.clear()
  34.   term.setBackgroundColor(c1)
  35.   term.setCursorPos(1,1)
  36.   term.clearLine()
  37.   write("    [exit]      Upgrades")
  38.   term.setBackgroundColor(c2)
  39.   term.setCursorPos(2,3)
  40.   print("[ UPGRADE ] Cost: "..upgradecost)
  41.   slc = 0
  42.   local event, button, x, y = os.pullEvent()
  43.   while true do
  44.     if slc == 0 then
  45.       if event == "mouse_click" then
  46.         if x >= 3 and x <= 13 and y == 3 and button == 1 then slc = 0
  47.           cookie = cookie - upgradecost
  48.           if cookie <= 0 then
  49.             cookie = cookie + upgradecost
  50.             upgrades()
  51.           end
  52.           upgrade = upgrade + 1
  53.           upgradecost = upgradecost + 3
  54.           upgrades()
  55.         elseif x >= 1 and x >= 6 and y == 1 and button == 1 then slc = 0
  56.           main()
  57.         else
  58.           upgrades()
  59.         end
  60.       end
  61.     end
  62.   end
  63. end
  64. slc = 0
  65.  
  66. function main()
  67.   while true do
  68.     drawScreen()
  69.     local event, button, x, y = os.pullEvent()
  70.     if slc == 0 then
  71.       if event == "mouse_click" then
  72.         if x >= 3 and x <= 13 and y == 19 and button == 1 then slc = 0
  73.           upgrades()
  74.         elseif x >= 10 and x <= 20 and y >= 6 and y <= 15 then
  75.           cookie = cookie + upgrade
  76.           main()
  77.         elseif x >= 15 and x <= 21 and y == 19 and button == 1 then slc = 0
  78.           os.reboot()
  79.         else
  80.           main()
  81.         end
  82.       end
  83.     end
  84.   end
  85. end
  86.  
  87. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement