This commit is contained in:
Kyle Coburn 2015-05-25 12:42:07 -07:00
parent 16f37b0330
commit 1461aa2877
15 changed files with 49 additions and 66 deletions

View File

@ -103,7 +103,7 @@ local function attack(attackIndex)
end end
end end
function movePP(name) local function movePP(name)
local midx = Pokemon.battleMove(name) local midx = Pokemon.battleMove(name)
if not midx then if not midx then
return 0 return 0
@ -212,7 +212,7 @@ function Battle.handleWild(battleStatus)
Battle.handle() Battle.handle()
end end
function Battle.fight(move, skipBuffs) function Battle.fight(move)
if move then if move then
if type(move) ~= "number" then if type(move) ~= "number" then
move = Pokemon.battleMove(move) move = Pokemon.battleMove(move)
@ -296,6 +296,7 @@ function Battle.redeployNidoking()
elseif Menu.hasTextbox() and Menu.getCol() == 1 then elseif Menu.hasTextbox() and Menu.getCol() == 1 then
Input.press("A") Input.press("A")
else else
local forced
local __, turns = Combat.bestMove() local __, turns = Combat.bestMove()
if turns == 1 then if turns == 1 then
if Pokemon.isDeployed("spearow") then if Pokemon.isDeployed("spearow") then

View File

@ -1,7 +1,5 @@
local Shop = {} local Shop = {}
local Textbox = require "action.textbox"
local Data = require "data.data" local Data = require "data.data"
local Input = require "util.input" local Input = require "util.input"
@ -17,7 +15,7 @@ function Shop.transaction(options)
menuIdx = 1 menuIdx = 1
itemMenu = Data.yellow and 28 or 29 itemMenu = Data.yellow and 28 or 29
quantityMenu = 158 quantityMenu = 158
for i,sit in ipairs(options.sell) do for __,sit in ipairs(options.sell) do
local idx = Inventory.indexOf(sit.name) local idx = Inventory.indexOf(sit.name)
if idx ~= -1 then if idx ~= -1 then
item = sit item = sit
@ -31,7 +29,7 @@ function Shop.transaction(options)
menuIdx = 0 menuIdx = 0
itemMenu = Data.yellow and 122 or 123 itemMenu = Data.yellow and 122 or 123
quantityMenu = 161 quantityMenu = 161
for i,bit in ipairs(options.buy) do for __,bit in ipairs(options.buy) do
local needed = (bit.amount or 1) - Inventory.count(bit.name) local needed = (bit.amount or 1) - Inventory.count(bit.name)
if needed > 0 then if needed > 0 then
item = bit item = bit
@ -78,8 +76,7 @@ end
function Shop.vend(options) function Shop.vend(options)
local item local item
menuIdx = 0 for __,bit in ipairs(options.buy) do
for i,bit in ipairs(options.buy) do
local needed = (bit.amount or 1) - Inventory.count(bit.name) local needed = (bit.amount or 1) - Inventory.count(bit.name)
if needed > 0 then if needed > 0 then
item = bit item = bit

View File

@ -32,7 +32,7 @@ end
-- Helper functions -- Helper functions
function dir(px, py, dx, dy) local function dir(px, py, dx, dy)
local direction local direction
if py > dy then if py > dy then
direction = "Up" direction = "Up"
@ -47,7 +47,7 @@ function dir(px, py, dx, dy)
end end
Walk.dir = dir Walk.dir = dir
function step(dx, dy, through) local function step(dx, dy, through)
local px, py = Player.position() local px, py = Player.position()
if px == dx and py == dy then if px == dx and py == dy then
return true return true

View File

@ -44,7 +44,6 @@ types[24] = "psychic"
types[25] = "ice" types[25] = "ice"
types[26] = "dragon" types[26] = "dragon"
local savedEncounters = {}
local conservePP = false local conservePP = false
local allowDamageRange = false local allowDamageRange = false
local disableThrash = false local disableThrash = false
@ -133,7 +132,7 @@ local function getOpponentType(ty)
end end
Combat.getOpponentType = getOpponentType Combat.getOpponentType = getOpponentType
function getOurType(ty) local function getOurType(ty)
local t1 = types[Memory.value("battle", "our_type1")] local t1 = types[Memory.value("battle", "our_type1")]
if ty ~= 0 then if ty ~= 0 then
t1 = types[Memory.value("battle", "our_type2")] t1 = types[Memory.value("battle", "our_type2")]
@ -195,7 +194,7 @@ local function calcBestHit(attacker, defender, ours, rng)
local ourMaxHit local ourMaxHit
local targetHP = defender.hp local targetHP = defender.hp
local ret = nil local ret = nil
for idx,move in ipairs(attacker.moves) do for __,move in ipairs(attacker.moves) do
if not move.pp or move.pp > 0 then if not move.pp or move.pp > 0 then
local minDmg, maxDmg = calcDamage(move, attacker, defender, rng) local minDmg, maxDmg = calcDamage(move, attacker, defender, rng)
if maxDmg then if maxDmg then
@ -236,7 +235,7 @@ local function calcBestHit(attacker, defender, ours, rng)
replaces = maxTurns < bestMinTurns replaces = maxTurns < bestMinTurns
end end
end end
elseif maxTurns < 2 or maxTurns == bestMaxTurns then elseif maxTurns < 2 or maxTurns == bestTurns then
if ret.name == "Earthquake" and (move.name == "Ice-Beam" or move.name == "Thunderbolt") then if ret.name == "Earthquake" and (move.name == "Ice-Beam" or move.name == "Thunderbolt") then
replaces = true replaces = true
elseif move.pp > ret.pp then elseif move.pp > ret.pp then
@ -278,7 +277,7 @@ local function getBestMove(ours, enemy, draw)
return return
end end
local bm, bestUs = calcBestHit(ours, enemy, true) local bm, bestUs = calcBestHit(ours, enemy, true)
local jj, bestEnemy = calcBestHit(enemy, ours, false) local __, bestEnemy = calcBestHit(enemy, ours, false)
if not bm then if not bm then
return return
end end
@ -341,7 +340,7 @@ function Combat.isPoisoned(target)
return checkStatus(target, 0x8) return checkStatus(target, 0x8)
end end
function Combat.hasParalyzeStatus(target) function Combat.hasParalyzeStatus()
return Memory.value("battle", "paralyzed") > 0 return Memory.value("battle", "paralyzed") > 0
end end
@ -412,7 +411,7 @@ end
function Combat.inKillRange(draw) function Combat.inKillRange(draw)
local ours, enemy = activePokemon() local ours, enemy = activePokemon()
local enemyAttack, __ = calcBestHit(enemy, ours, false) local enemyAttack, turnsToDie = calcBestHit(enemy, ours, false)
local __, turnsToKill = calcBestHit(ours, enemy, true) local __, turnsToKill = calcBestHit(ours, enemy, true)
if not turnsToKill or not enemyAttack then if not turnsToKill or not enemyAttack then
return false return false
@ -434,7 +433,7 @@ function Combat.inKillRange(draw)
end end
outsped = Memory.value("battle", "attack_turns") > 0 outsped = Memory.value("battle", "attack_turns") > 0
end end
if outsped or isConfused or turnsToKill > 1 or ours.speed <= enemy.speed or Pokemon.info(target, "status") > 0 then if outsped or isConfused or turnsToKill > 1 or ours.speed <= enemy.speed or Pokemon.info(0, "status") > 0 then
return ours, hpReq return ours, hpReq
end end
end end
@ -461,7 +460,7 @@ function Combat.nonKill()
end end
local bestDmg = -1 local bestDmg = -1
local ret = nil local ret = nil
for idx,move in ipairs(ours.moves) do for __,move in ipairs(ours.moves) do
if not move.pp or move.pp > 0 then if not move.pp or move.pp > 0 then
local __, maxDmg = calcDamage(move, ours, enemy, true) local __, maxDmg = calcDamage(move, ours, enemy, true)
if maxDmg > 0 then if maxDmg > 0 then

View File

@ -19,10 +19,11 @@ local potionInBattle = true
local encounters = 0 local encounters = 0
local canDie, shouldFight, minExp local canDie, shouldFight, minExp
local shouldCatch, attackIdx local shouldCatch
local extraEncounter, maxEncounters local extraEncounter, maxEncounters
local battleYolo local battleYolo
local encountersSection local encountersSection
local oneHits
Control.areaName = "Unknown" Control.areaName = "Unknown"
Control.getMoonExp = true Control.getMoonExp = true
@ -204,7 +205,7 @@ function Control.shouldFight()
if expRemaining > 0 then if expRemaining > 0 then
local oid = Memory.value("battle", "opponent_id") local oid = Memory.value("battle", "opponent_id")
local opponentLevel = Memory.value("battle", "opponent_level") local opponentLevel = Memory.value("battle", "opponent_level")
for i,encounter in ipairs(shouldFight) do for __,encounter in ipairs(shouldFight) do
if oid == Pokemon.getID(encounter.name) and (not encounter.levels or Utils.match(opponentLevel, encounter.levels)) then if oid == Pokemon.getID(encounter.name) and (not encounter.levels or Utils.match(opponentLevel, encounter.levels)) then
if oneHits then if oneHits then
local move = Combat.bestMove() local move = Combat.bestMove()
@ -222,7 +223,7 @@ function Control.shouldFight()
end end
end end
function Control.canCatch(partySize) function Control.canCatch()
local minimumCount = 0 local minimumCount = 0
if not Pokemon.inParty("nidoran", "nidorino", "nidoking") then if not Pokemon.inParty("nidoran", "nidorino", "nidoking") then
minimumCount = minimumCount + (Data.yellow and 1 or 2) minimumCount = minimumCount + (Data.yellow and 1 or 2)
@ -271,7 +272,7 @@ function Control.shouldCatch(partySize)
end end
local oid = Memory.value("battle", "opponent_id") local oid = Memory.value("battle", "opponent_id")
local opponentLevel = Memory.value("battle", "opponent_level") local opponentLevel = Memory.value("battle", "opponent_level")
for i,poke in ipairs(shouldCatch) do for __,poke in ipairs(shouldCatch) do
if oid == Pokemon.getID(poke.name) and not Pokemon.inParty(poke.name, poke.alt) then if oid == Pokemon.getID(poke.name) and not Pokemon.inParty(poke.name, poke.alt) then
if not poke.levels or Utils.match(opponentLevel, poke.levels) then if not poke.levels or Utils.match(opponentLevel, poke.levels) then
local overHP = poke.hp and Memory.double("battle", "opponent_hp") > poke.hp local overHP = poke.hp and Memory.double("battle", "opponent_hp") > poke.hp
@ -381,7 +382,7 @@ function Control.encounter(battleState)
if not opponentAlive and shouldCatch and not Control.killedCatch then if not opponentAlive and shouldCatch and not Control.killedCatch then
local gottaCatchEm = {"pidgey", "spearow", "paras", "oddish"} local gottaCatchEm = {"pidgey", "spearow", "paras", "oddish"}
local opponent = Battle.opponent() local opponent = Battle.opponent()
for i,catch in ipairs(gottaCatchEm) do for __,catch in ipairs(gottaCatchEm) do
if opponent == catch then if opponent == catch then
if not Pokemon.inParty(catch) then if not Pokemon.inParty(catch) then
local criticaled = Memory.value("battle", "critical") == 1 local criticaled = Memory.value("battle", "critical") == 1

View File

@ -227,7 +227,7 @@ local function potionForRedBar(damage)
{"potion", 20}, {"potion", 20},
{"super_potion", 50}, {"super_potion", 50},
} }
for i,potionTable in ipairs(potions) do for __,potionTable in ipairs(potions) do
local potion = potionTable[1] local potion = potionTable[1]
if Inventory.contains(potion) then if Inventory.contains(potion) then
local healsFor = potionTable[2] local healsFor = potionTable[2]
@ -700,7 +700,7 @@ end
-- dodgeCerulean -- dodgeCerulean
strategyFunctions.rivalSandAttack = function(data) strategyFunctions.rivalSandAttack = function()
if Strategies.trainerBattle() then if Strategies.trainerBattle() then
if Battle.redeployNidoking() then if Battle.redeployNidoking() then
local sacrifice = Battle.deployed() local sacrifice = Battle.deployed()
@ -930,7 +930,6 @@ strategyFunctions.catchOddish = function()
Player.interact("Left") Player.interact("Left")
Strategies.foughtRaticateEarly = true Strategies.foughtRaticateEarly = true
else else
local path
if caught then if caught then
if Strategies.initialize("caught") then if Strategies.initialize("caught") then
Bridge.caught(Pokemon.inParty("oddish")) Bridge.caught(Pokemon.inParty("oddish"))
@ -1212,7 +1211,6 @@ end
strategyFunctions.lavenderRival = function() strategyFunctions.lavenderRival = function()
if Strategies.trainerBattle() then if Strategies.trainerBattle() then
local forced
if stats.nidoran.special > 44 then -- RISK if stats.nidoran.special > 44 then -- RISK
local __, enemyTurns = Combat.enemyAttack() local __, enemyTurns = Combat.enemyAttack()
if enemyTurns and enemyTurns < 2 and Pokemon.isOpponent("pidgeotto", "gyarados") then if enemyTurns and enemyTurns < 2 and Pokemon.isOpponent("pidgeotto", "gyarados") then
@ -1293,7 +1291,7 @@ strategyFunctions.silphRival = function()
if Strategies.prepare("x_accuracy", "x_speed") then if Strategies.prepare("x_accuracy", "x_speed") then
local forced local forced
local opponentName = Battle.opponent() local opponentName = Battle.opponent()
local curr_hp, red_hp = Combat.hp(), Combat.redHP() local curr_hp = Combat.hp()
if opponentName == "gyarados" then if opponentName == "gyarados" then
if status.gyaradosDamage then if status.gyaradosDamage then
if willRedBar(status.gyaradosDamage) then if willRedBar(status.gyaradosDamage) then

View File

@ -209,7 +209,7 @@ function Strategies.canHealFor(damage, allowAlreadyHealed, allowFullRestore)
if allowFullRestore then if allowFullRestore then
table.insert(healChecks, 1, "full_restore") table.insert(healChecks, 1, "full_restore")
end end
for idx,potion in ipairs(healChecks) do for __,potion in ipairs(healChecks) do
if Inventory.contains(potion) and Utils.canPotionWith(potion, damage, curr_hp, max_hp) then if Inventory.contains(potion) and Utils.canPotionWith(potion, damage, curr_hp, max_hp) then
return potion return potion
end end
@ -410,7 +410,7 @@ function Strategies.isPrepared(...)
if not status.preparing then if not status.preparing then
return false return false
end end
for i,name in ipairs(arg) do for __,name in ipairs(arg) do
local currentCount = Inventory.count(name) local currentCount = Inventory.count(name)
if currentCount > 0 then if currentCount > 0 then
local previousCount = status.preparing[name] local previousCount = status.preparing[name]
@ -427,7 +427,7 @@ function Strategies.prepare(...)
status.preparing = {} status.preparing = {}
end end
local item local item
for idx,name in ipairs(arg) do for __,name in ipairs(arg) do
local currentCount = Inventory.count(name) local currentCount = Inventory.count(name)
local needsItem = currentCount > 0 local needsItem = currentCount > 0
local previousCount = status.preparing[name] local previousCount = status.preparing[name]
@ -550,7 +550,7 @@ function Strategies.completeCans()
} }
local walkIn = "Up" local walkIn = "Up"
for dir,tileset in pairs(completePath) do for dir,tileset in pairs(completePath) do
for i,tile in ipairs(tileset) do for __,tile in ipairs(tileset) do
if px == tile[1] and py == tile[2] then if px == tile[1] and py == tile[2] then
walkIn = dir walkIn = dir
break break
@ -923,7 +923,7 @@ Strategies.functions = {
elseif status.firstIndex < 0 or status.lastIndex < 0 then elseif status.firstIndex < 0 or status.lastIndex < 0 then
swapComplete = true swapComplete = true
if Strategies.initialize("swapUnavailable") then if Strategies.initialize("swapUnavailable") then
p("Not available to swap", data.item, data.dest, itemIndex, destIndex) p("Not available to swap", data.item, data.dest, status.firstIndex, status.lastIndex)
end end
elseif status.startedAt ~= Inventory.indexOf(status.checkItem) then elseif status.startedAt ~= Inventory.indexOf(status.checkItem) then
swapComplete = true swapComplete = true
@ -1011,7 +1011,7 @@ Strategies.functions = {
local opp = Battle.opponent() local opp = Battle.opponent()
local defLimit = 9001 local defLimit = 9001
local forced local forced
for i,poke in ipairs(data) do for __,poke in ipairs(data) do
if opp == poke[1] then if opp == poke[1] then
local minimumAttack = poke[3] local minimumAttack = poke[3]
if not minimumAttack or stats.nidoran.attack > minimumAttack then if not minimumAttack or stats.nidoran.attack > minimumAttack then
@ -1203,7 +1203,7 @@ Strategies.functions = {
end end
if resetsForStats then if resetsForStats then
local nidoranStatus local nidoranStatus = nil
if att < 15 and spd < 14 and scl < 12 then if att < 15 and spd < 14 and scl < 12 then
nidoranStatus = Utils.random { nidoranStatus = Utils.random {
"let's just forget this ever happened", "let's just forget this ever happened",
@ -1630,7 +1630,6 @@ Strategies.functions = {
if Battle.redeployNidoking() then if Battle.redeployNidoking() then
return false return false
end end
local forced
if Pokemon.isOpponent("staryu") then if Pokemon.isOpponent("staryu") then
local __, turnsToKill = Combat.bestMove() local __, turnsToKill = Combat.bestMove()
if turnsToKill and turnsToKill > 1 then if turnsToKill and turnsToKill > 1 then
@ -1660,7 +1659,7 @@ Strategies.functions = {
return false return false
end end
end end
Battle.automate(forced) Battle.automate()
elseif status.foughtTrainer then elseif status.foughtTrainer then
return true return true
end end
@ -2035,7 +2034,6 @@ Strategies.functions = {
end, end,
cinnabarCarbos = function() cinnabarCarbos = function()
local minDV = Data.yellow and 11 or 10
local skipsCarbos = not Strategies.needsCarbosAtLeast(Data.yellow and 2 or 1) local skipsCarbos = not Strategies.needsCarbosAtLeast(Data.yellow and 2 or 1)
if Strategies.initialize() then if Strategies.initialize() then
status.startCount = Inventory.count("carbos") status.startCount = Inventory.count("carbos")
@ -2064,7 +2062,6 @@ Strategies.functions = {
end, end,
ether = function(data) ether = function(data)
local main = Memory.value("menu", "main")
data.item = status.item data.item = status.item
if status.item and Strategies.completedMenuFor(data) then if status.item and Strategies.completedMenuFor(data) then
if Strategies.closeMenuFor(data) then if Strategies.closeMenuFor(data) then

View File

@ -11,8 +11,6 @@ local PAINT_ON = true -- Display contextual information while the bot runs
VERSION = "2.0.2" VERSION = "2.0.2"
local START_WAIT = 99
local Data = require "data.data" local Data = require "data.data"
Data.init() Data.init()
@ -30,7 +28,6 @@ local Pokemon = require "storage.pokemon"
local Bridge = require "util.bridge" local Bridge = require "util.bridge"
local Input = require "util.input" local Input = require "util.input"
local Memory = require "util.memory" local Memory = require "util.memory"
local Menu = require "util.menu"
local Paint = require "util.paint" local Paint = require "util.paint"
local Utils = require "util.utils" local Utils = require "util.utils"
local Settings = require "util.settings" local Settings = require "util.settings"
@ -109,7 +106,7 @@ local function generateNextInput(currentMap)
resetAll() resetAll()
end end
else else
Settings.startNewAdventure(START_WAIT) Settings.startNewAdventure()
end end
else else
if not running then if not running then
@ -134,7 +131,7 @@ local function generateNextInput(currentMap)
end end
end end
elseif battleState > 0 then elseif battleState > 0 then
if not Control.shouldCatch(partySize) then if not Control.shouldCatch() then
Battle.automate() Battle.automate()
end end
elseif Textbox.handle() then elseif Textbox.handle() then

View File

@ -3,7 +3,6 @@ local Inventory = {}
local Input = require "util.input" local Input = require "util.input"
local Memory = require "util.memory" local Memory = require "util.memory"
local Menu = require "util.menu" local Menu = require "util.menu"
local Utils = require "util.utils"
local Pokemon = require "storage.pokemon" local Pokemon = require "storage.pokemon"
@ -82,7 +81,7 @@ function Inventory.count(name)
end end
function Inventory.contains(...) function Inventory.contains(...)
for i,name in ipairs(arg) do for __,name in ipairs(arg) do
if Inventory.count(name) > 0 then if Inventory.count(name) > 0 then
return name return name
end end
@ -90,7 +89,7 @@ function Inventory.contains(...)
end end
function Inventory.containsAll(...) function Inventory.containsAll(...)
for i,name in ipairs(arg) do for __,name in ipairs(arg) do
if not Inventory.contains(name) then if not Inventory.contains(name) then
return false return false
end end

View File

@ -126,7 +126,7 @@ end
Pokemon.index = index Pokemon.index = index
local function indexOf(...) local function indexOf(...)
for ni,name in ipairs(arg) do for __,name in ipairs(arg) do
local pid = pokeIDs[name] local pid = pokeIDs[name]
for i=0,5 do for i=0,5 do
local atIdx = index(i) local atIdx = index(i)
@ -223,7 +223,7 @@ function Pokemon.getName(id)
end end
function Pokemon.getSacrifice(...) function Pokemon.getSacrifice(...)
for i,name in ipairs(arg) do for __,name in ipairs(arg) do
local pokemonIndex = indexOf(name) local pokemonIndex = indexOf(name)
if pokemonIndex ~= -1 and index(pokemonIndex, "hp") > 0 then if pokemonIndex ~= -1 and index(pokemonIndex, "hp") > 0 then
return name return name
@ -232,7 +232,7 @@ function Pokemon.getSacrifice(...)
end end
function Pokemon.inParty(...) function Pokemon.inParty(...)
for i,name in ipairs(arg) do for __,name in ipairs(arg) do
if indexOf(name) ~= -1 then if indexOf(name) ~= -1 then
return name return name
end end
@ -276,7 +276,7 @@ end
function Pokemon.isOpponent(...) function Pokemon.isOpponent(...)
local oid = Memory.value("battle", "opponent_id") local oid = Memory.value("battle", "opponent_id")
for i,name in ipairs(arg) do for __,name in ipairs(arg) do
if oid == pokeIDs[name] then if oid == pokeIDs[name] then
return name return name
end end
@ -285,7 +285,7 @@ end
function Pokemon.isDeployed(...) function Pokemon.isDeployed(...)
local deployedID = Memory.value("battle", "our_id") local deployedID = Memory.value("battle", "our_id")
for i,name in ipairs(arg) do for __,name in ipairs(arg) do
if deployedID == pokeIDs[name] then if deployedID == pokeIDs[name] then
return name return name
end end

View File

@ -9,8 +9,6 @@ if INTERNAL then
socket = require "socket" socket = require "socket"
end end
local utils = require "util.utils"
local client = nil local client = nil
local timeStopped = true local timeStopped = true
@ -107,8 +105,6 @@ function Bridge.process()
-- print(">"..response) -- print(">"..response)
if response:find("name:") then if response:find("name:") then
return response:gsub("name:", "") return response:gsub("name:", "")
else
end end
end end
end end

View File

@ -39,7 +39,7 @@ function Paint.draw(currentMap)
{"paras", "oddish", "charmander", "sandshrew"}, {"paras", "oddish", "charmander", "sandshrew"},
} }
local partyY = BOTTOM_EDGE local partyY = BOTTOM_EDGE
for i,pokemonCategory in ipairs(caughtPokemon) do for __,pokemonCategory in ipairs(caughtPokemon) do
local pokemon = Pokemon.inParty(unpack(pokemonCategory)) local pokemon = Pokemon.inParty(unpack(pokemonCategory))
if pokemon then if pokemon then
drawText(RIGHT_EDGE, partyY, Utils.capitalize(pokemon), true) drawText(RIGHT_EDGE, partyY, Utils.capitalize(pokemon), true)

View File

@ -2,8 +2,6 @@ local Player = {}
local Textbox = require "action.textbox" local Textbox = require "action.textbox"
local Data = require "data.data"
local Input = require "util.input" local Input = require "util.input"
local Memory = require "util.memory" local Memory = require "util.memory"

View File

@ -47,7 +47,7 @@ end
-- PUBLIC -- PUBLIC
function Settings.set(...) function Settings.set(...)
for i,name in ipairs(arg) do for __,name in ipairs(arg) do
if not isEnabled(name) then if not isEnabled(name) then
if Menu.open(settings_menu, 1) then if Menu.open(settings_menu, 1) then
Menu.setOption(name, desired[name]) Menu.setOption(name, desired[name])
@ -58,7 +58,7 @@ function Settings.set(...)
return Menu.cancel(settings_menu) return Menu.cancel(settings_menu)
end end
function Settings.startNewAdventure(startWait) function Settings.startNewAdventure()
local startMenu, withBattleStyle local startMenu, withBattleStyle
if Data.gameName ~= "red" then if Data.gameName ~= "red" then
withBattleStyle = "battle_style" withBattleStyle = "battle_style"
@ -72,7 +72,7 @@ function Settings.startNewAdventure(startWait)
if Settings.set("text_speed", "battle_animation", withBattleStyle) then if Settings.set("text_speed", "battle_animation", withBattleStyle) then
Menu.select(0) Menu.select(0)
end end
elseif math.random(0, startWait) == 0 then elseif math.random(0, START_WAIT) == 0 then
Input.press("Start", 2) Input.press("Start", 2)
end end
end end

View File

@ -12,7 +12,7 @@ function p(...)
string = arg[0] string = arg[0]
else else
string = "" string = ""
for i,str in ipairs(arg) do for __,str in ipairs(arg) do
if str == true then if str == true then
string = string.."\n" string = string.."\n"
else else
@ -46,7 +46,7 @@ function Utils.eachi(table, func)
end end
function Utils.match(needle, haystack) function Utils.match(needle, haystack)
for i,val in ipairs(haystack) do for __,val in ipairs(haystack) do
if needle == val then if needle == val then
return true return true
end end
@ -86,7 +86,7 @@ end
function Utils.multiplyString(string, times) function Utils.multiplyString(string, times)
local result = string local result = string
for i=1, times-1 do for __=1, times-1 do
result = result.." "..string result = result.." "..string
end end
return result return result