View difference between Paste ID: nskTfHev and MC1yQbRh
SHOW: | | - or go back to the newest paste.
1
-- Get the terminal size. Helpful for displaying text
2
local w, h = term.getSize() 
3
4
-- Paint title
5-
paintutils.drawFilledBox(0, 0, w, 2, colors.cyan)
5+
6
paintutils.drawFilledBox(0, 0, w, 2, colors.cyan)	
7-
function printCentered(sText)
7+
8
-- Add in the close button
9
term.setCursorPos(w - 1,1)
10
term.setBackgroundColor(colors.red)
11
term.write(" X")
12
13
-- Load in the username from the load game screen
14-
function displayNumber(num, isInt)
14+
local args = {...}
15
16-
    num = num or 0
16+
-- If the username was passed along, set it to a variable
17-
    isInt = isInt or false
17+
local username = ""
18
if args[1] then
19-
    if num >= 100000 then
19+
    username = args[1]
20-
        newNum = num / 100000
20+
else
21
    username = ""
22
end
23
24
-- This function will calculate a new upgrade price based on the base price and the amount owned
25
function calculateNewPrice(basePrice, owned)
26
    local newPrice = math.floor((basePrice * math.pow(1.1, owned)) + 0.5)
27
    return newPrice
28
end
29
30
-- This function saves all of the variables to the users save file to be read when the game loads
31
local function save()
32
   local hWrite = fs.open("saves/" .. username .. "_save_file", "w")
33
   hWrite.writeLine(cps)
34
   hWrite.writeLine(diamonds)
35
   hWrite.writeLine(diamondsGiven)
36
   hWrite.writeLine(store)
37
   hWrite.writeLine(woodPickPrice)
38
   hWrite.writeLine(woodPicksOwned)
39
   hWrite.writeLine(woodPickCPS)
40
   hWrite.writeLine(stonePickPrice)
41
   hWrite.writeLine(stonePicksOwned)
42
   hWrite.writeLine(stonePickCPS)
43
   hWrite.writeLine(ironPickPrice)
44
   hWrite.writeLine(ironPicksOwned)
45
   hWrite.writeLine(ironPickCPS)
46
   hWrite.writeLine(diamondPickPrice)
47
   hWrite.writeLine(diamondPicksOwned)
48
   hWrite.writeLine(diamondPickCPS)
49
   hWrite.writeLine(woodPickUpgradePrice)
50-
paintutils.drawPixel(5, 6, colors.black)
50+
   hWrite.writeLine(woodPickUpgradesOwned)
51-
paintutils.drawPixel(6, 6, colors.black)
51+
   hWrite.writeLine(woodPickMultiplier)
52-
paintutils.drawPixel(7, 6, colors.black)
52+
   hWrite.writeLine(stonePickUpgradePrice)
53
   hWrite.writeLine(stonePickUpgradesOwned)
54-
paintutils.drawPixel(9, 8, colors.black)
54+
   hWrite.writeLine(stonePickMultiplier)
55-
paintutils.drawPixel(10, 9, colors.black)
55+
   hWrite.writeLine(ironPickUpgradePrice)
56-
paintutils.drawPixel(10, 10, colors.black)
56+
   hWrite.writeLine(ironPickUpgradesOwned)
57-
paintutils.drawPixel(9, 11, colors.black)
57+
   hWrite.writeLine(ironPickMultiplier)
58-
paintutils.drawPixel(8, 12, colors.black)
58+
   hWrite.writeLine(diamondPickUpgradePrice)
59-
paintutils.drawPixel(7, 12, colors.black)
59+
   hWrite.writeLine(diamondPickUpgradesOwned)
60-
paintutils.drawPixel(6, 12, colors.black)
60+
   hWrite.writeLine(diamondPickMultiplier)
61
   hWrite.close()
62-
paintutils.drawPixel(4, 12, colors.black)
62+
63-
paintutils.drawPixel(3, 11, colors.black)
63+
64-
paintutils.drawPixel(2, 10, colors.black)
64+
-- This function will load all of the variables saved to the users save file
65-
paintutils.drawPixel(2, 9, colors.black)
65+
local function load()
66-
paintutils.drawPixel(3, 8, colors.black)
66+
    local hRead = fs.open("saves/" .. username .. "_save_file", "r")
67-
paintutils.drawPixel(4, 7, colors.black)
67+
    if hRead then
68-
paintutils.drawPixel(5, 7, colors.white)
68+
        cps = tonumber(hRead.readLine())
69-
paintutils.drawPixel(6, 7, colors.white)
69+
        diamonds = tonumber(hRead.readLine())
70-
paintutils.drawPixel(7, 7, colors.white)
70+
        diamondsGiven = tonumber(hRead.readLine())
71-
paintutils.drawPixel(4, 8, colors.white)
71+
        store = hRead.readLine()
72-
paintutils.drawPixel(5, 8, colors.cyan)
72+
        if store == "true" then
73-
paintutils.drawPixel(6, 8, colors.cyan)
73+
            store = true
74-
paintutils.drawPixel(7, 8, colors.cyan)
74+
        else 
75-
paintutils.drawPixel(8, 8, colors.cyan)
75+
            store = false
76-
paintutils.drawPixel(3, 9, colors.cyan)
76+
77-
paintutils.drawPixel(4, 9, colors.blue)
77+
        woodPickPrice = tonumber(hRead.readLine())
78-
paintutils.drawPixel(5, 9, colors.cyan)
78+
        woodPicksOwned = tonumber(hRead.readLine())
79-
paintutils.drawPixel(6, 9, colors.cyan)
79+
        woodPickCPS = tonumber(hRead.readLine())
80
        stonePickPrice = tonumber(hRead.readLine())
81-
paintutils.drawPixel(8, 9, colors.blue)
81+
        stonePicksOwned = tonumber(hRead.readLine())
82
        stonePickCPS = tonumber(hRead.readLine())
83-
paintutils.drawPixel(3, 10, colors.cyan)
83+
        ironPickPrice = tonumber(hRead.readLine())
84-
paintutils.drawPixel(4, 10, colors.blue)
84+
        ironPicksOwned = tonumber(hRead.readLine())
85-
paintutils.drawPixel(5, 10, colors.blue)
85+
        ironPickCPS = tonumber(hRead.readLine())
86
        diamondPickPrice = tonumber(hRead.readLine())
87-
paintutils.drawPixel(7, 10, colors.blue)
87+
        diamondPicksOwned = tonumber(hRead.readLine())
88-
paintutils.drawPixel(8, 10, colors.blue)
88+
        diamondPickCPS = tonumber(hRead.readLine())
89
        woodPickUpgradePrice = tonumber(hRead.readLine())
90-
paintutils.drawLine(4, 11, 8, 11, colors.cyan)
90+
        woodPickUpgradesOwned = tonumber(hRead.readLine())
91
        woodPickMultiplier = tonumber(hRead.readLine())
92
        stonePickUpgradePrice = tonumber(hRead.readLine())
93
        stonePickUpgradesOwned = tonumber(hRead.readLine())
94
        stonePickMultiplier = tonumber(hRead.readLine())
95
        ironPickUpgradePrice = tonumber(hRead.readLine())
96
        ironPickUpgradesOwned = tonumber(hRead.readLine())
97
        ironPickMultiplier = tonumber(hRead.readLine())
98
        diamondPickUpgradePrice = tonumber(hRead.readLine())
99
        diamondPickUpgradesOwned = tonumber(hRead.readLine())
100
        diamondPickMultiplier = tonumber(hRead.readLine())
101
        hRead.close()
102-
    paintutils.drawLine(5, 5, 7, 5, color)
102+
       
103-
    paintutils.drawPixel(8, 6, color)
103+
        return true
104-
    paintutils.drawPixel(9, 7, color)
104+
   else
105-
    paintutils.drawPixel(10, 8, color)
105+
        return false
106-
    paintutils.drawLine(11, 9, 11, 10, color)
106+
   end
107-
    paintutils.drawPixel(10, 11, color)
107+
108-
    paintutils.drawPixel(9, 12, color)
108+
109-
    paintutils.drawLine(8, 13, 4, 13, color)
109+
-- Use this function to print text centered on the screen
110-
    paintutils.drawPixel(3, 12, color)
110+
local function printCentered(sText)
111-
    paintutils.drawPixel(2, 11, color)
111+
112-
    paintutils.drawLine(1, 10, 1, 9, color)
112+
113-
    paintutils.drawPixel(2, 8, color)
113+
114-
    paintutils.drawPixel(3, 7, color)
114+
115-
    paintutils.drawPixel(4, 6, color) 
115+
116
117
-- Initialize variables that don't need to be saved
118
woodPickBasePrice = 15
119-
score = 0
119+
woodPickStartingCPS = .2
120-
diamondsGiven = 0
120+
121
stonePickBasePrice = 100
122-
function setScore()
122+
stonePickStartingCPS = .8
123
124-
    x = x or 0
124+
ironPickBasePrice = 500
125-
    y = y or 0
125+
ironPickStartingCPS = 4
126
127
diamondPickBasePrice = 2000
128
diamondPickStartingCPS = 10
129
130
-- Load the variables on launch, if this is the first time playing, create the variables
131-
            if score == 10 and diamondsGiven == 0 then
131+
if load() then
132-
                diamondsGiven = diamondsGiven + 1
132+
    load()
133
else 
134
    diamonds = 0
135
    cps = 0
136
    diamondsGiven = 0
137
    store = false
138-
        drawUpgrades()
138+
139-
        cps = woodPickCPS
139+
    -- Wooden Pick Data
140-
        score = score + (cps * .05)
140+
    woodPickPrice = 15
141
    woodPicksOwned = 0
142
    woodPickCPS = 0
143
144-
        term.clearLine()
144+
    -- Stone Pick Data
145-
        term.write(tostring(displayNumber(score)) .. " diamonds")
145+
    stonePickPrice = 100
146
    stonePicksOwned = 0
147
    stonePickCPS = 0
148
149
    -- Iron Pick Data
150
    ironPickPrice = 500
151
    ironPicksOwned = 0
152
    ironPickCPS = 0
153
154
    -- Diamond Pick Data
155
    diamondPickPrice = 2000
156-
            if ((x>=3 and x<=10) and (y>= 6 and y<= 12)) then
156+
    diamondPicksOwned = 0
157
    diamondPickCPS = 0
158
159
    -- Wooden Pick Upgrade Data
160-
                score = score + 1
160+
    woodPickUpgradePrice = 100
161
    woodPickUpgradesOwned = 0
162
    woodPickMultiplier = 1
163
164-
        drawUpgrades(x, y)
164+
    -- Stone Pick Store Data
165
    stonePickUpgradePrice = 1000
166
    stonePickUpgradesOwned = 0
167
    stonePickMultiplier = 1
168-
woodPickPrice = 15
168+
169-
woodPicksOwned = 0
169+
    -- Iron Pick Store Data
170-
woodPickCPS = 0
170+
    ironPickUpgradePrice = 10000
171
    ironPickUpgradesOwned = 0
172-
cps = 0
172+
    ironPickMultiplier = 1
173
174
    -- Diamond Pick Store Data
175
    diamondPickUpgradePrice = 100000
176-
    x = x or 0
176+
    diamondPickUpgradesOwned = 0
177-
    y = y or 0
177+
    diamondPickMultiplier = 1
178
    
179-
        -- Draw the first upgrade
179+
180-
        if score >= woodPickPrice then
180+
181
-- Use this function to correctly display a number. 
182-
            paintutils.drawFilledBox(15, 6, 27, 10, colors.green)
182+
-- num is the number to format, if isInt is true, it will round to the nearest int
183-
            if ((x>=15 and x<=25) and (y>=6 and y<=10)) then
183+
local function displayNumber(num, isInt)
184-
                score = score - woodPickPrice
184+
185
    local num = num or 0
186-
                woodPickPrice = math.floor((woodPickPrice * 1.25) + 0.5)
186+
    local newNum = 0
187-
                woodPickCPS = woodPickCPS + .1
187+
    local isInt = isInt or false
188
    
189-
        elseif score < woodPickPrice then
189+
    if num >= 1000000 then
190
        newNum = num / 1000000
191-
            paintutils.drawFilledBox(15, 6, 27, 10, colors.red)
191+
192
        newNum = tostring(newNum)
193
        if isInt == false then
194-
        term.setCursorPos(16,6)
194+
195
        end
196-
        term.setCursorPos(16,7)
196+
197
        newNum = num / 1000
198-
        term.setCursorPos(16,8)
198+
199-
        term.write("Price:" .. displayNumber(woodPickPrice, true))
199+
200-
        term.setCursorPos(16,9)
200+
201
            newNum = string.format("%.1f", newNum) .. "K"
202-
        term.setCursorPos(16,10)
202+
203-
        term.write("CPS:" .. (displayNumber(woodPickCPS)))
203+
204
        newNum = tostring(num)
205
        if isInt == false then
206
            newNum = string.format("%.1f", newNum)
207
        end
208-
parallel.waitForAny(setScore, handleTouchInputs)
208+
209
    
210
    return newNum
211
end
212
213
-- Write the title text
214
term.setCursorPos(0,1)
215
term.setBackgroundColour(colours.cyan)
216
term.setTextColour(colours.white)
217
printCentered("Diamond Digger")
218
print(string.rep("-", w))
219
220
-- Draw diamond
221
paintutils.drawPixel(7, 7, colors.black)
222
paintutils.drawPixel(8, 7, colors.black)
223
paintutils.drawPixel(9, 7, colors.black)
224
paintutils.drawPixel(10, 8, colors.black)
225
paintutils.drawPixel(11, 9, colors.black)
226
paintutils.drawPixel(12, 10, colors.black)
227
paintutils.drawPixel(12, 11, colors.black)
228
paintutils.drawPixel(11, 12, colors.black)
229
paintutils.drawPixel(10, 13, colors.black)
230
paintutils.drawPixel(9, 13, colors.black)
231
paintutils.drawPixel(8, 13, colors.black)
232
paintutils.drawPixel(7, 13, colors.black)
233
paintutils.drawPixel(6, 13, colors.black)
234
paintutils.drawPixel(5, 12, colors.black)
235
paintutils.drawPixel(4, 11, colors.black)
236
paintutils.drawPixel(4, 10, colors.black)
237
paintutils.drawPixel(5, 9, colors.black)
238
paintutils.drawPixel(6, 8, colors.black)
239
paintutils.drawPixel(7, 8, colors.white)
240
paintutils.drawPixel(8, 8, colors.white)
241
paintutils.drawPixel(9, 8, colors.white)
242
paintutils.drawPixel(6, 9, colors.white)
243
paintutils.drawPixel(7, 9, colors.cyan)
244
paintutils.drawPixel(8, 9, colors.cyan)
245
paintutils.drawPixel(9, 9, colors.cyan)
246
paintutils.drawPixel(10, 9, colors.cyan)
247
paintutils.drawPixel(5, 10, colors.cyan)
248
paintutils.drawPixel(6, 10, colors.blue)
249
paintutils.drawPixel(7, 10, colors.cyan)
250
paintutils.drawPixel(8, 10, colors.cyan)
251
paintutils.drawPixel(9, 10, colors.cyan)
252
paintutils.drawPixel(10, 10, colors.blue)
253
paintutils.drawPixel(11, 10, colors.cyan)
254
paintutils.drawPixel(5, 11, colors.cyan)
255
paintutils.drawPixel(6, 11, colors.blue)
256
paintutils.drawPixel(7, 11, colors.blue)
257
paintutils.drawPixel(8, 11, colors.blue)
258
paintutils.drawPixel(9, 11, colors.blue)
259
paintutils.drawPixel(10, 11, colors.blue)
260
paintutils.drawPixel(11, 11, colors.cyan)
261
paintutils.drawLine(6, 12, 10, 12, colors.cyan)
262
263
-- A function used to control the logic of the white outline around the diamond on click
264
function updateDiamondOutline()
265
    drawDiamondOutline(colors.white)
266
    sleep(.2)
267
    drawDiamondOutline(colors.gray)
268
end
269
270
-- The function that draws the diamond outline to the screen
271
function drawDiamondOutline(color)
272
273
    color = color or colors.gray
274
    
275
    paintutils.drawLine(7, 6, 9, 6, color)
276
    paintutils.drawPixel(10, 7, color)
277
    paintutils.drawPixel(11, 8, color)
278
    paintutils.drawPixel(12, 9, color)
279
    paintutils.drawLine(13, 10, 13, 11, color)
280
    paintutils.drawPixel(12, 12, color)
281
    paintutils.drawPixel(11, 13, color)
282
    paintutils.drawLine(10, 14, 6, 14, color)
283
    paintutils.drawPixel(5, 13, color)
284
    paintutils.drawPixel(4, 12, color)
285
    paintutils.drawLine(3, 11, 3, 10, color)
286
    paintutils.drawPixel(4, 9, color)
287
    paintutils.drawPixel(5, 8, color)
288
    paintutils.drawPixel(6, 7, color) 
289
   
290
end
291
292
-- Draw shop button
293
term.setTextColour(colours.white)
294
term.setBackgroundColor(colors.cyan)
295
term.setCursorPos(5, 16)
296
term.write("       ")
297
term.setCursorPos(5, 17)
298
term.write(" Store ")
299
term.setCursorPos(5, 18)
300
term.write("       ")
301
302
-- A function used to set the score
303
function setDiamonds()
304
    
305
    while true do
306
        os.sleep(0)
307
        
308
        -- If the game is being run on a command computer, give the player diamonds for certain milestones
309
        if commands then
310
            if diamonds >= 100 and diamondsGiven == 0 then
311
                diamondsGiven = 1
312
                commands.say("@p has earned a diamond by playing Diamond Digger!")
313
                commands.exec("give @p diamond 1")
314
            elseif diamonds >= 1000 and diamondsGiven == 1 then
315
                diamondsGiven = 2
316
                commands.say("@p has earned a diamond by playing Diamond Digger!")
317
                commands.exec("give @p diamond 1")
318
            elseif diamonds >= 10000 and diamondsGiven == 2 then
319
                diamondsGiven = 3
320
                commands.say("@p has earned a diamond by playing Diamond Digger!")
321
                commands.exec("give @p diamond 1")
322
            elseif diamonds >= 100000 and diamondsGiven == 3 then
323
                diamondsGiven = 4
324
                commands.say("@p has earned a diamond by playing Diamond Digger!")
325
                commands.exec("give @p diamond 1")
326
            elseif diamonds >= 1000000 and diamondsGiven == 3 then
327
                diamondsGiven = 5
328
                commands.say("@p has earned a diamond by playing Diamond Digger!")
329
                commands.exec("give @p diamond 1")
330
            end
331
        end
332
        
333
        -- If we are on the store page, draw the store, else, draw the upgrades page
334
        if store == false then
335
        	drawUpgrades(0,0)
336
        else 
337
            drawStore(0,0)
338
        end
339
        
340
        -- Calculate the clicks per second based on the upgrades and their multipliers
341
        cps = (woodPickCPS * woodPickMultiplier) + (stonePickCPS * stonePickMultiplier) + (ironPickCPS * ironPickMultiplier) + (diamondPickCPS * diamondPickMultiplier)
342
        
343
        -- Calculate the new score based on the current diamonds, and the clicks per second
344
        -- The .05 is used to convert it from ticks to seconds
345
        diamonds = diamonds + (cps * .05)
346
        term.setBackgroundColor(colors.gray)
347
        term.setTextColor(colors.white)
348
        term.setCursorPos(2,4)
349
        
350
        -- I'm not all that familiar with Lua:CC so this is the dumb code I came up with instead of clearing the whole line
351
        local diamondString = tostring(displayNumber(diamonds)) .. " diamonds"
352
        
353
        while string.len(diamondString) < 15 do
354
            diamondString = diamondString .. " "
355
        end
356
        
357
        term.write(diamondString)
358
        term.setCursorPos(2,5)
359
        
360
        local cpsString = tostring(displayNumber(cps)) ..  " CPS"
361
   
362
        while string.len(cpsString) < 11 do
363
            cpsString = cpsString .. " "
364
        end
365
        
366
        term.write(cpsString)
367
    end
368
end    
369
370
-- Get the touch inputs and redirect accordingly
371
function handleTouchInputs()
372
    while true do
373
        save()
374
        local event, side, x, y = os.pullEvent()
375
  
376
        if event == "monitor_touch" or event == "mouse_click" then
377
            if ((x>=4 and x<=12) and (y>= 7 and y<= 13)) then
378
                updateDiamondOutline()
379
                term.setCursorPos(2,4)
380
                term.clearLine()
381
                diamonds = diamonds + 1
382
            elseif ((x>=5 and x<= 11) and (y>=16 and y<=18)) then
383
                sleep(.2)
384
            	if store == false then
385
                    store = true
386
                else 
387
                    store = false
388
                end
389
            elseif ((x == w or x == w - 1) and y == 1) then
390
            	os.reboot()
391
            end
392
                
393
        end
394
    	
395
        term.setTextColour(colours.white)
396
        term.setBackgroundColor(colors.cyan)
397
        term.setCursorPos(5, 17)
398
        if store == false then
399
            term.write(" Store ")
400
        	drawUpgrades(x, y)
401
        else 
402
            term.write(" Picks ")
403
            drawStore(x, y)
404
        end
405
        
406
    end
407
end
408
409
-- This function draws all of the upgrades onto the screen
410
function drawUpgrades(x,y)
411
    
412
    local x = x or 0
413
    local y = y or 0
414
    
415
    -- Draw upgrades outline
416
    paintutils.drawFilledBox(18, 5, 48, 18, colors.black)
417
    paintutils.drawFilledBox(32, 6, 34, 17, colors.black)
418
    paintutils.drawFilledBox(19, 11, 47, 12, colors.black)
419
    
420
        -- Wooden Pick
421
        if diamonds >= woodPickPrice then
422
            term.setBackgroundColor(colors.green)
423
            paintutils.drawFilledBox(19, 6, 31, 10, colors.green)
424
            if ((x>=19 and x<=31) and (y>=6 and y<=10)) then
425
                diamonds = diamonds - woodPickPrice
426
                woodPicksOwned = woodPicksOwned + 1
427
                woodPickPrice = calculateNewPrice(woodPickBasePrice, woodPicksOwned)
428
                woodPickCPS = woodPickCPS + woodPickStartingCPS
429
            end
430
        elseif diamonds < woodPickPrice then
431
            term.setBackgroundColor(colors.red)
432
            paintutils.drawFilledBox(19, 6, 31, 10, colors.red)
433
        end  
434
    
435
        term.setCursorPos(20,6)
436
        term.write("Wooden")
437
        term.setCursorPos(20,7)
438
        term.write("Pickaxe")
439
        term.setCursorPos(20,8)
440
        term.write("Price:" .. displayNumber(woodPickPrice))
441
        term.setCursorPos(20,9)
442
        term.write("Owned:" .. displayNumber(woodPicksOwned, true))
443
        term.setCursorPos(20,10)
444
        term.write("CPS:" .. (displayNumber(woodPickCPS * woodPickMultiplier)))
445
    
446
        -- Stone Pick
447
        if diamonds >= stonePickPrice then
448
            term.setBackgroundColor(colors.green)
449
            paintutils.drawFilledBox(35, 6, 47, 10, colors.green)
450
            if ((x>=35 and x<=47) and (y>=6 and y<=10)) then
451
                diamonds = diamonds - stonePickPrice
452
                stonePicksOwned = stonePicksOwned + 1
453
                stonePickPrice = calculateNewPrice(stonePickBasePrice, stonePicksOwned)
454
                stonePickCPS = stonePickCPS + stonePickStartingCPS
455
            end
456
        elseif diamonds < stonePickPrice then
457
            term.setBackgroundColor(colors.red)
458
            paintutils.drawFilledBox(35, 6, 47, 10, colors.red)
459
        end  
460
    
461
        term.setCursorPos(36,6)
462
        term.write("Stone")
463
        term.setCursorPos(36,7)
464
        term.write("Pickaxe")
465
        term.setCursorPos(36,8)
466
        term.write("Price:" .. displayNumber(stonePickPrice))
467
        term.setCursorPos(36,9)
468
        term.write("Owned:" .. displayNumber(stonePicksOwned, true))
469
        term.setCursorPos(36,10)
470
        term.write("CPS:" .. (displayNumber(stonePickCPS * stonePickMultiplier)))
471
    
472
        -- Iron Pick
473
        if diamonds >= ironPickPrice then
474
            term.setBackgroundColor(colors.green)
475
            paintutils.drawFilledBox(19, 13, 31, 17, colors.green)
476
            if ((x>=19 and x<=31) and (y>=13 and y<=17)) then
477
                diamonds = diamonds - ironPickPrice
478
                ironPicksOwned = ironPicksOwned + 1
479
                ironPickPrice = calculateNewPrice(ironPickBasePrice, ironPicksOwned)
480
                ironPickCPS = ironPickCPS + ironPickStartingCPS
481
            end
482
        elseif diamonds < ironPickPrice then
483
            term.setBackgroundColor(colors.red)
484
            paintutils.drawFilledBox(19, 13, 31, 17, colors.red)
485
        end  
486
    
487
        term.setCursorPos(20,13)
488
        term.write("Iron")
489
        term.setCursorPos(20,14)
490
        term.write("Pickaxe")
491
        term.setCursorPos(20,15)
492
        term.write("Price:" .. displayNumber(ironPickPrice))
493
        term.setCursorPos(20,16)
494
        term.write("Owned:" .. displayNumber(ironPicksOwned, true))
495
        term.setCursorPos(20,17)
496
        term.write("CPS:" .. (displayNumber(ironPickCPS * ironPickMultiplier)))
497
                      
498
        -- Diamond Pick
499
        if diamonds >= diamondPickPrice then
500
            term.setBackgroundColor(colors.green)
501
            paintutils.drawFilledBox(35, 13, 47, 17, colors.green)
502
            if ((x>=35 and x<=47) and (y>=13 and y<=17)) then
503
                diamonds = diamonds - diamondPickPrice
504
                diamondPicksOwned = diamondPicksOwned + 1
505
                diamondPickPrice = calculateNewPrice(diamondPickBasePrice, diamondPicksOwned)
506
                diamondPickCPS = diamondPickCPS + diamondPickStartingCPS
507
            end
508
        elseif diamonds < diamondPickPrice then
509
            term.setBackgroundColor(colors.red)
510
            paintutils.drawFilledBox(35, 13, 47, 17, colors.red)
511
        end  
512
    
513
        term.setCursorPos(36,13)
514
        term.write("Diamond")
515
        term.setCursorPos(36,14)
516
        term.write("Pickaxe")
517
        term.setCursorPos(36,15)
518
        term.write("Price:" .. displayNumber(diamondPickPrice))
519
        term.setCursorPos(36,16)
520
        term.write("Owned:" .. displayNumber(diamondPicksOwned, true))
521
        term.setCursorPos(36,17)
522
        term.write("CPS:" .. (displayNumber(diamondPickCPS * diamondPickMultiplier)))
523
end
524
525
-- This function is used to draw the store on the screen
526
function drawStore(x,y)
527
    
528
    local x = x or 0
529
    local y = y or 0
530
    
531
    -- Draw Store Outline
532
    
533
    paintutils.drawFilledBox(18, 5, 48, 18, colors.orange)
534
    paintutils.drawFilledBox(32, 6, 34, 17, colors.orange)
535
    paintutils.drawFilledBox(19, 11, 47, 12, colors.orange)
536
    
537
        -- Wooden Pick
538
        if diamonds >= woodPickUpgradePrice and woodPicksOwned >= 1 then
539
            term.setBackgroundColor(colors.green)
540
            paintutils.drawFilledBox(19, 6, 31, 10, colors.green)
541
            if ((x>=19 and x<=31) and (y>=6 and y<=10)) then
542
                diamonds = diamonds - woodPickUpgradePrice
543
                woodPickUpgradesOwned = woodPickUpgradesOwned + 1
544
                woodPickUpgradePrice = math.floor((woodPickUpgradePrice * 4) + 0.25)
545
            	if woodPickMultiplier == 1 then
546
                	woodPickMultiplier = woodPickMultiplier +1
547
				else
548
            		woodPickMultiplier = woodPickMultiplier * 2
549
                end
550
            end
551
        elseif diamonds < woodPickUpgradePrice or woodPicksOwned < 1 then
552
            term.setBackgroundColor(colors.red)
553
            paintutils.drawFilledBox(19, 6, 31, 10, colors.red)
554
        end  
555
    
556
        term.setCursorPos(20,6)
557
        term.write("Wooden")
558
        term.setCursorPos(20,7)
559
        term.write("Multiplier")
560
        term.setCursorPos(20,8)
561
        term.write("Price:" .. displayNumber(woodPickUpgradePrice))
562
        term.setCursorPos(20,9)
563
        term.write("Owned:" .. displayNumber(woodPickUpgradesOwned, true))
564
        term.setCursorPos(20,10)
565
        term.write("Multi:" .. (displayNumber(woodPickMultiplier, true)))
566
    
567
        -- Stone Pick
568
        if diamonds >= stonePickUpgradePrice and stonePicksOwned >= 1 then
569
            term.setBackgroundColor(colors.green)
570
            paintutils.drawFilledBox(35, 6, 47, 10, colors.green)
571
            if ((x>=35 and x<=47) and (y>=6 and y<=10)) then
572
                diamonds = diamonds - stonePickUpgradePrice
573
                stonePickUpgradesOwned = stonePickUpgradesOwned + 1
574
                stonePickUpgradePrice = math.floor((stonePickUpgradePrice * 4) + 0.25)
575
            	if stonePickMultiplier == 1 then
576
                	stonePickMultiplier = stonePickMultiplier +1
577
				else
578
            		stonePickMultiplier = stonePickMultiplier * 2
579
                end            
580
        	end
581
        elseif diamonds < stonePickUpgradePrice or stonePicksOwned < 1 then
582
            term.setBackgroundColor(colors.red)
583
            paintutils.drawFilledBox(35, 6, 47, 10, colors.red)
584
        end  
585
    
586
        term.setCursorPos(36,6)
587
        term.write("Stone")
588
        term.setCursorPos(36,7)
589
        term.write("Multiplier")
590
        term.setCursorPos(36,8)
591
        term.write("Price:" .. displayNumber(stonePickUpgradePrice))
592
        term.setCursorPos(36,9)
593
        term.write("Owned:" .. displayNumber(stonePickUpgradesOwned, true))
594
        term.setCursorPos(36,10)
595
        term.write("Multi:" .. (displayNumber(stonePickMultiplier, true)))
596
    
597
        -- Iron Pick
598
        if diamonds >= ironPickUpgradePrice and ironPicksOwned >= 1 then
599
            term.setBackgroundColor(colors.green)
600
            paintutils.drawFilledBox(19, 13, 31, 17, colors.green)
601
            if ((x>=19 and x<=31) and (y>=13 and y<=17)) then
602
                diamonds = diamonds - ironPickUpgradePrice
603
                ironPickUpgradesOwned = ironPickUpgradesOwned + 1
604
                ironPickUpgradePrice = math.floor((ironPickUpgradePrice * 4) + 0.25)
605
            	if ironPickMultiplier == 1 then
606
                	ironPickMultiplier = ironPickMultiplier +1
607
				else
608
            		ironPickMultiplier = ironPickMultiplier * 2
609
                end            
610
        	end
611
        elseif diamonds < ironPickUpgradePrice or ironPicksOwned < 1 then
612
            term.setBackgroundColor(colors.red)
613
            paintutils.drawFilledBox(19, 13, 31, 17, colors.red)
614
        end  
615
    
616
        term.setCursorPos(20,13)
617
        term.write("Iron")
618
        term.setCursorPos(20,14)
619
        term.write("Multiplier")
620
        term.setCursorPos(20,15)
621
        term.write("Price:" .. displayNumber(ironPickUpgradePrice))
622
        term.setCursorPos(20,16)
623
        term.write("Owned:" .. displayNumber(ironPickUpgradesOwned, true))
624
        term.setCursorPos(20,17)
625
        term.write("Multi:" .. (displayNumber(ironPickMultiplier, true)))
626
                      
627
        -- Diamond Pick
628
        if diamonds >= diamondPickUpgradePrice and diamondPicksOwned >= 1 then
629
            term.setBackgroundColor(colors.green)
630
            paintutils.drawFilledBox(35, 13, 47, 17, colors.green)
631
            if ((x>=35 and x<=47) and (y>=13 and y<=17)) then
632
                diamonds = diamonds - diamondPickUpgradePrice
633
                diamondPickUpgradesOwned = diamondPickUpgradesOwned + 1
634
                diamondPickUpgradePrice = math.floor((diamondPickUpgradePrice * 4) + 0.25)
635
            	if diamondPickMultiplier == 1 then
636
                	diamondPickMultiplier = diamondPickMultiplier +1
637
				else
638
            		diamondPickMultiplier = diamondPickMultiplier * 2
639
                end            
640
        	end
641
        elseif diamonds < diamondPickUpgradePrice or diamondPicksOwned < 1 then
642
            term.setBackgroundColor(colors.red)
643
            paintutils.drawFilledBox(35, 13, 47, 17, colors.red)
644
        end  
645
    
646
        term.setCursorPos(36,13)
647
        term.write("Diamond")
648
        term.setCursorPos(36,14)
649
        term.write("Multiplier")
650
        term.setCursorPos(36,15)
651
        term.write("Price:" .. displayNumber(diamondPickUpgradePrice))
652
        term.setCursorPos(36,16)
653
        term.write("Owned:" .. displayNumber(diamondPickUpgradesOwned, true))
654
        term.setCursorPos(36,17)
655
        term.write("Multi:" .. (displayNumber(diamondPickMultiplier, true)))
656
end
657
658
-- This is what allows the program to wait for inputs as well as keep the score going at the same time
659
parallel.waitForAny(setDiamonds, handleTouchInputs)