Skip to content

Working examples for Lua functions emu.getregister and emu.setregister #4349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SandTAS
Copy link

@SandTAS SandTAS commented Jun 8, 2025

The old examples were trying to use emu.getregisters()[0] to get an arbitrary register name for the current core. But emu.getregisters() returns a key–value table, not a sequential table, so it's not correct to index it with an integer. Even if it were a sequential table, the first element would be at index 1, not 0.

The new examples use the Lua function next to get an arbitrary register name. They also replace the apparently autogenerated variable name inemuget with more meaningful ones (regname and value).

Check if completed:

The old examples were trying to use `emu.getregisters()[0]` to get an
arbitrary register name for the current core. But `emu.getregisters()`
returns a key–value table, not a sequential table, so it's not correct
to index it with an integer. Even if it were a sequential table, the
first element would be at index 1, not 0.

The new examples use the Lua function `next` to get an arbitrary
register name. They also replace the apparently autogenerated variable
name `inemuget` with more meaningful ones (`regname` and `value`).
@YoshiRulz
Copy link
Member

The replacement is just as unhelpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants