Looks like I've finally (kind of) figured it out. I think part of what I was doing wrong was not initializing a[2] as a table, and trying to do the math to change the address while defining it. I'm sure there's a far simpler way to achieve what I was trying to do, but having created my first successful GG script I feel pleased ?
if gg.isVisible() then gg.setVisible(false) end
newgame = gg.alert('Have you restarted the level?', 'Yes', 'No')
if newgame == 2 then
gg.toast.('Start fresh and try again!'
os.exit()
end
--initial search
gg.processPause()
gg.searchNumber('0', gg.TYPE_DWORD, false, gg.SIGN_EQUAL)
gg.toast('Results: '..gg.getResultCount())
gg.processResume()
while gg.getResultCount() > 1 do
gg.toast('Cause an accident!')
gg.sleep(5000)
gg.processPause()
acc = gg.alert('Did you crash some vehichles?', 'Yes', 'No')
if acc == 2 then
gg.searchFuzzy()
else
gg.searchFuzzy('0', gg.SIGN_FUZZY_LESS)
end
gg.processResume()
end
--[[
if gg.getResultCount() <10 then
while gg.getResultCount() > 1 do
gg.searchNumber('0~-10000', gg.TYPE_DWORD, false, gg.SIGN_EQUAL)
end
end
]]--
gg.toast('Results narrowed to: '.. gg.getResultCount())
a = gg.getResults(1)
a[1].value = '0'
a[1].freeze = true
cn = a[1].address - 4
rn = a[1].address + 4
c = {}
c[1] = {}
c[1].flags = gg.TYPE_DWORD
c[1].address = cn
c[1].value = '85'
c[1].freeze = true
c[1].freezeType = gg.FREEZE_MAY_INCREASE
c[2] = {}
c[2].flags = gg.TYPE_DWORD
c[2].address = rn
c[2].value = '0'
c[2].freeze = true
c[2].freezeType = gg.FREEZE_NORMAL
gg.addListItems(a)
gg.addListItems(c)
print('Cars: '..c[1].address)
print('Traffic: '..c[2].address)
--gg.clearResults()
One thing I can't figure out is how to filter results by value. I tried searching by number after the fuzzy search, for anything between 0 to -10000(like the searchNumber() examples show for positive numbers) using SIGN_EQUAL or SIGN_GREATER but it kept getting stuck in the while loop with two results, the desired one and one that was always around -1,000,000 which I was hoping to filter out.
Thanks again for your help, and all of your dedication to this project, it's greatly appreciated!