Jump to content
  • 0

Does it possible to find text and replace with another text?


1001z

Question

Example In-game has:

Item name: Hello
Status: +7

Result should be:

Status: +7
Item name: Hello

My idea is find word with Item name: and find word with Status: then swap it

But I am not sure how to do correctly....
 

function getItemName()
	utf16 = false
	local bytes = parse("Item name:", 1, false)
	local len = #bytes
	gg.clearResults()
	local used = len
	if used > lim then used = lim end
	
	local search = tbl2hex(bytes)
	if used < len then search = search:sub(1, used*3) end
	gg.searchNumber('h '..search)
	
	local found = gg.getResultCount()
	local results = {}
	local count = 0
	local checked = 0
	while true do
		if checked >= found then
			break
		end
		local all = gg.getResults(100000)
		local total = #all
		local start = checked
		if checked + used > total then
			break
		end
		
		while start < total do		
			local good = true
			local offset = all[1 + start].address - 1
			if used < len then			
				local get = {}
				for i = lim + 1, len do
					get[i - lim] = {address = offset + i, flags = gg.TYPE_BYTE, value = 0}
				end
				get = gg.getValues(get)
				
				for i = lim + 1, len do
					if get[i - lim].value + 0 ~= bytes[i] then
						good = false
						break
					end
				end
			end
			if good then
				count = count + 1
				results[count] = offset
				checked = checked + used
			else
				local del = {}
				for i = 1, used do
					del[i] = all[i + start]
				end
				gg.removeResults(del)
			end
			start = start + used
		end
	end
	return results
end

local itemNameResult = getItemName()
-- SO HOW TO DO NEXT...

 

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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.