From f96e0b015eb9bde8752cdb5382e234e63b58f7e5 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Wed, 8 Apr 2015 10:31:29 +0200 Subject: [PATCH] Clean up in-game time section --- util/memory.lua | 3 +++ util/utils.lua | 27 +++++++++++---------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/util/memory.lua b/util/memory.lua index 68cd4a2..67f99f3 100644 --- a/util/memory.lua +++ b/util/memory.lua @@ -44,6 +44,9 @@ local memoryNames = { frames = 0x1A45, battle = 0x1057, textbox = 0x0FC4, + time_hours = 0x1A41, + time_minutes = 0x1A43, + time_seconds = 0x1A44, }, shop = { transaction_amount = 0x0F96, diff --git a/util/utils.lua b/util/utils.lua index 25d2114..7123edb 100644 --- a/util/utils.lua +++ b/util/utils.lua @@ -67,9 +67,9 @@ end -- TIME function utils.igt() - local secs = memory.raw(0x1A44) - local mins = memory.raw(0x1A43) - local hours = memory.raw(0x1A41) + local secs = memory.value("game", "time_seconds") + local mins = memory.value("game", "time_minutes") + local hours = memory.value("game", "time_hours") return secs + mins * 60 + hours * 3600 end @@ -93,22 +93,17 @@ function utils.timeSince(prevTime) end function utils.elapsedTime() - local secs = memory.raw(0x1A44) - if secs < 10 then - secs = "0"..secs - end - local mins = memory.raw(0x1A43) - if mins < 10 then - mins = "0"..mins - end - return memory.raw(0x1A41)..":"..mins..":"..secs + local secs = memory.value("game", "time_seconds") + local mins = memory.value("game", "time_minutes") + local hours = memory.value("game", "time_hours") + return hours..":"..clockSegment(mins)..":"..clockSegment(secs) end function utils.frames() - local totalFrames = memory.raw(0x1A41) * 60 - totalFrames = (totalFrames + memory.raw(0x1A43)) * 60 - totalFrames = (totalFrames + memory.raw(0x1A44)) * 60 - return totalFrames + memory.raw(0x1A45) + local totalFrames = memory.value("game", "time_hours") * 60 + totalFrames = (totalFrames + memory.value("game", "time_minutes")) * 60 + totalFrames = (totalFrames + memory.value("game", "time_seconds")) * 60 + return totalFrames + memory.value("game", "frames") end return utils