Jump to content
  • 0

Question

Posted

hello its me again, i still couldnt find solution about comparing address and... changing the value.

the goal is to edit a value in each different address using offset,
before going to the code, let me give a briefing.

0x1234567C value 19 DWORD (address "C" is static, the rest always changing)
0x123456D8 value 19 DWORD (address "D8" is static, the rest always changing)

and here is my lua code, correct me please, i knew my code below is wrong.

gg.searchNumber("19",gg.TYPE_DWORD)
local t = gg.getResults(2)
for i, v in ipairs(t) do
	if v.address == "C" then
		local q = {}
		q[1].address = t[1].address + 0x2
		q[1].flags = 4                
		q[1].value = 2
		q[1].freeze = true
		q[1].name = 'ATK'
		q[2].address = t[1].address + 0x20
		q[2].flags = 4                
		q[2].value = 20
		q[2].freeze = true
		q[2].name = 'ATK SPD'
	end
	if v.address == "D8" then
		local q = {}
		q[1].address = t[1].address + 0x4
		q[1].flags = 4                
		q[1].value = 4
		q[1].freeze = true
		q[1].name = 'MOVE'
		q[2].address = t[1].address + 0x40
		q[2].flags = 4                
		q[2].value = 40
		q[2].freeze = true
		q[2].name = 'MOVE SPD'
	end
gg.setValues(q)
gg.addListItems(q)
end

 

2 answers to this question

Recommended Posts

  • 0
Posted
4 hours ago, chandelier said:

hello its me again, i still couldnt find solution about comparing address and... changing the value.

the goal is to edit a value in each different address using offset,
before going to the code, let me give a briefing.

0x1234567C value 19 DWORD (address "C" is static, the rest always changing)
0x123456D8 value 19 DWORD (address "D8" is static, the rest always changing)

and here is my lua code, correct me please, i knew my code below is wrong.

gg.searchNumber("19",gg.TYPE_DWORD)
local t = gg.getResults(2)
for i, v in ipairs(t) do
	if v.address == "C" then
		local q = {}
		q[1].address = t[1].address + 0x2
		q[1].flags = 4                
		q[1].value = 2
		q[1].freeze = true
		q[1].name = 'ATK'
		q[2].address = t[1].address + 0x20
		q[2].flags = 4                
		q[2].value = 20
		q[2].freeze = true
		q[2].name = 'ATK SPD'
	end
	if v.address == "D8" then
		local q = {}
		q[1].address = t[1].address + 0x4
		q[1].flags = 4                
		q[1].value = 4
		q[1].freeze = true
		q[1].name = 'MOVE'
		q[2].address = t[1].address + 0x40
		q[2].flags = 4                
		q[2].value = 40
		q[2].freeze = true
		q[2].name = 'MOVE SPD'
	end
gg.setValues(q)
gg.addListItems(q)
end

 

Address is probably a string. Maybe you want to check the string.sub() function ? 

https://www.lua.org/pil/20.html
https://stackoverflow.com/questions/45255696/extracting-the-last-n-characters-of-string-in-lua

  • 0
Posted

Use bitwise operators. To check that address ends with hexadecimal digit C

v.address & 0xF == 0xC

Similarly for D8: 

v.address & 0xFF == 0xD8

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.