Rework drawing party Pokémon, clean up paint.lua
This commit is contained in:
parent
38aa916669
commit
d4233a7d76
|
@ -20,7 +20,7 @@ local function sendButton(button, ab)
|
||||||
local inputTable = {[button] = true}
|
local inputTable = {[button] = true}
|
||||||
joypad.set(inputTable)
|
joypad.set(inputTable)
|
||||||
if debug then
|
if debug then
|
||||||
Utils.drawText(0, 7, button.." "..remainingFrames)
|
Utils.drawText(0, 14, button.." "..remainingFrames)
|
||||||
end
|
end
|
||||||
if ab then
|
if ab then
|
||||||
button = "A,B"
|
button = "A,B"
|
||||||
|
|
|
@ -6,14 +6,16 @@ local Utils = require "util.utils"
|
||||||
|
|
||||||
local Pokemon = require "storage.pokemon"
|
local Pokemon = require "storage.pokemon"
|
||||||
|
|
||||||
|
local RIGHT_EDGE, BOTTOM_EDGE = 158, 135
|
||||||
|
|
||||||
local encounters = 0
|
local encounters = 0
|
||||||
local elapsedTime = Utils.elapsedTime
|
local elapsedTime = Utils.elapsedTime
|
||||||
local drawText = Utils.drawText
|
local drawText = Utils.drawText
|
||||||
|
|
||||||
function Paint.draw(currentMap)
|
function Paint.draw(currentMap)
|
||||||
local px, py = Player.position()
|
local px, py = Player.position()
|
||||||
drawText(0, 14, currentMap..": "..px.." "..py)
|
|
||||||
drawText(0, 0, elapsedTime())
|
drawText(0, 0, elapsedTime())
|
||||||
|
drawText(0, 7, currentMap..": "..px.." "..py)
|
||||||
|
|
||||||
if Memory.value("battle", "our_id") > 0 then
|
if Memory.value("battle", "our_id") > 0 then
|
||||||
local curr_hp = Pokemon.index(0, "hp")
|
local curr_hp = Pokemon.index(0, "hp")
|
||||||
|
@ -24,37 +26,23 @@ function Paint.draw(currentMap)
|
||||||
hpStatus = "RED"
|
hpStatus = "RED"
|
||||||
end
|
end
|
||||||
if hpStatus then
|
if hpStatus then
|
||||||
drawText(120, 7, hpStatus)
|
drawText(RIGHT_EDGE, 7, hpStatus, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local xPokemon = 125
|
local caughtPokemon = {
|
||||||
local yPokemon = 15
|
{"squirtle"},
|
||||||
drawText(xPokemon,yPokemon,"Pokemons: ")
|
{"nidoran", "nidorino", "nidoking"},
|
||||||
local squirtx = Pokemon.indexOf("squirtle")
|
{"spearow", "pidgey"},
|
||||||
if squirtx ~= -1 then
|
{"paras", "oddish", "sandshrew", "charmander"},
|
||||||
drawText(xPokemon,yPokemon +5,"Squirtle")
|
}
|
||||||
end
|
local partyY = BOTTOM_EDGE
|
||||||
|
for i,pokemonCategory in ipairs(caughtPokemon) do
|
||||||
|
local pokemon = Pokemon.inParty(unpack(pokemonCategory))
|
||||||
local pidgeyx = Pokemon.indexOf("pidgey")
|
if pokemon then
|
||||||
if pidgeyx ~= -1 then
|
drawText(RIGHT_EDGE, partyY, Utils.capitalize(pokemon), true)
|
||||||
drawText(xPokemon,yPokemon+15,"Pidgey")
|
partyY = partyY - 7
|
||||||
end
|
end
|
||||||
|
|
||||||
local spearowx = Pokemon.indexOf("spearow")
|
|
||||||
if spearowx ~= -1 then
|
|
||||||
drawText(xPokemon,yPokemon+15,"Spearow")
|
|
||||||
end
|
|
||||||
|
|
||||||
local parasx = Pokemon.indexOf("paras")
|
|
||||||
if parasx ~= -1 then
|
|
||||||
drawText(xPokemon,yPokemon+20,"Paras")
|
|
||||||
end
|
|
||||||
|
|
||||||
local oddishx = Pokemon.indexOf("oddish")
|
|
||||||
if oddishx ~= -1 then
|
|
||||||
drawText(xPokemon,yPokemon+20,"Oddish")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local nidx = Pokemon.indexOf("nidoran", "nidorino", "nidoking")
|
local nidx = Pokemon.indexOf("nidoran", "nidorino", "nidoking")
|
||||||
|
@ -63,29 +51,11 @@ function Paint.draw(currentMap)
|
||||||
local def = Pokemon.index(nidx, "defense")
|
local def = Pokemon.index(nidx, "defense")
|
||||||
local spd = Pokemon.index(nidx, "speed")
|
local spd = Pokemon.index(nidx, "speed")
|
||||||
local scl = Pokemon.index(nidx, "special")
|
local scl = Pokemon.index(nidx, "special")
|
||||||
drawText(60, 0,"Nido stats: "..att.." "..def.." "..spd.." "..scl)
|
drawText(RIGHT_EDGE, 0, att.." "..def.." "..spd.." "..scl, true)
|
||||||
end
|
end
|
||||||
nidx = Pokemon.indexOf("nidoran")
|
|
||||||
if nidx == -1 then
|
drawText(0, BOTTOM_EDGE-7, "Repel: "..Memory.value("player", "repel"))
|
||||||
nidx = Pokemon.indexOf("nidorino")
|
drawText(0, BOTTOM_EDGE, Utils.pluralize(encounters, "encounter"))
|
||||||
if nidx == -1 then
|
|
||||||
nidx = Pokemon.indexOf("nidoking")
|
|
||||||
if nidx ~= -1 then
|
|
||||||
drawText(xPokemon,yPokemon+10,"Nidoking")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
drawText(xPokemon,yPokemon+10,"Nidorino")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
drawText(xPokemon,yPokemon+10,"Nidoran")
|
|
||||||
end
|
|
||||||
local enc = " encounter"
|
|
||||||
if encounters ~= 1 then
|
|
||||||
enc = enc.."s"
|
|
||||||
end
|
|
||||||
drawText(0, 116, Memory.value("battle", "critical"))
|
|
||||||
drawText(0, 125, Memory.value("player", "repel"))
|
|
||||||
drawText(0, 134, encounters..enc)
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,13 @@ function Utils.multiplyString(string, times)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Utils.pluralize(amount, description)
|
||||||
|
if amount ~= 1 then
|
||||||
|
description = description.."s"
|
||||||
|
end
|
||||||
|
return amount.." "..description
|
||||||
|
end
|
||||||
|
|
||||||
-- GAME
|
-- GAME
|
||||||
|
|
||||||
function Utils.canPotionWith(potion, forDamage, curr_hp, max_hp)
|
function Utils.canPotionWith(potion, forDamage, curr_hp, max_hp)
|
||||||
|
@ -112,7 +119,10 @@ function Utils.ingame()
|
||||||
return Memory.raw(0x020E) > 0
|
return Memory.raw(0x020E) > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function Utils.drawText(x, y, message)
|
function Utils.drawText(x, y, message, right)
|
||||||
|
if right then
|
||||||
|
x = x - #message * 5
|
||||||
|
end
|
||||||
gui.text(x * EMP, y * EMP, message)
|
gui.text(x * EMP, y * EMP, message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue