Jump to content
  • 0

How to offset calculator in lua script?


Josexdll
 Share

Question

I made my own lua script which is 

-- Define the address to search for (in hexadecimal format)
local targetAddressHex = "7AF6EF6780" -- Replace with your specific hexadecimal address

-- Convert the hexadecimal string to a number
local targetAddressNum = tonumber(targetAddressHex, 16)

-- Set the search parameters and search
gg.clearResults()
gg.searchNumber(targetAddressNum, gg.TYPE_QWORD, false, gg.SIGN_EQUAL, 0, -1)

-- Get the search results
local results = gg.getResults(500)

-- Add each result to the Game Guardian items list
gg.addListItems(results)

Which saves all found addresses as last step so i can do the text step i want which is offset calculation i do it with type float and value is 14. Anyway to do it with lua instead of keep doing manually every time?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 1

If what you mean is to add 0x14 to address of each found value and load the values to search results or saved list, then the following example based on your code shows how to do that: 

-- Define the address to search for (in hexadecimal format)
local targetAddressHex = "7AF6EF6780" -- Replace with your specific hexadecimal address

-- Set the search parameters and search
gg.clearResults()
gg.searchNumber(targetAddressHex .. "h", gg.TYPE_QWORD)

-- Get the search results
local results = gg.getResults(500)

-- Create table for target values from results by adding offset
local targetValues = {}
for i, v in ipairs(results) do
  targetValues[i] = {address = v.address + 0x14, flags = gg.TYPE_FLOAT}
end

gg.loadResults(targetValues) -- to set search results to target values
gg.addListItems(targetValues) -- to add target values to saved list
Link to comment
Share on other sites

  • 0
5 hours ago, CmP said:

If what you mean is to add 0x14 to address of each found value and load the values to search results or saved list, then the following example based on your code shows how to do that: 

-- Define the address to search for (in hexadecimal format)
local targetAddressHex = "7AF6EF6780" -- Replace with your specific hexadecimal address

-- Set the search parameters and search
gg.clearResults()
gg.searchNumber(targetAddressHex .. "h", gg.TYPE_QWORD)

-- Get the search results
local results = gg.getResults(500)

-- Create table for target values from results by adding offset
local targetValues = {}
for i, v in ipairs(results) do
  targetValues[i] = {address = v.address + 0x14, flags = gg.TYPE_FLOAT}
end

gg.loadResults(targetValues) -- to set search results to target values
gg.addListItems(targetValues) -- to add target values to saved list

You are a legend thanks. I thought there is no api for it

Link to comment
Share on other sites

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
 Share

×
×
  • 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.