-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgress.ls
43 lines (35 loc) · 925 Bytes
/
Progress.ls
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
global numTasks, finishedTasks, numSteps, finishedSteps
on setTasks num
set ongoingTask = numTasks > 0
set numTasks = num + ongoingTask
set finishedTasks = 0
end
on removeTasks num
set numTasks = max(numTasks - num, 1)
end
on finishTask
if finishedTasks < numTasks then
set finishedTasks = finishedTasks + 1
setSteps(0)
end if
end
on setSteps num
set numSteps = num
set finishedSteps = 0
end
on finishStep
if finishedSteps < numSteps then set finishedSteps = finishedSteps + 1
end
on getProgress
set taskProgress = float(finishedSteps) / max(numSteps, 1)
return (finishedTasks + taskProgress) / max(numTasks, 1)
end
on resetProgress
set numTasks = 0
set finishedTasks = 0
set numSteps = 0
set finishedSteps = 0
end
on logProgress
logMsg(finishedTasks && "/" && numTasks && "tasks," && finishedSteps && "/" && numSteps && "steps")
end