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 


Combo Box Lua (Goal: Same Index Selection No Sound)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
FIRESKY
Cheater
Reputation: 0

Joined: 01 Mar 2017
Posts: 34

PostPosted: Sun Apr 28, 2024 12:06 pm    Post subject: Combo Box Lua (Goal: Same Index Selection No Sound) Reply with quote

Hey guys, I was pondering a solution where:

1) I select a command line from the example combo box:
index == 2 then: -- > PLAY A SOUND

2) If I select "the same" command line from the ComboBox = this time i not want a SOUND WILL BE PLAYED AGAIN (Obviously until I change the selection from the combo box).

Ultimately the objective is to play a sound only if I select a different command line from the combo box,
obviously if from INDEX 2 I go back to INDEX 1 the sound must be played at least the first time from the selection


SCRIPT: Currently with this example obviously the sound is ok on the first selection but then it is disabled permanently... because something is needed to restore it if I change the selection index.


sound = 0



function CEComboBox1OnSelect(sender)

index = combobox_getItemIndex(CEtrainer_CTComboBox1);
if index == -1 then return end;



if index == 1 then
writeInteger("BLA BLA",tonumber("1"))
if sound == 0 then
playSound( findTableFile('music.wav') )
sound = 1
end


elseif index == 2 then
writeInteger("BLA BLA",tonumber("2"))
if sound == 0 then
playSound( findTableFile('music.wav') )
sound = 1
end


end
end

setMethodProperty(CEtrainer_CTComboBox1, "OnSelect", CEComboBox1OnSelect)
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 34

Joined: 16 Feb 2017
Posts: 1418

PostPosted: Sun Apr 28, 2024 12:58 pm    Post subject: Reply with quote

Code:
if frm1 then frm1.Destroy() frm1=nil end
frm1=createForm()

CEtrainer = {}
CEtrainer.CTComboBox1=createComboBox(frm1)
CEtrainer.CTComboBox1.Left=50
CEtrainer.CTComboBox1.Top=50
CEtrainer.CTComboBox1.ReadOnly=true
CEtrainer.CTComboBox1.Style='csDropDownList'

CEtrainer.CTComboBox1.Items.Add("select index")
CEtrainer.CTComboBox1.Items.Add("index 1")
CEtrainer.CTComboBox1.Items.Add("index 2")
CEtrainer.CTComboBox1.Items.Add("index 3")
CEtrainer.CTComboBox1.Items.Add("index 4")
CEtrainer.CTComboBox1.ItemIndex=0

local sound = 0
local sound2 = 0

CEtrainer.CTComboBox1.OnChange=function()
index = combobox_getItemIndex(CEtrainer_CTComboBox1);
if sound2==index then sound=1 else sound=0 end
  if index==1 then
    if sound==0 then
      print("play sound")
      sound=1
      sound2=index
    else
      print("No play sound!")
    end
  elseif index==2 then
    if sound==0 then
      print("play sound")
      sound=1
      sound2=index
    else
      print("No play sound!")
    end
  elseif index==3 then
    if sound==0 then
      print("play sound")
      sound=1
      sound2=index
    else
      print("No play sound!")
    end
  elseif index==4 then
    if sound==0 then
      print("play sound")
      sound=1
      sound2=index
    else
      print("No play sound!")
    end
  end
end


-- your code:
Code:
local sound = 0
local sound2 = 0

CEtrainer.CTComboBox1.OnChange=function()
index = combobox_getItemIndex(CEtrainer_CTComboBox1);
if sound2==index then sound=1 else sound=0 end
  if index==1 then
    if sound==0 then
      writeInteger("BLA BLA",tonumber("1"))
      playSound( findTableFile('music.wav'))
      sound=1
      sound2=index
    else
      writeInteger("BLA BLA",tonumber("1"))
    end
  elseif index==2 then
    if sound==0 then
      writeInteger("BLA BLA",tonumber("2"))
      playSound( findTableFile('music.wav'))
      sound=1
      sound2=index
    else
      writeInteger("BLA BLA",tonumber("2"))
    end
  end
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
FIRESKY
Cheater
Reputation: 0

Joined: 01 Mar 2017
Posts: 34

PostPosted: Sun Apr 28, 2024 10:24 pm    Post subject: Reply with quote

Hey AylinCE,
thanks for your time, honestly I had thought of something similar with a double sound that recalled the state of the index, excellent tip, I hope to be able to reciprocate in the future.
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