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 


Conditional Value Change & AOB Values
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Sat Sep 04, 2021 11:53 am    Post subject: Reply with quote

@ParkourPenguin does the best scolding. So much so that you sit and cry.
Then you'll regret not checking your code twice.

@Parkour always catches you. Crying or Very sad Cool
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sat Sep 04, 2021 12:02 pm    Post subject: Reply with quote

ByTransient wrote:
@ParkourPenguin does the best scolding. So much so that you sit and cry.
Then you'll regret not checking your code twice.

@Parkour always catches you. Crying or Very sad Cool


It's fine, I am not offended or hurt by any means. I like to learn and if I am shown a better way of doing things then I am grateful for that.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Sat Sep 04, 2021 12:33 pm    Post subject: Reply with quote

I don't intend to insult or belittle anyone for trying to help others. I try to test my code before posting it online and think others should too.

I still miss stuff like readByte (haven't installed CE 7.3 yet).

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sat Sep 04, 2021 1:15 pm    Post subject: Reply with quote

ParkourPenguin wrote:
I don't intend to insult or belittle anyone for trying to help others. I try to test my code before posting it online and think others should too.


Something I wholly appreciate. When people that have experience with skills show people the right way helps immensely.
Back to top
View user's profile Send private message
Cissamannen
Cheater
Reputation: 0

Joined: 16 Jul 2009
Posts: 36

PostPosted: Sat Sep 04, 2021 3:35 pm    Post subject: Reply with quote

Birdi wrote:
I tried to help externally a couple days ago, but after a few hours went to bed and just got back to see if any progress was made.. I'm definitely not an expert but I try, anyway. My attempts were successful but catching an edge case completely broke it for seemingly no reason.. when I'm home I can post the excerpts and maybe get some insight there. I knew about the extra parameters of AOBscan but tried a different method of getting last digits and that was what likely broke it all. I planned on amending my function to include it but time is always a factor.
Tba


Yeah that was baffling. Considering it also worked once, but then failed on restart Shocked
The first you posted worked wonders still!

I've been out all day and will mess about a bit again in the morning after reasing through some tips here.

Getting that conditional one to work properly would be helpful in more than just this game too. Im guessing running it in main table is still better if having an enable/disable script entry as suggested by LeFixer so i can use it for several different 'cheat entries' using the same conditional check?

And regarding the readByte i upgraded to 7.3 myself while testing the codes, and noticed myself at first it was not highlighted in the code until the version upgrade. But that made me kind of unsure if readByte and readBytes would give the same effect.
So to be clear, from what i understood, if doing readBytes(address,2) would give 2 value results, and not the same as readSmallInteger? If so, would readByte(address) and readBytes(address,1) give same result?

P.S: Mr Penguin's way of being direct is much better than walking on eggshells!
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Sat Sep 04, 2021 4:21 pm    Post subject: Reply with quote

Cissamannen wrote:
if doing readBytes(address,2) would give 2 value results, and not the same as readSmallInteger?

Attach to the CE tutorial (or anything really) and play around with this:
Code:
autoAssemble[[
globalalloc(foo,4096)
foo:
  db 10 27
]]

local b1, b2 = readBytes('foo',2)
print('bytes:', b1, b2)

local s1 = readSmallInteger('foo')
print('short:', s1)

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Birdi
Expert Cheater
Reputation: 0

Joined: 08 Jun 2020
Posts: 122
Location: Migrating

PostPosted: Sat Sep 04, 2021 7:50 pm    Post subject: Reply with quote

The working non-edge case solution:
Code:

function scanAndSet(aob,memrec)
  local aobresult=AOBScan(aob)
  if (aobresult~=nil) then
    for i=0,aobresult.Count-1 do
      local cAddress = tostring(aobresult[i])
      if string.len(cAddress) == 8 then --check if the address is 8 characters long - physical memory is 9
        if string.sub(cAddress, 1, 1) == "0" then --check if the address begins with 0
          dynamicAddress = aobresult[i]
          --print(dynamicAddress)
          setAddress(memrec)
        end
      end
    end
  end
end
function setAddress(memrec)
  local al = getAddressList()
  for i=0,al.Count-1 do
    if al[i].Description == memrec then
      al[i].Address = dynamicAddress
    end
  end
end


We next tried adding in the last 4 digits of the physical address to compare against any of the valid editable addresses, because we couldn't edit the physical address even with Fullaccess(). The regular dynamic address worked anyway, so that was the goal. Attempting to read the 9-long address to get the last four digits was the goal, and that worked fine.. but subsequently AOBScanning only returned the first result out of the generated table, no matter how I did it.

This was the final attempt:
Code:

if syntaxcheck then return end
function scanAndSet(aob,memrec,debug)
  local aobR1 = AOBScan(aob)
  local aobR2 = AOBScan(aob)
  if (aobR1~=nil) then
    getUOff(aobR2,debug)
    getReal(aobR1,debug)
  end
end

function setAddress(memrec)
  local al = getAddressList()
  for i=0,al.Count-1 do
    if al[i].Description == memrec then
      al[i].Address = dynamicAddress
    end
  end
end

function getUOff(address,debug)
  for i=0,address.Count-1 do
    local cA = tostring(address[i])
    if string.len(cA) == 9 then
      cOffset = string.sub(cA, -4)
      if debug == true then
        print("cOffset successfully found: "..cOffset)
      end
      break
    end
  end
end

function getReal(address,debug)
  for i=0,address.Count-1 do
    local e = i+1
    local cAddress = tostring(address[i])
    local cLen = string.len(cAddress)
    local cFC = string.sub(cAddress, 1, 1)
    local cO = string.sub(caddress, -4)
    if debug == true then
      print("     Current Result (Address): "..address[i].." | address["..e.."]")
      print("     Current Result (String): "..tostring(address[i]).." | cAddress")
      print("     Current Result (Length): "..cLen.." | cLen")
      print("     Current Result (First Character): "..cFC.." | cFC")
      print("     Current Result (Offset): "..cO.." | cO")
    end
  end
end

scanAndSet("80 10 20 B7 22 AE","No Random Battles (Everywhere Else)",true)


My only guess is that using AOBScan removes the same possible results from being found, but that didn't quite make sense to me. Even if I copied aobR1 into aobR2 it would only print the first result, with a different set of debug prints.. I gave up in the end.
Obviously just using the rest of the AOBScan parameters to get the final digits would be best, but I wanted to make this work out of stubbornness by the end lol

_________________
Trying to learn!

Add me on Discord if you want hands-on help: Birdi#0007
Back to top
View user's profile Send private message Visit poster's website
Cissamannen
Cheater
Reputation: 0

Joined: 16 Jul 2009
Posts: 36

PostPosted: Sun Sep 05, 2021 1:02 am    Post subject: Reply with quote

Thanks Parkour, that shed some light on it very well! Very Happy

Another question that goes into the timer on the conditional code.
The timer I have enable script for, and added to main lua, is running fine. Its the cheat itself for changing value based on that only runs once, because theres no loop.
So can there be a timer made for several cheat entries, by say giving them different names without causing conflict of ones already running? Example:
tmrInBattle = createTimer(MainForm, false)
valTimer= createTimer(MainForm, false)

If there is only 1 global timer that can be ran, is there a way to add a check into a cheat by using said created timer? As I tested using 2 different timer names, but it would permanently set the first enabled of the cheats as permanently activated until I closed and re-opened CE again, whereas the second cheat could be enabled/disabled normally.
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sun Sep 05, 2021 6:35 am    Post subject: Reply with quote

You can have as many timers as you like, within reason. I feel I am not qualified enough to give you the answer you require so I will just advise where I can.
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
Goto page Previous  1, 2, 3
Page 3 of 3

 
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