Jump to content
  • 0

Command to access "go to" button's results in making a lua script


Stone66

Question

Hi I'm new in making lua script, I am using anonymous region for searching this float value "0.93969261646" then there would be 12-13 results. If it gives me 12 results I choose the last address, and if it gives me 13 results I choose the first address to show me these three 1.0 ordered float values by using the "go to" option then change the value of the third address to 1.5. My question is how do I make this into a lua script? I keep on searching what command to open that "go to" button then change the value but I can't seem to search the right question.

Screenshot_20220114-175432~2.png

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

--function to check value with offset and store correct ones in new table. same as checking with goto.

function checkValueWithOffset(Table, Offset, Type, Value)

  local t, check = {}, {}

  for i, v in ipairs(Table) do

    check[i] = {address=v.address+Offset, flags=Type}

  end

  local check = gg.getValues(check)

  for i, v in ipairs(check) do

    if v.value==Value then t[#t=1]=Table[i] end

  end

  return t

end

 

--function to modify values with offset

function editValueWithOffset(Table, Offset, Type, Value, Freeze)

  local t={}

  for i, v in ipairs(Table) do

    t[i]={address=v.address+Offset, flags=Type, value=Value, freeze=Freeze}

  end

  gg.setValues(t)

  if Freeze then gg.addListItems(t) end

end

 

gg.clearResults()

gg.setRanges(gg.REGION_ANONYMOUS)

gg.searchNumber('0.93969261646', gg.TYPE_FLOAT)

local res, realOnes = gg.getResults(999), {}

if #res==12 then

  table.insert(realOnes, res[12])

elseif #res==13 then

  res = checkValueWithOffset(res, 0x4, gg.TYPE_FLOAT, 1)

  res = checkValueWithOffset(res, 0x8, gg.TYPE_FLOAT, 1)

  realOnes = checkValueWithOffset(res, 0xc, gg.TYPE_FLOAT, 1)

else

  gg.loadResults(res)

  print("Something was wrong. check your values again")

  os.exit()

end

 

editValueWithOffset(realOnes, 0xc, gg.TYPE_FLOAT, 1.5)

print("Success")

I give credit to CmP for above function codes.

Link to comment
Share on other sites

On 1/14/2022 at 3:48 AM, Stone66 said:

Hi I'm new in making lua script, I am using anonymous region for searching this float value "0.93969261646" then there would be 12-13 results. If it gives me 12 results I choose the last address, and if it gives me 13 results I choose the first address to show me these three 1.0 ordered float values by using the "go to" option then change the value of the third address to 1.5. My question is how do I make this into a lua script? I keep on searching what command to open that "go to" button then change the value but I can't seem to search the right question.

Screenshot_20220114-175432~2.png

This should work for you, let me know if it doesnt

gg.getRanges(gg.REGION_ANONYMOUS)
gg.clearResults()
gg.searchNumber("0.93969261646", gg.TYPE_FLOAT)
local result = gg.getResults(gg.getResultsCount())--gets all search results
local start_address = 0

if gg.getResultsCount() == 12 then --if 12 results then set starting address to last result
    start_address = result[12].address
elseif gg.getResultsCount() == 13 then --if 13 results then set starting address to first  result
    start_address = result[1].address
end

--create table of addresses, flag types and values to be set
if start_address~= 0 then --checks if start_address has been set
    local edit_address = {
        [1] = {
            address = start_address + 12, --add offset from start_address to address you wish to edit
            flags = gg.TYPE_FLOAT,
            value = Your_New_Float_Value_Here
        }
    }
    gg.setValues(edit_address) --sets the values designated in your edit_address table
end

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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