fceux-lualisted
Install: claude install-skill Yuki001/nes-skills
# FCEUX Lua Scripting
Write Lua scripts for FCEUX (`fceux64.exe -lua script.lua rom.nes`) to automate NES ROM analysis tasks.
## FCEUX binary
The skill bundles FCEUX 2.6.6 for Windows at `bin/fceux-2.6.6-win64.zip`.
If the project already has FCEUX installed (e.g. `tools/fceux/fceux64.exe`), use that. If not, extract the skill's bundled zip:
```bash
# Linux/WSL
unzip .claude/skills/fceux-lua/bin/fceux-2.6.6-win64.zip -d tools/fceux/
# Windows (PowerShell)
Expand-Archive .claude/skills/fceux-lua/bin/fceux-2.6.6-win64.zip -DestinationPath tools/fceux/
```
The zip contains `fceux64.exe` and required DLLs (`lua5.1.dll`, `7z_64.dll`, etc.).
## Critical Lua syntax for FCEUX
```lua
-- FCEUX uses LuaJIT. Key gotchas:
-- 1. Callbacks take FUNCTION REFERENCES, not strings:
memory.registerexec(0x8000, 0x80FF, my_callback) -- CORRECT
memory.registerexec(0x8000, 0x80FF, "my_callback") -- WRONG: bad argument #3, need function
-- 2. Print goes to console, often invisible. Write to files instead:
local log = io.open("output.txt", "w")
log:write("message\n"); log:flush()
-- 3. Non-ASCII text may crash on Windows GBK terminal. Use ASCII labels.
-- 4. Callback functions must be global, not local.
```
## Script template
```lua
local log = io.open("script_log.txt", "w")
local function p(msg) log:write(msg .. "\n"); log:flush() end
-- ... script body ...
p("Done. Total frames: " .. emu.framecount())
log:close()
emu.exit() -- always exit cleanly
```
Run: `./fceux64.ex