The other script is more directly useful during normal play. It displays the relationship status for the first-generation characters when the Y-button is pressed:
Language: lua
emu = snes9x
function sword(x) if x >= 0x8000 then return x-0x10000 else return x end end
nw, nm = 9, 15
wname = { "brg", "til", "fur", "syl", "lch", "dia", "edn", "ayr", "eth" }
mname = { "sig", "noi", "alc", "adn", "fin", "cua", "mid", "lev", "hol", "azl", "jam", "cld", "beo", "lex", "deu" }
function get_love()
local love_skip = 3
local love_tab = 0x7e3be5
local love = {}
for i = 1, nw do love[i] = {} end
for w = 0, nw-1 do
for m = 0, nm-1 do
love[w+1][m+1] = sword(memory.readword(love_tab+2*(w*(nm+love_skip)+m)))
end
end
return love
end
function love_color(score)
if score >= 500 then return 0x00ff00ff
elseif score > 400 then return 0xff8080
else return 0xffffff00 end
end
-- Display love table, hiding people who are not present
-- (i.e. those with 0 for all scores)
function show_love(love)
local width, height = 16, 7
local bsub = 4
-- Check which are present of each sex, and which are already
-- in love
local mok, wok, mmax, wmax = {}, {}, {}, {}
for w = 1, nw do wok[w] = 0 wmax[w] = 0 end
for m = 1, nm do mok[m] = 0 mmax[m] = 0 end
for w = 1, nw do
for m = 1, nm do
if love[w][m] ~= 0 then
mok[m] = mok[m] + 1
wok[w] = wok[w] + 1
if(love[w][m] > mmax[m]) then mmax[m] = love[w][m] end
if(love[w][m] > wmax[w]) then wmax[w] = love[w][m] end
end
end
end
wi = 0
for w = nw, 1, -1 do
if wok[w] > 0 then
wi = wi + 1
gui.fillbox(width*wi-2,0,width*(wi+1)-bsub,height,love_color(wmax[w]))
gui.text(width*wi,0,string.format("%3s",wname[w]))
mi = 0
for m = 1, nm do
if mok[m] > 0 then
mi = mi + 1
gui.fillbox(width*wi-2,height*mi,width*(wi+1)-bsub,height*(mi+1),love_color(love[w][m]))
gui.text(width*wi,height*mi,string.format("%3d",love[w][m]))
if wi==1 then
gui.fillbox(-2,height*mi,width-bsub,height*(mi+1),love_color(mmax[m]))
gui.text(0,height*mi,string.format("%3s",mname[m]))
end
end
end
end
end
end
while true do
local keys = joypad.get(1)
if keys.Y then
show_love(get_love())
end
emu.frameadvance()
end
Most of this code is simply drawing to the screen. The actual work is done in get_love().