Jump to content
  • 0

[Help request] How do I separate addresses with a specific distance between each other from other addresses?


Question

Posted (edited)

Hello, I'm a bit new to game guardian and started tinkering with it yesterday so I'm a noob. A bit of help would be appreciated. I'd be grateful if you could even just point me in the right direction to look.

I'm trying to increase a game's resolution to match my device's native display and I've mostly succeeded after trying for a day but the addresses get reset not only when I restart the game but also whenever I do that game's version of dungeon runs.

Their are 4 addresses that seem to impact the resolution from my testing. They have a address difference of 4 between them. 2 of the values are 728 and 2 of the values are 1620 by default. As you can see from the screenshot, same number values have an address difference of 8 between them.

I think I've figured out a range the addresses will be on so I can set that with the "From -> To" option in the search bar at the top right to use for when recording a script.

The problem is a lot of extra addresses show up with same number values which are for other things from what I can tell. I need to exclude them somehow while recording the script.

I'm thinking of searching 728 or the other first, finish adjusting for that value and then search the other number and finish the rest so I think I'll need to use an address difference of 8. I'm not going to freeze the values as they get reset and seem to start working on other processes when they get reset.....

Any help would be appreciated.

Screenshot_20240202-151022.png

Edited by MooExplosion
Realized my title sounded like I wanted a feature request which I didn't want

10 answers to this question

Recommended Posts

  • 0
Posted

I tried a bit more and can see the difference in the offset calculator option. When I press it, it only copies the value to my keyboard. Can I use the offset calculator to directly select those two addresses somehow?

This is the only step preventing me from recording a script

Screenshot_20240202-174114.png

  • 0
Posted

you can do a group search like this:

1620;728::5

or

1620;728;1620;728::13

to search only for values that have an offset of 0x4

if you still have too many results you can see if there are any unique values close to the ones you need and use them to select the right addresses.
then you can use a while loop to set the resolution values in the background

  • 0
Posted (edited)
On 2/2/2024 at 7:23 PM, MarioRossi93i said:

you can do a group search like this:

1620;728::5

or

1620;728;1620;728::13

to search only for values that have an offset of 0x4

if you still have too many results you can see if there are any unique values close to the ones you need and use them to select the right addresses.
then you can use a while loop to set the resolution values in the background

Thanks for the help MarioRossi. Your comment was helpful. I still have extra addresses sometimes but the amount is manageable enough now and even if I edit the wrong one by accident, nothing seems to happen now. The extra ones are same values with same differences. I feel like they don't serve any purpose in the game?

The recorded script is now runnable now. I can now adjust the game resolution even in dungeons where I don't have access to native game settings which I previously needed to help me find the addresses originally.

I don't know how to set a while loop up yet. A loop would be very neat but I have to go to specific menus before adjusting the resolution values and then go back to the game because the game glitches if you change it while gameplay is running. I think this makes running loops unfavourable?

I think I'll try more to get rid of extra addresses and change the resolution settings in a one click script too. My script currently just gathers the required addresses(and sometimes a few extra addresses).

For anyone who might see this, what I'm currently trying to do is make it convert the 728 value to 1080 and 1620 value to 2400 automatically after finding the addresses but I can't find a way to do this myself manually without selecting the addresses and changing the values myself. So far, what I do is, run the script to find the addresses> select one type of value all myself> convert it to what I want> inverse select to grab the other type of value in one click and change that as well.

The script recorder can't seem to record specific selection the way I tried. I'm guessing I'll need to edit the script file manually?

I found this post

How to loop? to edit and repeat the automatic edit many times? (#5glj94sj)

I think what I need is gg.getResults and gg.refineNumber?

Can I somehow specify the values gg.getResults will get? Is the last comment there specifying 10 random search values? Could I specify which values to grab?

Edited by MooExplosion
  • 0
Posted (edited)

Hi @MooExplosion,

Quote

Could I specify which values to grab?

gg.getResults() returns a table, and yes, you can specify which value to grab just by defining what index table that you want to get. So, you can either be specific or eliminate value to narrow it down (if changed value exist)

--Get the 2nd and 9th position from the results
results = gg.getResults()
if results ~= nil then
  	--Notice results[2] & results[9]
	specify = {results[2], results[9]}
	for k, v in ipairs(specify) do
		specify[k].value = '2400'
	end
	gg.setValues(specify)
end

--Eliminate changed values / refining
results = gg.getResults()
gg.refineNumber('2400', gg.TYPE_FLOAT)
Edited by MC874
  • 0
Posted (edited)
On 2/4/2024 at 1:30 AM, MC874 said:

Hi @MooExplosion,

gg.getResults() returns a table, and yes, you can specify which value to grab just by defining what index table that you want to get. So, you can either be specific or eliminate value to narrow it down (if changed value exist)

--Get the 2nd and 9th position from the results
results = gg.getResults()
if results ~= nil then
  	--Notice results[2] & results[9]
	specify = {results[2], results[9]}
	for k, v in ipairs(specify) do
		specify[k].value = '2400'
	end
	gg.setValues(specify)
end

--Eliminate changed values / refining
results = gg.getResults()
gg.refineNumber('2400', gg.TYPE_FLOAT)

Hello, @MC874. Thanks for the help. Sorry for the late reply. When I asked my previous question, I mistook refine for something else. Also, my values are DWORDs if that's important to mention.

I decided to check the gg class reference page but I wasn't able to tell what I needed. I got your provided code working somewhat however.

gg.searchNumber("1620;728;1620;728::13", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0x7801000000, 0x9014b5ffff, 0)
--Get the 2nd and 9th position from the results
results = gg.getResults(100)
if results ~= nil then
  	--Notice results[2] & results[9]
	specify = {results[1], results[3], results[5], results[7], results[9], results[11]}
	specifytwo = {results[2], results[4], results[6], results[8], results[10]}
	for k, v in ipairs(specify) do
		specify[k].value = '2400'
		specifytwo[k].value = '1080'
	end
	gg.setValues(specify)
	gg.setValues(specifytwo)
end

Sadly, I start getting an error after the first 5-6 times I exit, enter a dungeon and run the code from my testing. This is the error:

 

Script ended:

Script error: luaj.o: /storage/emulated/0/Notes/gamescript.lua:55

` specifytwo[k].value = '1080'`

table expected for set index ('value') value, got nil (field '?')

level = 1, const = 60, proto = 0, upval = 1, vars = 22, code = 144

SETTABLE v15 "value" "1080"

 ; PC 132 CODE 9C4E83CA OP 10 A 15 B 312 C 314 Bx 160058 sBx 28987

stack traceback:

 /storage/emulated/0/Notes/gamescript.lua:55 in main chunk

 [Java]: in ?

 at luaj.LuaValue.d(src:2795)

 at luaj.LuaValue.b(src:1123)

 at luaj.LuaClosure.a(src:383)

 at luaj.LuaClosure.l(src:160)

 at android.ext.Script.d(src:6056)

 at android.ext.Script$ScriptThread.run(src:5785)

 

Can I do anything about this?

 

Also, anyway to clean up what I'm currently using? I feel like adding multiple results might not be good because I don't always have the same amount of results. The width of that game's resolution is always even numbers and the height is always odd numbers in results when I use this script so I was wondering if I could take advantage of that.

Edited by MooExplosion
  • 0
Posted (edited)

Your Prompt Error ()

Use One Prompt And Edit It Using Table {}

 Or (secpify) do else (specifytwo )

Is it to  Change Value 1080;2400 by Choice  📁

Edited by Unknownharry
  • 0
Posted

@Unknownharry I can't figure out where to place the do else but I did manage to solve it by placing the specifytwo into a different script placing loadfile("storage/emulated/0/notes/script2.lua") at the end of the first script. I actually came here to make a comment mentioning that and then saw your message. I know my method probably isn't that great so I'd be open to hear how to do it the way you mentioned if you would be willing to give me more info(I'm a complete noob).

39 minutes ago, Unknownharry said:

Is it to  Change Value 1080;2400 by Choice  📁

Yes, it is. The game is capped to 720 by default for all or at least most android devices.

My script(or scripts) is finally one click runnable now(for now....). I guess I'll just try and see if I can clean up the script a bit more since it's a bit of spaghetti with how I handled it.

  • 0
Posted (edited)

Hi @MooExplosion, you're handling it incorrectly, the 'for'-loop is only enumerating 'specify' table and not 'specifytwo'

gg.searchNumber("1620;728;1620;728::13", gg.TYPE_DWORD)

results = gg.getResults(gg.getResultsCount())
if results ~= nil then
	specify = {results[1], results[3], results[5], results[7], results[9], results[11]}
	specifytwo = {results[2], results[4], results[6], results[8], results[10]}
	
	--Notice the bracket: (specify)
	for k, v in ipairs(specify) do
		specify[k].value = '2400'
		specifytwo[k].value = '1080'
	end
	for k, v in ipairs(specifytwo) do
		specifytwo[k].value = '1080'
	end

	gg.setValues(specify)
	gg.setValues(specifytwo)
end

/*********\
Since this is group searches, You can just refine the value first to specific value then change it all
Example 1:

--'d' suffix is for DWORD
gg.searchNumber('1620d;728d::5')
results = gg.getResults(gg.getResultsCount())

--Refining '1620' from result then change it to '2400'
gg.refineNumber('1620', gg.TYPE_DWORD)
gg.editAll('2400', gg.TYPE_DWORD)

--Reload results -> refine '728' -> Change it to '1080'
gg.loadResults(results)
gg.refineNumber('728', gg.TYPE_DWORD)
gg.editAll('1080', gg.TYPE_DWORD)
gg.clearResults()

Example 2:

--'d' suffix is for DWORD
gg.searchNumber('1620d;728d::5')
results = gg.getResults(gg.getResultsCount())

--Changing specific value from results
for k, v in ipairs(results) do
	if tonumber(v.value) == 1620 then
		results[k].value = 2400
	elseif tonumber(v.value) == 728 then
		results[k].value = 1080
	end
end

gg.setValues(results)

/*********\

Edited by MC874
fixed key value
  • 0
Posted (edited)

@MC874thanks for explaining. I actually tried duplicating the

for k, v in ipairs(specify) do

for the second part in one of my tries but it looks like I forgot to change (specify) to (specify2) like how you pointed out....

also didn't add the end and tried adding an else somewhere.

I was able to get the original code and example two you wrote working. I just changed the searchnurmbers because the 1620d;728d::5 variant gives me 50+ results while 1620;728;1620;728::13 variant gives me 4-12 results.

I however can't get your first example working. I just did two minor edits on it. Added a clear result at start and changed the searchnurmbers but I get a script error.

Your code with very minor edits:

gg.clearResults()
--'d' suffix is for DWORD
gg.searchNumber("1620d;728d;1620d;728d::13", gg.TYPE_AUTO, false, gg.SIGN_EQUAL, 0x7801000000, 0x8501000007, 0)
results = gg.getResults(gg.getResultsCount())
--Refining '1620' from result then change it to '2400'
gg.refineNumber('1620', gg.TYPE_DWORD)
gg.editAll('2400', gg.TYPE_DWORD)
--Reload results -> refine '728' -> Change it to '1080'
gg.loadResults(results)
gg.refineNumber('728', gg.TYPE_DWORD)
gg.editAll('1080', gg.TYPE_DWORD)

The script error:

Script ended:

Script error: luaj.o: /storage/emulated/0/Notes/test/more test/test2.lua:8

`gg.editAll('2400', gg.TYPE_DWORD)`

You must call gg.getResults before calling gg.editAll. (field 'editAll')

level = 1, const = 20, proto = 0, upval = 1, vars = 8, code = 51

CALL v0..v2

 ; PC 33 CODE 0180401D OP 29 A 0 B 3 C 1 Bx 1537 sBx -129534

stack traceback:

 /storage/emulated/0/Notes/gamename/more test/test2.lua:8 in main chunk

 [Java]: in ?

 at android.ext.Script$editAll.b(src:3704)

 at android.ext.Script$ApiFunction.a_(src:1393)

 at luaj.lib.VarArgFunction.a(src:62)

 at luaj.LuaClosure.a(src:535)

 at luaj.LuaClosure.l(src:160)

 at android.ext.Script.d(src:6056)

 at android.ext.Script$ScriptThread.run(src:5785)

I tried adding a gg.getResults before the editall but that didn't work either.

My question is however not a priority as my issue has already been solved(for now). I was just trying everything as I was a bit curious and wanted to clean things a bit. You example 2 seems to be exactly what I was looking for. I just made 2 minor edits(searchresults swap and clearResults at start) and am now using it.

Edited by MooExplosion
  • 0
Posted (edited)

If anybody is wondering why my script error has two different file paths, it's because I noticed I forgot to edit out the true file location when I sent it but it was still waiting for an approval from a mod. So, I edited it out. Then I noticed it wrote my file path a second time and edited that again but gave it a different edit by mistake. Now I can't edit that message anymore lol.

Edited by MooExplosion
Edited this because I accidentally sent before writing my whole comment....

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.