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 


Need help with running Wav files under conditions

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

Joined: 14 Apr 2018
Posts: 8

PostPosted: Sat Jun 23, 2018 8:55 pm    Post subject: Need help with running Wav files under conditions Reply with quote

I would if it's possible to create a script to where if an address or two get a certain value (condition), Cheat Engine would play a sound from a file I have.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sat Jun 23, 2018 9:32 pm    Post subject: Reply with quote

sure, there's various ways but something like this may be the most generic
Code:
soundCheckMemrecs = {
  AddressList.getMemoryRecordByID('name/desc of memory record with address'),
}
soundCheckValues = {
  '100', -- strings because that's how memrec exposes the values
}
local thewav = ... -- tablefile from findTableFile or a stream containing wav data
function doCheck()
  if #soundCheckMemrecs ~= #soundCheckValues then error('num memrecs do not match num values!') end
  for i,mr in ipairs(soundCheckMemrecs) do
    if mr.Value ~= soundCheckValues[i] then
      return false -- quit checking
    end
  end
  -- otherwise we did not leave the function so everything matched
  playSound(thewav)
  -- potentially change interval to delay next check
end

-- create timer to continuously check
soundTimer = createTimer()
soundTimer.Interval = getUpdateTimer().Interval
soundTimer.OnTimer = doCheck

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
TheRunner
How do I cheat?
Reputation: 0

Joined: 14 Apr 2018
Posts: 8

PostPosted: Sun Jun 24, 2018 12:51 pm    Post subject: Reply with quote

I am really new to this. I hope you could help me by putting an example for this to work. For example I want it to be turned on when the address 209A80EF gets the value 73. Could you please built the script with this? It could help me know where do I insert these addresses and values for this to work. Thanks in advance for the help.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Jun 24, 2018 1:24 pm    Post subject: Reply with quote

Then add the address 209A80EF to the address list and name it "name/desc of memory record with address" without quotes (or change that in the code to whatever you name it), and change the 100 in the values table to 73.

set thewav to findTableFile('Activate') for testing, CE automatically adds Activate and Deactivate sounds

Then run the lua code

_________________
https://github.com/FreeER/ has a few CE related repos
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