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
--untested
TimeSystem = {}
TimeSystem.hours = 0;
TimeSystem.minutes = 0;
TimeSystem.days = 0;
function TimeSystem:New(object)
	object = object or {}; 				-- create object if user does not provide one
	setmetatable(object, self);
	self.__index = self;
	
	return object;
end
function TimeSystem:TickMinute()
	self.minutes = self.minutes + 1;
	
	if (self.minutes >= 60) then
		self.minutes = 0;
		self.hours = self.hours + 1;
		if (self.hours >= 24) then
			self.hours = 0;
			self.days = self.days + 1;
		end
		
		return true;
	end
	
	
	
	return false;
end
function TimeSystem:GetTime()
	if (self.days <= 0) then
		if (self.hours <= 0) then
		
			if (self.minutes <= 0) then
				return "No time has passed";
			end
			
			
			return tostring(self.minutes).." minutes"
		end
		
		return tostring(self.hours).." hours, "..tostring(self.minutes).." minutes";
	end
	
	local tempstring = tostring(self.days).." days, "..tostring(self.hours).." hours";
	if (self.minutes == 0) then
		return tempstring;
	else
		return tempstring..", "..tostring(self.minutes).." minutes";
	end
end
---------------------------------------------------------------
-- Then use as
local myTimeSystem = TimeSystem:New()
addhook("minute","minuteHook")
function minuteHook()
	myTimeSystem:TickMinute();
	msg(myTimeSystem:GetTime());
end