From d63ed6607273e9d2efbb9e38b1993bebfa34a482 Mon Sep 17 00:00:00 2001 From: Kyle Coburn Date: Fri, 10 Apr 2015 01:14:27 -0700 Subject: [PATCH] Merge pull requests --- main.lua | 11 ++++++----- util/memory.lua | 7 ++++++- util/utils.lua | 30 +++++++++++++----------------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/main.lua b/main.lua index bc7770b..869d923 100644 --- a/main.lua +++ b/main.lua @@ -32,7 +32,7 @@ local Settings = require "util.settings" local Pokemon = require "storage.pokemon" local hasAlreadyStartedPlaying = false -local oldSecs +local oldSeconds local running = true local lastHP @@ -64,7 +64,7 @@ local function resetAll() Walk.reset() Paint.reset() Bridge.reset() - oldSecs = 0 + oldSeconds = 0 running = false -- client.speedmode = 200 @@ -73,6 +73,7 @@ local function resetAll() p("RUNNING WITH A FIXED SEED ("..Strategies.seed.."), every run will play out identically!", true) else Strategies.seed = os.time() + print("PokeBot v"..VERSION..": starting a new run with seed "..Strategies.seed) end math.randomseed(Strategies.seed) end @@ -170,10 +171,10 @@ while true do end if STREAMING_MODE then - local newSecs = Memory.raw(0x1A44) - if newSecs ~= oldSecs and (newSecs > 0 or Memory.raw(0x1A45) > 0) then + local newSeconds = Memory.value("time", "seconds") + if newSeconds ~= oldSeconds and (newSeconds > 0 or Memory.value("time", "frames") > 0) then Bridge.time(Utils.elapsedTime()) - oldSecs = newSecs + oldSeconds = newSeconds end elseif PAINT_ON then Paint.draw(currentMap) diff --git a/util/memory.lua b/util/memory.lua index d7316ff..16b8dfa 100644 --- a/util/memory.lua +++ b/util/memory.lua @@ -37,10 +37,15 @@ local memoryNames = { }, game = { map = 0x135E, - frames = 0x1A45, battle = 0x1057, textbox = 0x0FC4, }, + time = { + hours = 0x1A41, + minutes = 0x1A43, + seconds = 0x1A44, + frames = 0x1A45, + }, shop = { transaction_amount = 0x0F96, }, diff --git a/util/utils.lua b/util/utils.lua index d97a39c..254c25b 100644 --- a/util/utils.lua +++ b/util/utils.lua @@ -82,10 +82,10 @@ end -- TIME function Utils.igt() - local secs = Memory.raw(0x1A44) - local mins = Memory.raw(0x1A43) - local hours = Memory.raw(0x1A41) - return secs + mins * 60 + hours * 3600 + local hours = Memory.value("time", "hours") + local mins = Memory.value("time", "minutes") + local secs = Memory.value("time", "seconds") + return (hours * 60 + mins) * 60 + secs end local function clockSegment(unit) @@ -108,22 +108,18 @@ 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("time", "seconds") + local mins = Memory.value("time", "minutes") + local hours = Memory.value("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("time", "hours") * 60 + totalFrames = (totalFrames + Memory.value("time", "minutes")) * 60 + totalFrames = (totalFrames + Memory.value("time", "seconds")) * 60 + totalFrames = totalFrames + Memory.value("time", "frames") + return totalFrames end return Utils