Jump to content
  • 0

How to know the amount of string results


Platonic

Question

Hi, so the script is missing some algorithm. And i dunno how to apply it.

When searching for UTF16 string, the script must know how many times the string has been found. Currently i use refine on the 3 first chars of the string, then i refine the first and count how much results i have left. But refine only works in the perfect scenario. But if i had a string like "BoomBoom" the refine would be useless.

How to apply the proper algorithm so that i dont have to use refine to know how many times the string was found?

Here is the script:

function setNewName()
  local t = gg.getResults(gg.getResultsCount())
  local replaceString = {}
  local stringSize = {}
  local str = {}
  gg.clearResults()
  for i= 1, #editname[1] do
    str[i] = string.sub(editname[1], i, j)
  end
  for i, v in ipairs(t) do
    stringSize[#stringSize + 1] = {address = t[i].address - 0x4, flags = gg.TYPE_WORD, value = #editname[1]}
    for charCount = 1, #editname[1] do
      replaceString[#replaceString + 1] = {address = t[i].address, flags = gg.TYPE_WORD, value = string.byte(string.sub(str[charCount], 1, 1))}
      t[i].address = t[i].address + 2
    end
  end
  gg.setValues(replaceString)
  gg.setValues(stringSize)
end
function findName()
  gg.setRanges(gg.REGION_ANONYMOUS)
  gg.searchNumber(';'..playername[1])
  local a = gg.getResults(gg.getResultsCount())
  if #a == 0 then
    gg.toast("name not found, search again")
    prompt_search()
  else
    gg.refineNumber(a[1].value..';'..a[2].value..';'..a[3].value..'::5')
    gg.refineNumber(a[1].value)
  end
end

-- if menu is nil
function noselect()
  gg.toast('You not select anything')
end

function prompt_edit()
  editname = gg.prompt(
    {[1] = 'Input name to modify to'},
    {[1] = '0'},
    {[1] = 'text'})
  if editname == nil then noselect() else
    setNewName()
  end
end

function prompt_search()
  playername = gg.prompt(
    {[1] = 'Input desired player name.'},
    {[1] = '0'},
    {[1] = 'text'})
  if playername == nil then
    noselect()
  else
    findName()
    prompt_edit()
  end
end

prompt_search()
while (true) do
  if gg.isVisible() then
    gg.setVisible(false)
    prompt_search()
  end
  gg.sleep(100) 
end

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

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.