From e1eb69d1a70dde6997dcf42a38c20e282ef58f92 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Tue, 24 Nov 2009 23:05:46 +0000 Subject: [PATCH] autotime git-svn-id: http://svn.net-core.org/repos/t-engine4@37 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engine/Calendar.lua | 2 -- game/modules/tome/class/Game.lua | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/game/engine/Calendar.lua b/game/engine/Calendar.lua index 189ba28b36..14da2d79ac 100644 --- a/game/engine/Calendar.lua +++ b/game/engine/Calendar.lua @@ -40,7 +40,6 @@ function _M:getDayOfYear(turn) d = math.floor(turn / self.DAY) y = math.floor(d / 365) d = math.floor(d % 365) - print(turn, d, y, self.YEAR) return d, self.start_year + y end @@ -49,7 +48,6 @@ function _M:getTimeOfDay(turn) min = math.floor((turn % self.DAY) / self.MINUTE) hour = math.floor(min / 60) min = math.floor(min % 60) - print(turn, hour, min, self.HOUR) return hour, min end diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index 88649a6550..32c3a1e47d 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -26,6 +26,7 @@ function _M:run() Map:setViewerFaction("players") self.calendar = Calendar.new("/data/calendar_rivendell.lua", "Today is the %s %s of the %s year of the Fourth Age of Middle-earth.\nThe time is %02d:%02d.", 122) + self.day_of_year = self.calendar:getDayOfYear(self.turn) self.zone = Zone.new("ancient_ruins") @@ -52,6 +53,11 @@ end function _M:tick() engine.GameTurnBased.tick(self) + + if self.day_of_year ~= self.calendar:getDayOfYear(self.turn) then + self.log(self.calendar:getTimeDate(self.turn)) + self.day_of_year = self.calendar:getDayOfYear(self.turn) + end end function _M:display() -- GitLab