Skip to content

Lua: Add Ramsearch functions#687

Open
Perdu wants to merge 3 commits intoclementgallet:masterfrom
Perdu:lua_ramsearch
Open

Lua: Add Ramsearch functions#687
Perdu wants to merge 3 commits intoclementgallet:masterfrom
Perdu:lua_ramsearch

Conversation

@Perdu
Copy link
Copy Markdown
Contributor

@Perdu Perdu commented Nov 16, 2025

This commit adds ability to perform RAM search from lua scripts.

Finding variables in memory can be an especially tedious process in libTAS as, unlike emulators, addresses change across different runs of the same process, or even inside a single execution of the process. This commits provides another way to make finding variable easier, along with the existing pointer search function.

To do this, I reused the MemScanner from RamSearchModel.

I included a basic example in the documentation to showcase how to use it to automatically retrieve the player x;y position in a game, provided we know the value at some specific frames.

I reordered the parameters in the API compared to memscanner.scan() to put values that users have more chance to be willing to change in first positions, as lua does not provide a way to use named parameters.

One thing that can be discussed is whether it would be a good idea to tie this search to the Ram search window (which I originally tried using newWatches() and searchWatches(), but I reverted to calling memscanner.scan() as it wasn't sufficient) or make them completely independent search. The latter would open the way to make several ram search in parallel, to look for different variables on the same frames.

Edit: One thing I forgot to mention is that there may be conflicts when using this new lua function and the window ramsearch in parallel (not sure, I haven't tested this)

@Perdu
Copy link
Copy Markdown
Contributor Author

Perdu commented Dec 6, 2025

I noticed an issue: only the case when we compare integers works and not other types. I need to fix this

Note: the CI issue is due to the error that was fixed in e997120

@Perdu
Copy link
Copy Markdown
Contributor Author

Perdu commented Dec 7, 2025

I noticed an issue: only the case when we compare integers works and not other types. I need to fix this

Note: the CI issue is due to the error that was fixed in e997120

Fixed + rebased to fix CI issue

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