Simplify menu open/close checking with better support for Yellow

This commit is contained in:
Kyle Coburn 2015-04-15 01:41:02 -07:00
parent 70998c425a
commit 1d0182dc0d
5 changed files with 50 additions and 19 deletions

View File

@ -42,12 +42,12 @@ function Shop.transaction(options)
end
if not item then
if not Textbox.isActive() then
if not Menu.isOpened() then
return true
end
Input.press("B")
elseif Player.isFacing(options.direction or "Left") then
if Textbox.isActive() then
if Menu.isOpened() then
local mainMenu = yellow and 245 or 32
if Menu.isCurrently(mainMenu, "shop") then
Menu.select(menuIdx, true, false, "shop")
@ -88,12 +88,12 @@ function Shop.vend(options)
end
end
if not item then
if not Textbox.isActive() then
if not Menu.isOpened() then
return true
end
Input.press("B")
elseif Player.face(options.direction) then
if Textbox.isActive() then
if Menu.isOpened() then
if Memory.value("battle", "text") > 1 and not Menu.hasTextbox() then
Menu.select(item.index, true)
else

View File

@ -1251,7 +1251,7 @@ strategyFunctions.shopBuffs = function()
end
strategyFunctions.deptElevator = function()
if Textbox.isActive() then
if Menu.isOpened() then
status.canProgress = true
Menu.select(0, false, true)
else
@ -1761,7 +1761,7 @@ strategyFunctions.depositPokemon = function()
return true
end
else
if not Textbox.isActive() then
if not Menu.isOpened() then
Player.interact("Up")
else
local pc = Memory.value("menu", "size")

View File

@ -332,7 +332,7 @@ local function completedSkillFor(data)
if Memory.raw(data.done) > (data.val or 0) then
return true
end
elseif status.tries > 0 and not Menu.isOpen() then
elseif status.tries > 0 and not Menu.isOpened() then
return true
end
return false
@ -637,8 +637,14 @@ Strategies.functions = {
skill = function(data)
if completedSkillFor(data) then
if not Menu.hasTextbox() and not Textbox.isActive() then
return true
if yellow then
if not Menu.hasTextbox() then
return true
end
else
if not Menu.isOpened() then
return true
end
end
Input.press("B")
elseif not data.dir or Player.face(data.dir) then
@ -1279,7 +1285,7 @@ Strategies.functions = {
end,
silphElevator = function()
if Textbox.isActive() then
if Menu.isOpened() then
status.canProgress = true
Menu.select(9, false, true)
else

View File

@ -64,9 +64,7 @@ Strategies.timeRequirements = {
-- HELPERS
local function depositPikachu()
if not Textbox.isActive() then
Player.interact("Up")
else
if Menu.isOpened() then
local pc = Memory.value("menu", "size")
if Memory.value("battle", "menu") ~= 19 then
local menuColumn = Menu.getCol()
@ -84,6 +82,8 @@ local function depositPikachu()
else
Input.cancel()
end
else
Player.interact("Up")
end
end
@ -491,7 +491,7 @@ end
-- redbarCubone
strategyFunctions.deptElevator = function()
if Textbox.isActive() then
if Menu.isOpened() then
status.canProgress = true
Menu.select(4, false, true)
else
@ -695,7 +695,7 @@ strategyFunctions.depositPokemon = function()
if Menu.close() then
return true
end
else
elseif Menu.isOpened() then
local menuSize = Memory.value("menu", "size")
if not Menu.hasTextbox() then
if menuSize == 5 then
@ -713,6 +713,8 @@ strategyFunctions.depositPokemon = function()
end
end
Input.press("A")
else
Player.interact("Up")
end
end

View File

@ -6,6 +6,7 @@ local Memory = require "util.memory"
local yellow = GAME_NAME == "yellow"
local sliding = false
local alternateStart = 0
Menu.pokemon = yellow and 51 or 103
@ -183,19 +184,32 @@ function Menu.onPokemonSelect(battleMenu)
return battleMenu == 8 or battleMenu == 48 or battleMenu == 184 or battleMenu == 224
end
function Menu.isOpen()
return Memory.value("game", "textbox") == 1 or Memory.value("menu", "current") == 24
function Menu.isOpened()
return Memory.value("game", "textbox") == 1
end
function Menu.hasBeenOpened()
local mainMenu = Memory.value("menu", "main")
if mainMenu > 7 then
return true
end
if (Menu.isOpened() or Menu.onPokemonSelect()) and (mainMenu == 0 or mainMenu == 2 or mainMenu == 4 or mainMenu == 6) then
return true
end
if mainMenu > 0 and INTERNAL and not STREAMING_MODE then
p("DMM", mainMenu)
end
end
function Menu.close()
if Memory.value("game", "textbox") == 0 and Memory.value("menu", "main") < 8 then
if not Menu.hasBeenOpened() then
return true
end
Input.press("B")
end
function Menu.pause()
if Memory.value("game", "textbox") == 1 then
if Menu.isOpened() then
if Menu.hasTextbox() then
Input.cancel()
else
@ -206,6 +220,15 @@ function Menu.pause()
Input.press("B")
end
else
if yellow then
alternateStart = alternateStart + 1
if alternateStart > 1 then
if alternateStart > 2 then
alternateStart = 0
end
return false
end
end
Input.press("Start", 2)
end
end