-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
5304 lines (4422 loc) · 185 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--Copyright 2017 Ibispi
--the main file
function love.load()
pPPointsShown = false
productivityPts = { }
--for each registered year you need a function that adds this year to the register
local currentHour = tonumber(os.date("%H"))
local currentMin = tonumber(os.date("%M"))
local currentDay = tonumber(os.date("%d"))
local currentMonth = tonumber(os.date("%m"))
local currentYear = tonumber(os.date("%Y"))
function getHighestNumberOfXMonths (xMonths, xYear, previousHighestNumber)
local highestNumber = 0
if previousHighestNumber ~= nil then
highestNumber = previousHighestNumber
end
local previousYearCount = 0
local currentMonth = tonumber(os.date("%m"))
local currentYear = tonumber(os.date("%Y"))
if xYear ~= nil then
currentMonth = 12
currentYear = xYear
end
if productivityPts[currentYear] ~= nil then
if productivityPts[currentYear][currentMonth] ~= nil then
for someMonth = currentMonth-xMonths, currentMonth, 1 do
if productivityPts[currentYear][someMonth] ~= nil then
for someDay = 1, #productivityPts[currentYear][someMonth], 1 do
if productivityPts[currentYear][someMonth][someDay] > highestNumber then
highestNumber = productivityPts[currentYear][someMonth][someDay]
end
end
else
previousYearCount = previousYearCount + 1
end
end
if previousYearCount ~= 0 then
if productivityPts[currentYear-1] ~= nil then
getHighestNumberOfXMonths (previousYearCount, currentYear-1, highestNumber)
end
end
end
end
return highestNumber
end
function getGraphData ()
if productivityPts ~= nil then
local graphData = {}
-- 1. max ever, 2. last five years, 3. last year, 4. last 6 months, 5. last month, 6. last 7 days and today (5+8=13) graphsToBeDrawn
local currentYear = tonumber(os.date("%Y"))
local currentMonth = tonumber(os.date("%m"))
local currentDay = tonumber(os.date("%d"))
for _ = 1, 13, 1 do
graphData[_] = 0
end
graphData[1] = getHighestNumberOfXMonths(2000)
graphData[2] = getHighestNumberOfXMonths(60)
graphData[3] = getHighestNumberOfXMonths(12)
if productivityPts[currentYear] ~= nil then
if productivityPts[currentYear][currentMonth] ~= nil then
local highestNumber = 0
local previousYearCount = 0
for someMonth = currentMonth-5, currentMonth, 1 do
if productivityPts[currentYear][someMonth] ~= nil then
for someDay = 1, #productivityPts[currentYear][someMonth], 1 do
if productivityPts[currentYear][someMonth][someDay] > highestNumber then
highestNumber = productivityPts[currentYear][someMonth][someDay]
end
end
else
previousYearCount = previousYearCount + 1
end
end
if previousYearCount ~= 0 then
if productivityPts[currentYear-1] ~= nil then
for someMonth = 12-previousYearCount, 12, 1 do
if productivityPts[currentYear-1][someMonth] ~= nil then
for someDay = 1, #productivityPts[currentYear-1][someMonth], 1 do
if productivityPts[currentYear-1][someMonth][someDay] > highestNumber then
highestNumber = productivityPts[currentYear-1][someMonth][someDay]
end
end
end
end
end
end
graphData[4] = highestNumber
local highestNumber = 0
for _ = 1, #productivityPts[currentYear][currentMonth], 1 do
if productivityPts[currentYear][currentMonth][_] > highestNumber then
highestNumber = productivityPts[currentYear][currentMonth][_]
end
end
graphData[5] = highestNumber
local extraDays = 0
for _ = 6, 13, 1 do
local theExactNum = currentDay-(13-_)
if productivityPts[currentYear][currentMonth][theExactNum] ~= nil then
graphData[_] = productivityPts[currentYear][currentMonth][theExactNum]
else
extraDays = extraDays + 1
end
end
if extraDays ~= 0 then
extraDays = extraDays-1
local extraDayNum = 6
if productivityPts[currentYear][currentMonth-1] ~= nil then
for thisDay = #productivityPts[currentYear][currentMonth-1]-extraDays, #productivityPts[currentYear][currentMonth-1], 1 do
graphData[extraDayNum] = productivityPts[currentYear][currentMonth-1][thisDay]
extraDayNum = extraDayNum + 1
end
elseif productivityPts[currentYear-1][12] ~= nil then
for thisDay = #productivityPts[currentYear-1][12]-extraDays, #productivityPts[currentYear-1][12], 1 do
graphData[extraDayNum] = productivityPts[currentYear][currentMonth-1][thisDay]
extraDayNum = extraDayNum + 1
end
else
extraDayNum = extraDayNum + 1
end
end
end
end
return graphData
end
end
function checkPPYear () --checks if the current year is not in PP and if so adds it...
if love.filesystem.exists("productivityPts.txt") then
productivityPts = serializer.load("productivityPts.txt")
end
if productivityPts == nil then productivityPts = {} end
local currentYear = tonumber(os.date("%Y"))
if productivityPts[currentYear] == nil then
local febLength = howLongIsFebruary (currentYear)
local currentYearTable = {}
local yearMonthLength = { 31, febLength, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
for someMonth = 1, #yearMonthLength, 1 do
currentYearTable[someMonth] = {}
for someDay = 1, yearMonthLength[someMonth], 1 do
table.insert (currentYearTable[someMonth], 0)
end
end
table.insert(productivityPts, currentYear, currentYearTable)
if productivityPts ~= nil then
productivityPts._fileName = "productivityPts.txt"
serializer.save(productivityPts)
--local serializedTable = serializer.encode(productivityPts)
--love.filesystem.write("productivityPts.lua", serializedTable)
end
end
end
xCursor = 0
yCursor = 0
reenablePossible = 0 --for the reenable button to be shown
addClickingBoxes = true
clickingBox = {
}
--[[
local aNewClickingBox = {
x1 = xDistance,
x2 = whichIsBigger,--this will be just the additions to the 1s
y1 = whereToY,
y2 = boxHeight,--this will be just the additions to the 1s
keyboardTarget = "name",
keyboardClipboard = theGoal.name,
keyboardTable = theGoal,
somethingElse = "",
where = "theGoalEditing"
}
table.insert(clickingBox,aNewClickingBox)
]]
printMeThis = ""
-- things to do:
--[[
2.draw a smartdoge icon for the program and make the github page with the doge painting
3.undo/redo with extra save slots
4.copy/paste with addingDumbgoal/addingSmartgoal
6. figure out how to transfer the save file from computer to phone and vice versa
]]
function load()
if love.filesystem.exists("smartDogeSaveFile") then
local savingNewline = "~~n~"
local levelTwoGoalLine = "~~2~"
local levelThreeGoalLine = "~~3~"
local savingSpace = "~~s~"
local contents, size = love.filesystem.read("smartDogeSaveFile")
for theGoalGroup in string.gmatch(contents, "~~goals~(.-)~~ticketInventory~") do
--everything goal related
for goals in string.gmatch(theGoalGroup, "(.-)"..savingNewline) do
--each goal of the level
local whichGoal = 1
local elementNum = 0
local tableType = "broad"
for insideGoals in string.gmatch(goals, "(.-)"..savingSpace) do
--inside goals are parts of each individual goal
elementNum=elementNum+1
if elementNum == 1 then--type
if insideGoals == "broad" then
tableType = "broad"
--do inner loops.. or not???
elseif insideGoals == "specific" then
tableType = "specific"
end
elseif elementNum == 2 then
if insideGoals == "~~1~" then
addGoal(tableType, goal)
whichGoal = goal[#goal]
elseif insideGoals == "~~2~" then
addGoal(tableType, goal[#goal].goal)
whichGoal = goal[#goal].goal[#goal[#goal].goal]
elseif insideGoals == "~~3~" then
addGoal(tableType, goal[#goal].goal[#goal[#goal].goal].goal)
whichGoal = goal[#goal].goal[#goal[#goal].goal].goal[#goal[#goal].goal[#goal[#goal].goal].goal]
end
elseif elementNum == 3 then --name
whichGoal.name = insideGoals
elseif elementNum == 4 then --description
whichGoal.description = insideGoals
elseif elementNum == 5 then --ticketAmount
insideGoals = tonumber(insideGoals)
whichGoal.ticketAmount = insideGoals
elseif elementNum == 6 then --measurement.amountTotal --mandatoryBy.year
if tableType == "specific" then
insideGoals = tonumber(insideGoals)
whichGoal.measurement.amountTotal = insideGoals
elseif tableType == "broad" then
insideGoals = tonumber(insideGoals)
whichGoal.mandatoryBy.year = insideGoals
end
elseif elementNum == 7 then --measurement.aproxAmountPerSession --mandatoryBy.month
if tableType == "specific" then
insideGoals = tonumber(insideGoals)
whichGoal.measurement.aproxAmountPerSession = insideGoals
elseif tableType == "broad" then
insideGoals = tonumber(insideGoals)
whichGoal.mandatoryBy.month = insideGoals
end
elseif elementNum == 8 then --measurement.doneSoFar --mandatoryBy.day
if tableType == "specific" then
insideGoals = tonumber(insideGoals)
whichGoal.measurement.doneSoFar = insideGoals
elseif tableType == "broad" then
insideGoals = tonumber(insideGoals)
whichGoal.mandatoryBy.day = insideGoals
end
elseif elementNum == 9 then --measurement.measurement --mandatoryBy.hour
if tableType == "specific" then
whichGoal.measurement.measurement = insideGoals
elseif tableType == "broad" then
insideGoals = tonumber(insideGoals)
whichGoal.mandatoryBy.hour = insideGoals
end
elseif elementNum == 10 then --aproxTime.amount --mandatoryBy.min
if tableType == "specific" then
insideGoals = tonumber(insideGoals)
whichGoal.aproxTime.amount = insideGoals
elseif tableType == "broad" then
insideGoals = tonumber(insideGoals)
whichGoal.mandatoryBy.min = insideGoals
end
elseif elementNum == 11 then --aproxTime.measurement --partlyCompleted
if tableType == "specific" then
whichGoal.aproxTime.measurement = insideGoals
elseif tableType == "broad" then
theBool = false
if insideGoals == "true" then theBool = true end
whichGoal.partlyCompleted = theBool
end
elseif elementNum == 12 then --mandatoryBy.year --fullyCompleted
if tableType == "specific" then
insideGoals = tonumber(insideGoals)
whichGoal.mandatoryBy.year = insideGoals
elseif tableType == "broad" then
theBool = false
if insideGoals == "true" then theBool = true end
whichGoal.fullyCompleted = theBool
end
elseif elementNum == 13 then --mandatoryBy.month
insideGoals = tonumber(insideGoals)
whichGoal.mandatoryBy.month = insideGoals
elseif elementNum == 14 then --mandatoryBy.day
insideGoals = tonumber(insideGoals)
whichGoal.mandatoryBy.day = insideGoals
elseif elementNum == 15 then --mandatoryBy.hour
insideGoals = tonumber(insideGoals)
whichGoal.mandatoryBy.hour = insideGoals
elseif elementNum == 16 then --mandatoryBy.min
insideGoals = tonumber(insideGoals)
whichGoal.mandatoryBy.min = insideGoals
elseif elementNum == 17 then --partlyCompleted
theBool = false
if insideGoals == "true" then theBool = true end
whichGoal.partlyCompleted = theBool
elseif elementNum == 18 then --fullyCompleted
theBool = false
if insideGoals == "true" then theBool = true end
whichGoal.fullyCompleted = theBool
end
end
end
end
for ticketGroup in string.gmatch(contents, "~~ticketInventory~(.-)~~ticketVault~") do
--everything goal related
for ticketGroups in string.gmatch(ticketGroup, "(.-)"..savingNewline) do
--each goal of the level
local elementNum = 0
if #ticketInventory == 0 then
ticketInventory[1] = { name = "", allows = {amount = 1, measurement = "bla"},
amount = 1}
else
ticketInventory[#ticketInventory+1] = { name = "", allows = {amount = 1, measurement = "bla"},
amount = 1}
end
for insideTickets in string.gmatch(ticketGroups, "(.-)"..savingSpace) do
elementNum = elementNum + 1
if elementNum == 1 then
ticketInventory[#ticketInventory].name = insideTickets
elseif elementNum == 2 then
insideTickets = tonumber(insideTickets)
ticketInventory[#ticketInventory].allows.amount = insideTickets
elseif elementNum == 3 then
ticketInventory[#ticketInventory].allows.measurement = insideTickets
elseif elementNum == 4 then
insideTickets = tonumber(insideTickets)
ticketInventory[#ticketInventory].amount = insideTickets
end
end
end
end
for ticketGroup in string.gmatch(contents, "~~ticketVault~(.-)~~end~") do --IF YOU WANT TO ADD MORE TO
--THE SAVING YOU HAVE TO ADD THE NEW CATEGORY HERE BY COMBINING IT WITH THIS
-- STRING LIKE THIS "~~ticketVault~(.-)~~newCategoryName~"
--everything goal related
for ticketGroups in string.gmatch(ticketGroup, "(.-)"..savingNewline) do
--each goal of the level
local elementNum = 0
addTicketToVault()
for insideTickets in string.gmatch(ticketGroups, "(.-)"..savingSpace) do
elementNum = elementNum + 1
if elementNum == 1 then
ticketVault[#ticketVault].name = insideTickets
elseif elementNum == 2 then
insideTickets = tonumber(insideTickets)
ticketVault[#ticketVault].allows.amount = insideTickets
elseif elementNum == 3 then
ticketVault[#ticketVault].allows.measurement = insideTickets
elseif elementNum == 4 then
insideTickets = tonumber(insideTickets)
ticketVault[#ticketVault].rarityHandicap = insideTickets
end
end
end
end
else
local clickHereTask = {
goal = {--[[loops]]},
type = "broad",
name = "click here!",
description = "Welcome to smartDogeUtility! These goals are just merely examples of how smartDogeUtility can be used, you can set whatever goals you want for yourself. Just remember not to do unproductive things that make you feel good unless you have the appropriate ticket! (You can add tickets to the ticket pool by clicking on Tickets > Ticket Pool) The example goals should be deleted by clicking the delete button.",
ticketAmount = 0,
tracking = { percentage = 0.0, sessionsTillFinished=0, measurementTimeTillFinished = "s."--[[calculated based on measurement and aproxTime OF ITS INNER GOALS!!!]]},
mandatoryBy = {year = 9999, month = 6, day = 23, hour = 15, min = 30, roughlyIn = {amount = 0, measurement = "days"}, },--[[this sets mandatory by to all the inside goals and is set to be earlier if one of the inside goals is earlier]]
partlyCompleted = false--[[this is for when a task is completed for a day for example and then you reenable it the next day]],
fullyCompleted = false, --[[when 100% of the task is completed, it can still be reenabled if need be]]}
local healthTask = { goal = {--[[loops]]
{type = "specific",
name = "exercises",
ticketAmount = 1,
description = "After 10 sessions of this and all the sessions of the jogging goal you would get awarded with 5 tickets from the health dumb goal!",
tracking = { percentage = 0.0, sessionsTillFinished=0, measurementTimeTillFinished = "s."--[[number of sessions]]},
measurement = {amountTotal=10, aproxAmountPerSession = 1, sessionPercentage = 0.0, doneSoFar = 0, measurement = "exercise" --[[calculates percentage and how much more is needed]]},
aproxTime = { amount = 40, measurement = "min"},
mandatoryBy = {year = 9999, month = 6, day = 23, hour = 15, min = 30, roughlyIn = {amount = 0, measurement = "days"},},
partlyCompleted = false--[[this is for when a task is completed for a day for example and then you reenable it the next day]],
fullyCompleted = false, --[[when 100% of the task is completed, it can still be reenabled if need be]]},
{type = "specific",
name = "jogging",
ticketAmount = 1,
description = "After 10 sessions of this and all the sessions of the jogging goal you would get awarded with 5 tickets from the health dumb goal!",
tracking = { percentage = 0.0, sessionsTillFinished=0, measurementTimeTillFinished = "s."--[[number of sessions]]},
measurement = {amountTotal=10, aproxAmountPerSession = 2, sessionPercentage = 0.0, doneSoFar = 0, measurement = "miles" --[[calculates percentage and how much more is needed]]},
aproxTime = { amount = 30, measurement = "min"},
mandatoryBy = {year = 9999, month = 6, day = 23, hour = 15, min = 30, roughlyIn = {amount = 0, measurement = "days"},},
partlyCompleted = false--[[this is for when a task is completed for a day for example and then you reenable it the next day]],
fullyCompleted = false, --[[when 100% of the task is completed, it can still be reenabled if need be]]}
--[[loopsendshere]]},
type = "broad",
name = "health",
description = "These are various tasks to improve your health and well-being. By completing the requirements of all the tasks you get rewarded by 5 extra tickets from this dumb goal! And then you cn just re-enable the tasks and keep on with improving your health!",
ticketAmount = 5,
tracking = { percentage = 0.0, sessionsTillFinished=0, measurementTimeTillFinished = "s."--[[calculated based on measurement and aproxTime OF ITS INNER GOALS!!!]]},
mandatoryBy = {year = 9999, month = 6, day = 23, hour = 15, min = 30, roughlyIn = {amount = 0, measurement = "days"}, },--[[this sets mandatory by to all the inside goals and is set to be earlier if one of the inside goals is earlier]]
partlyCompleted = false--[[this is for when a task is completed for a day for example and then you reenable it the next day]],
fullyCompleted = false, --[[when 100% of the task is completed, it can still be reenabled if need be]]}
local everydayTask =
{type = "specific",
name = "everyday task",
ticketAmount = 1,
description = "It's useful to have an undefined goal you can just use to reward yourself with tickets. Some tasks can appear out of nowhere and you may not have enough time to plan them out but are still worthy a ticket.",
tracking = { percentage = 0.0, sessionsTillFinished=0, measurementTimeTillFinished = "s."--[[number of sessions]]},
measurement = {amountTotal=999998, aproxAmountPerSession = 0, sessionPercentage = 0.0, doneSoFar = 0, measurement = "..." --[[calculates percentage and how much more is needed]]},
aproxTime = { amount = 1, measurement = "hours"},
mandatoryBy = {year = 9999, month = 6, day = 23, hour = 15, min = 30, roughlyIn = {amount = 0, measurement = "days"},},
partlyCompleted = false--[[this is for when a task is completed for a day for example and then you reenable it the next day]],
fullyCompleted = false, --[[when 100% of the task is completed, it can still be reenabled if need be]]}
local writeANovelGoal = { goal = {--[[loops]]
{goal = {--[[loops]]
{type = "specific",
name = "fiction-books",
ticketAmount = 7,
description = "For example, you could be measuring the progress of the research on the other fictional works on this topic or of this setting based on the number of books/sources read.",
tracking = { percentage = 0.0, sessionsTillFinished=0, measurementTimeTillFinished = "s."--[[number of sessions]]},
measurement = {amountTotal=10, aproxAmountPerSession = 1, sessionPercentage = 0.0, doneSoFar = 0, measurement = "sources" --[[calculates percentage and how much more is needed]]},
aproxTime = { amount = 7, measurement = "days"},
mandatoryBy = {year = 9999, month = 6, day = 23, hour = 15, min = 30, roughlyIn = {amount = 0, measurement = "days"},},
partlyCompleted = false--[[this is for when a task is completed for a day for example and then you reenable it the next day]],
fullyCompleted = false, --[[when 100% of the task is completed, it can still be reenabled if need be]]},
{type = "specific",
name = "nonfiction-p.",
ticketAmount = 1,
description = "And that you are measuring your progress on non-fiction research by the amount of pages read.",
tracking = { percentage = 0.0, sessionsTillFinished=0, measurementTimeTillFinished = "s."--[[number of sessions]]},
measurement = {amountTotal=1000, aproxAmountPerSession = 20, sessionPercentage = 0.0, doneSoFar = 0, measurement = "pages" --[[calculates percentage and how much more is needed]]},
aproxTime = { amount = 1, measurement = "hours"},
mandatoryBy = {year = 9999, month = 6, day = 23, hour = 15, min = 30, roughlyIn = {amount = 0, measurement = "days"},},
partlyCompleted = false--[[this is for when a task is completed for a day for example and then you reenable it the next day]],
fullyCompleted = false, --[[when 100% of the task is completed, it can still be reenabled if need be]]},
},
type = "broad",
name = "do research",
description = "Let's say you are writing a historical novel, one of the parts of this process will be to conduct research on the topic or the setting you are writing about.",
ticketAmount = 1,
tracking = { percentage = 0.0, sessionsTillFinished=0, measurementTimeTillFinished = "s."},
mandatoryBy = {year = 9999, month = 6, day = 23, hour = 15, min = 30, roughlyIn = {amount = 0, measurement = "days"}, },
partlyCompleted = false,
fullyCompleted = false, },
{type = "specific",
name = "words written",
ticketAmount = 1,
description = "This is where you'd track your total word count for the novel. How much you've written as of yet.",
tracking = { percentage = 0.0, sessionsTillFinished=0, measurementTimeTillFinished = "s."--[[number of sessions]]},
measurement = {amountTotal=100000, aproxAmountPerSession = 1000, sessionPercentage = 0.0, doneSoFar = 0, measurement = "words" --[[calculates percentage and how much more is needed]]},
aproxTime = { amount = 20, measurement = "min"},
mandatoryBy = {year = 9999, month = 6, day = 23, hour = 15, min = 30, roughlyIn = {amount = 0, measurement = "days"},},
partlyCompleted = false--[[this is for when a task is completed for a day for example and then you reenable it the next day]],
fullyCompleted = false, --[[when 100% of the task is completed, it can still be reenabled if need be]]},
--[[loopsendshere]]
},
type = "broad",
name = "write a novel",
description = "You can write down notes regarding a goal here (press Edit > Tap to edit the description)!",
ticketAmount = 9,
tracking = { percentage = 0.0, sessionsTillFinished=0, measurementTimeTillFinished = "s."},
mandatoryBy = {year = 9999, month = 6, day = 23, hour = 15, min = 30, roughlyIn = {amount = 0, measurement = "days"}, },
partlyCompleted = false,
fullyCompleted = false, }
table.insert(goal, writeANovelGoal)
table.insert(goal, healthTask)
table.insert(goal, everydayTask)
table.insert(goal, clickHereTask)
local defaultReward = {
--expiresAfter = {year = 0, month = 0, day = 7, hour = 0, min = 0},
name = "doing something pleasurable",
allows = {amount = 1, measurement = "hour"},
rarityHandicap = 100, --[[decreases the likelyhood of this being picked as compared to other tickets]]
}
table.insert (ticketVault, defaultReward)
local defaultReward = {
--expiresAfter = {year = 0, month = 0, day = 7, hour = 0, min = 0},
name = "no reward, sometimes you don't need one!",
allows = {amount = 0, measurement = ""},
rarityHandicap = 50, --[[decreases the likelyhood of this being picked as compared to other tickets]]
}
table.insert (ticketVault, defaultReward)
end
end
function save ()
if productivityPts ~= nil then
productivityPts._fileName = "productivityPts.txt"
serializer.save(productivityPts)
--love.filesystem.write("productivityPts.lua", serializedTable)
end
local dataToBeSaved = ""
-- ~ is used at the beginning of every important line because the player can't type ~
local savingNewline = "~~n~"
local levelOneGoalLine = "~~1~"
local levelTwoGoalLine = "~~2~"
local levelThreeGoalLine = "~~3~"
local savingSpace = "~~s~"
local dataToBeSaved = dataToBeSaved.."~~goals~"
for goalNumOne = 1, #goal, 1 do
-- ~~n~ is a new line
-- ~~2~ is a level 2 goal
-- ~~3~ is a level 3 goal
if goal[goalNumOne].type == "specific" then
local partlyCompleted = "false"
local fullyCompleted = "false"
if goal[goalNumOne].partlyCompleted == true then
partlyCompleted = "true"
end
if goal[goalNumOne].fullyCompleted == true then
fullyCompleted = "true"
end
dataToBeSaved = dataToBeSaved..
goal[goalNumOne].type..savingSpace..
levelOneGoalLine..savingSpace..
goal[goalNumOne].name..savingSpace..
goal[goalNumOne].description..savingSpace..
goal[goalNumOne].ticketAmount..savingSpace..
goal[goalNumOne].measurement.amountTotal..savingSpace..
goal[goalNumOne].measurement.aproxAmountPerSession..savingSpace..
goal[goalNumOne].measurement.doneSoFar..savingSpace..
goal[goalNumOne].measurement.measurement..savingSpace..
goal[goalNumOne].aproxTime.amount..savingSpace..
goal[goalNumOne].aproxTime.measurement..savingSpace..
goal[goalNumOne].mandatoryBy.year..savingSpace..
goal[goalNumOne].mandatoryBy.month..savingSpace..
goal[goalNumOne].mandatoryBy.day..savingSpace..
goal[goalNumOne].mandatoryBy.hour..savingSpace..
goal[goalNumOne].mandatoryBy.min..savingSpace..
partlyCompleted..savingSpace..fullyCompleted..savingSpace..savingNewline
elseif goal[goalNumOne].type == "broad" then
local partlyCompleted = "false"
local fullyCompleted = "false"
if goal[goalNumOne].partlyCompleted == true then
partlyCompleted = "true"
end
if goal[goalNumOne].fullyCompleted == true then
fullyCompleted = "true"
end
dataToBeSaved = dataToBeSaved..
goal[goalNumOne].type..savingSpace..
levelOneGoalLine..savingSpace..
goal[goalNumOne].name..savingSpace..
goal[goalNumOne].description..savingSpace..
goal[goalNumOne].ticketAmount..savingSpace..
goal[goalNumOne].mandatoryBy.year..savingSpace..
goal[goalNumOne].mandatoryBy.month..savingSpace..
goal[goalNumOne].mandatoryBy.day..savingSpace..
goal[goalNumOne].mandatoryBy.hour..savingSpace..
goal[goalNumOne].mandatoryBy.min..savingSpace..
partlyCompleted..savingSpace..fullyCompleted..savingSpace..savingNewline
if goal[goalNumOne].goal[1] ~= nil then
for goalNumTwo = 1, #goal[goalNumOne].goal, 1 do
if goal[goalNumOne].goal[goalNumTwo].type == "specific" then
local partlyCompleted = "false"
local fullyCompleted = "false"
if goal[goalNumOne].goal[goalNumTwo].partlyCompleted == true then
partlyCompleted = "true"
end
if goal[goalNumOne].goal[goalNumTwo].fullyCompleted == true then
fullyCompleted = "true"
end
dataToBeSaved = dataToBeSaved..
goal[goalNumOne].goal[goalNumTwo].type..savingSpace..
levelTwoGoalLine..savingSpace..
goal[goalNumOne].goal[goalNumTwo].name..savingSpace..
goal[goalNumOne].goal[goalNumTwo].description..savingSpace..
goal[goalNumOne].goal[goalNumTwo].ticketAmount..savingSpace..
goal[goalNumOne].goal[goalNumTwo].measurement.amountTotal..savingSpace..
goal[goalNumOne].goal[goalNumTwo].measurement.aproxAmountPerSession..savingSpace..
goal[goalNumOne].goal[goalNumTwo].measurement.doneSoFar..savingSpace..
goal[goalNumOne].goal[goalNumTwo].measurement.measurement..savingSpace..
goal[goalNumOne].goal[goalNumTwo].aproxTime.amount..savingSpace..
goal[goalNumOne].goal[goalNumTwo].aproxTime.measurement..savingSpace..
goal[goalNumOne].goal[goalNumTwo].mandatoryBy.year..savingSpace..
goal[goalNumOne].goal[goalNumTwo].mandatoryBy.month..savingSpace..
goal[goalNumOne].goal[goalNumTwo].mandatoryBy.day..savingSpace..
goal[goalNumOne].goal[goalNumTwo].mandatoryBy.hour..savingSpace..
goal[goalNumOne].goal[goalNumTwo].mandatoryBy.min..savingSpace..
partlyCompleted..savingSpace..fullyCompleted..savingSpace..savingNewline
elseif goal[goalNumOne].goal[goalNumTwo].type == "broad" then
local partlyCompleted = "false"
local fullyCompleted = "false"
if goal[goalNumOne].goal[goalNumTwo].partlyCompleted == true then
partlyCompleted = "true"
end
if goal[goalNumOne].goal[goalNumTwo].fullyCompleted == true then
fullyCompleted = "true"
end
dataToBeSaved = dataToBeSaved..
goal[goalNumOne].goal[goalNumTwo].type..savingSpace..
levelTwoGoalLine..savingSpace..
goal[goalNumOne].goal[goalNumTwo].name..savingSpace..
goal[goalNumOne].goal[goalNumTwo].description..savingSpace..
goal[goalNumOne].goal[goalNumTwo].ticketAmount..savingSpace..
goal[goalNumOne].goal[goalNumTwo].mandatoryBy.year..savingSpace..
goal[goalNumOne].goal[goalNumTwo].mandatoryBy.month..savingSpace..
goal[goalNumOne].goal[goalNumTwo].mandatoryBy.day..savingSpace..
goal[goalNumOne].goal[goalNumTwo].mandatoryBy.hour..savingSpace..
goal[goalNumOne].goal[goalNumTwo].mandatoryBy.min..savingSpace..
partlyCompleted..savingSpace..fullyCompleted..savingSpace..savingNewline
if goal[goalNumOne].goal[goalNumTwo].goal[1] ~= nil then
for goalNumThree = 1, #goal[goalNumOne].goal[goalNumTwo].goal, 1 do
local partlyCompleted = "false"
local fullyCompleted = "false"
if goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].partlyCompleted == true then
partlyCompleted = "true"
end
if goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].fullyCompleted == true then
fullyCompleted = "true"
end
dataToBeSaved = dataToBeSaved..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].type..savingSpace..
levelThreeGoalLine..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].name..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].description..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].ticketAmount..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].measurement.amountTotal..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].measurement.aproxAmountPerSession..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].measurement.doneSoFar..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].measurement.measurement..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].aproxTime.amount..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].aproxTime.measurement..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].mandatoryBy.year..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].mandatoryBy.month..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].mandatoryBy.day..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].mandatoryBy.hour..savingSpace..
goal[goalNumOne].goal[goalNumTwo].goal[goalNumThree].mandatoryBy.min..savingSpace..
partlyCompleted..savingSpace..fullyCompleted..savingSpace..savingNewline
end
end
end
end
end
end
end
local dataToBeSaved = dataToBeSaved.."~~ticketInventory~"
for ticketNum = 1, #ticketInventory, 1 do
dataToBeSaved = dataToBeSaved..
ticketInventory[ticketNum].name..savingSpace..ticketInventory[ticketNum].allows.amount..
savingSpace..ticketInventory[ticketNum].allows.measurement..savingSpace..
ticketInventory[ticketNum].amount..savingSpace..savingNewline
end
local dataToBeSaved = dataToBeSaved.."~~ticketVault~"
for ticketNum = 1, #ticketVault, 1 do
dataToBeSaved = dataToBeSaved..
ticketVault[ticketNum].name..savingSpace..ticketVault[ticketNum].allows.amount..
savingSpace..ticketVault[ticketNum].allows.measurement..savingSpace..
ticketVault[ticketNum].rarityHandicap..savingSpace..savingNewline
end
dataToBeSaved = dataToBeSaved.."~~end~"
love.filesystem.write( "smartDogeSaveFile", dataToBeSaved )
end
addingDumbGoal = false--if true it allows you to pick a level for the goal
clickingBox = {}
addingSmartGoal = false
viewingGoals = false
viewingGoalPart = "Info"
--newline string is different per OS
currentOS = love.system.getOS()
newLineString = "\n"
--[[
if currentOS == "Windows" then
newLineString = "\r\n"
elseif currentOS == "OS X" then
newLineString = "\r"
elseif currentOS == "Linux" then
newLineString = "\r\n"
elseif currentOS == "Android" then
newLineString = "\n"
end
]]
remainingTickets = 0 --0 by default, in case there is more than 1 ticket to be rewarded
wonATicket = 0 --is 0 by default, if not 0 then a ticket has been chosen
completingAGoal = false --when the completion window comes up
completingAGoalWay = "add" -- the other alternative is total
notChosenTableForCompletion = false --;-;
maxViewingGoal = 0
viewingGoalSelected = 3 --became meaningless, should be removed probably
manuallyViewingGoalSelected = 0
firstBackspaceTimerDone = false
descriptionTooltip = ""
asIfReturnWasPressed = false -- used to simulate pressing enter on the keyboard
--just to go through the keyboard clipboard iteration
keyboardInput = false
keyboardClipboard = ""--string things are written onto before the input is approved
keyboardTarget = ""--[[this can be the 'name' of a goal for example]]
keyboardTable = goal -- the table containing the target
editingDescription = false
editingGoals = false
currentGoalPage = 1
totalAmountOfGoalPages = 1
selectedGoal = {1, 1, 1} --the goal is the number of the goal on each level
--there are 3 levels from left to right 1-3, if no goal is selected on a
--level this is marked by 0
editingTicket = false
ticketInventoryOpen = false
ticketVaultOpen = false
selectedTicket = 1
monthLength = {
leap = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
common = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
}
mandatoryByWhatToPrint = {
preWord = "!",
measurement = "days",
number = 0,
}
--table related
--------------------------------------------------------------------------------
goal = {
}
ticketInventory = {
} --punishments are generated for every punishment drawing
ticketVault = {
}
--tables should be drawn in the order of which goals have already been completed for the day and which are mandatory
--------------------------------------------------------------------------------
--load the modules here and setup the key-press booleans
local starterpack = require "0modules0.starterpack" starterpack()
--defaultSprite = love.graphics.newImage("sprites/defaultSprite.png")
local add_image = require "0modules0.add_image"
local copy = require "0modules0.copy"
directoryContent = {}
amountToFit = 1
directory = "sprites"
currentFolderPage = 1
undoTable = {}
redoTable = {}
buttonFunction = {
[1] = function () --undo
end,
[2] = function () --pPPoints (used to be redo)
if pPPointsShown == false then
graphsToBeDrawn = getGraphData ()
if graphsToBeDrawn ~= nil then
pPPointsShown = true
viewingGoals = false
editingGoals = false
addingDumbGoal = false
clickingBox = {}
addingSmartGoal = false
ticketVaultOpen = false
ticketInventoryOpen = false
addClickingBoxes = false
clickingBox = {}--has to be emptied every time
editingTicket = false
keyboardInput = false
completingAGoal = false
asIfReturnWasPressed = true
editingDescription = false
end
elseif pPPointsShown == true then
pPPointsShown = true
viewingGoals = false
editingGoals = false
addingDumbGoal = false
clickingBox = {}
addingSmartGoal = false
ticketVaultOpen = false
ticketInventoryOpen = false
addClickingBoxes = false
clickingBox = {}--has to be emptied every time
editingTicket = false
keyboardInput = false
completingAGoal = false
asIfReturnWasPressed = true
editingDescription = false
clickingBox = {}--has to be emptied every time
pPPointsShown = false
manuallyViewingGoalSelected = 0
asIfReturnWasPressed = true
viewingGoals = false
editingGoals = false
editingTicket=false
editingDescription = false
end
end,
[3] = function () --newDumbGoal
if ticketVaultOpen == true then
elseif ticketInventoryOpen == true then
else
if viewingGoals==false and editingGoals == false then
addingDumbGoal = true
end
end
end,
[4] = function () --newSmartGoal or addReward
if ticketVaultOpen == true and editingTicket == false then
addTicketToVault()
selectedTicket = #ticketVault
save()
addClickingBoxes = true
clickingBox = {}--has to be emptied every tim
elseif ticketInventoryOpen == true then
else
if viewingGoals==false and editingGoals == false then
addingSmartGoal = true
end
end
end,
[5] = function () --tickets
if ticketInventoryOpen == false and ticketVaultOpen == false then
ticketInventoryOpen = true
addClickingBoxes = true
clickingBox = {}--has to be emptied every tim
selectedTicket = 1
editingTicket = false
ticketVaultOpen = false
editingGoals = false
viewingGoals = false
keyboardInput = false
completingAGoal = false
asIfReturnWasPressed = true
editingDescription = false
elseif ticketInventoryOpen == true or ticketVaultOpen == true then