I have some code here that I've been trying to make work, but I'm not sure what's going wrong. I watched an x-y pair that I'm almost certain is picked up by readbyte() in the for loop, just to make sure something has canvas coordinates. Yet drawRectangle isn't giving me anything with the inputs I give it.
I'd love to hear any suggestions, since coming from Python, I see Lua as some kind of special needs child that I have to work with.
gui.drawRectangle(100,100,5,5), if put inside highlightSprites(), gives a very apparent white square.
Language: lua
--not used
function map(f, arr)
for index,value in pairs(arr) do
result[index] = f(index,value)
end
return result
end
meX = 0
meY = 0
--canShoot = false
function boxSprite(name,position)
gui.drawRectangle(position[0],position[1],5,5)
end
--dudewat no colons this is spooky where's muh python
function highlightSprites()
--probably not bytes, will determine the correct read when I get home and have the game in front of me
meX = memory.readbyte(0x000B88)
meY = memory.readbyte(0x000B8C)
--seriously this language is like made of marshmallows
--this assignment is index-explicit for a reason
--because {meX,meY}[0] == nil
--like wow
positionTable = {}
positionTable[0] = {}
positionTable[0][0] = meX
positionTable[0][1] = meY
top = 0x000BD8+25*0x50
--not sure how big the object table is but on frame 3737
for i = 0x000BD8, top, 0x50 do
positionTable[i] = {[0] = 0,[1] = 0}
positionTable[i][0] = memory.readbyte(i)
positionTable[i][1] = memory.readbyte(i+2)
end
--map(boxSprite,positionTable)
i = 0
while(i ~= nil) do
gui.drawRectangle(positionTable[i][0],positionTable[i][1],5,5)
i = next(positionTable,i)
end
end
--emu.registerbefore(highlightSprites)
while true do
emu.frameadvance()
highlightSprites()
end