Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Can't make nextScan work correctly

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
TAImatem
How do I cheat?
Reputation: 0

Joined: 26 Mar 2019
Posts: 1

PostPosted: Tue Mar 26, 2019 9:10 am    Post subject: Can't make nextScan work correctly Reply with quote

So, I wanted to make a script for RPG maker that would find value's addresses by utilizing RGSSEval function from RGSS dll file
firstScan works correctly, but whenever I do nextScan it does all of the below:
1.doesn't filter out invalid addresses (so it becomes like Found:3(shown:139))
2.doesn't do exact value scan correctly (as in Found become 0), even though findValue was set correctly (compared to what is shown at foundList)

here's some explanation:
com is variable's name written in RGSS (e.g. '$Player.money')
Value is initial variable's value
dType is data type

RgssSetVal sets the variable to val

RgssSearchTimerSt launches first scan, puts memscan, foundlist, Value, dType, com into global variables, and starts a timer with RgssReSearch attached

RgssReSearch launches next scans, and then changes the variable

UPD: tried converting findValue to string using string.format, didn't work either

Code:

globValue = nil
globdType = nil
globcom = nil
prevcount = nil
globiter = nil
tempVal = nil
foundlist = nil
memscan = nil
prevVal = nil

function RgssReSearch(MyTimer)
         Value =globValue
         dType = globdType
         com = globcom
         addressList = getAddressList()
         if (type(com) == "string")and(memscan~=nil) then
                    print (string.format('%s=%i',com,tempVal))
                    local findValue = tempVal*2 + 1 --calculates the findValue from tempVal (given by previous iterations, including one with firstScan)
                    print (string.format('=%i',findValue))
                    foundlist.deinitialize()
                    memscan.nextScan(soExactValue, vtDword, rtTruncated, findValue, nil,
                    false, true, false, false,false) -- nextScan itself
                    prevVal = findValue
                    memscan.waitTillDone()
                    foundlist.initialize()
                    print (foundlist.Count)
                    globiter=globiter - 1
                    if (foundlist.Count<2 or globiter<=0) then
                        RgssSetVal(com,Value)
                    else
                        tempVal = math.random(0,math.max(tonumber(Value,10),100))
                        print (string.format('%s=%i',com,tempVal))
                        RgssSetVal(com,tempVal) --updates the variable with random number
                    end
         end
end

function RgssSearchTimerSt(Value,dType,com)
         globValue = Value
         globdType = dType
         globcom = com
         addressList = getAddressList()
         math.randomseed(os.clock())
         if (type(com) == "string")and(addressList.getMemoryRecordByDescription('script_INIT').Active) then
             if dType==0 then
             elseif dType==1 then
                    memscan = getCurrentMemscan()
                    foundlist = createFoundList(memscan)
                    protectionflags = "*W-X-C"
                    tempVal =tonumber(Value,10)
                    local findValue = tempVal*2 + 1
                    prevVal = findValue
                    memscan.firstScan(soExactValue, vtDword, rtTruncated, findValue, nil,
                    "03ffffff","12ffffff",protectionflags,fsmAligned,"4",
                    false, true, false, false)
                    memscan.waitTillDone()
                    globiter = 4
             elseif dType==2 then
             elseif dType==3 then
             elseif dType==4 then
             end
         end
         foundlist.initialize()
         if (foundlist.Count<2) then
            for i = 1, foundlist.Count, 1 do
                addressList.createMemoryRecord()
                addressList.MemoryRecord[addressList.getCount()-1].Address = foundlist.Address[i-1]
            end
            foundlist.deinitialize()
            memscan.newScan()
            foundlist.initialize()
         else
             RgssTimer = createTimer(nil,false)
             RgssTimer.Interval = 5000
             RgssTimer.OnTimer = RgssReSearch
             RgssTimer.enabled = true
         end
end
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites