It's amazing that some of the simple questions in this thread haven't been answered yet.
ElectroSpecter: To read 16 bits instead of 8, use memory.readword.
The basic structure of a simple emulator lua script is:
initialize if needed (usually isn't for simple scripts)
while true do
do everything you want to do every frame here
Snes9x.frameadvance()
end
If you don't have the loop, then the script will do stuff only once, and terminate after one frame.
Here is an example:
while true do
x = memory.readword(0x7e0b1b)
memory.writeword(0x7e1a62,x-0x80)
gui.text(10,10,"" .. x)
snes9x.frameadvance()
end
This sets the camera's x position to equal Donkey Kong's x position - 128, as well as displaying the x position. So to get the script you want, you would add the y parts, as well as a check for which character is active, and use appropriate addresses for that character.