-
Notifications
You must be signed in to change notification settings - Fork 0
/
completed_tasks_bag.ttslua
35 lines (31 loc) · 1.05 KB
/
completed_tasks_bag.ttslua
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
win_cube_GUID = "506978"
completed_task_counter_GUID = "21e8f6"
function onLoad()
completed_task_value = 0
completed_task_counter = getObjectFromGUID(completed_task_counter_GUID)
win_cube = getObjectFromGUID(win_cube_GUID)
end
function onUpdate()
local num_mission_cards = count_mission_cards(self) -- expensive!
local missions_to_complete = Global.getVar('MISSIONS_TO_COMPLETE')
if missions_to_complete ~= nil then
completed_task_counter.setValue(missions_to_complete - num_mission_cards)
end
end
function filterObjectEnter(obj)
-- consumes an object trying to get into the bag and returns
-- true if the object's a taskcard, false otherwise.
return Global.call("is_taskcard_p", obj)
end
function count_mission_cards(self)
-- consumes self (a bag) and counts the number of mission cards I hold
-- expensive, ish.
object_descs = self.getObjects()
count = 0
for _, desc in ipairs(object_descs) do
if Global.call("is_taskcard_desc_p", desc) then
count = count + 1
end
end
return count
end