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 


How to make a blinking effect with timer?

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

Joined: 17 Jan 2018
Posts: 205

PostPosted: Thu May 28, 2020 11:28 am    Post subject: How to make a blinking effect with timer? Reply with quote

How to change the font color of the label with one timer? To make a blinking effect between gray and white colors. The following code only changes to gray color.
Code:

  if UDF1.CELabel1.Font.Color == 0xFFFFFF then
  UDF1.CELabel1.Font.Color = 0x716D6C --gray
  elseif UDF1.CELabel1.Font.Color == 0x716D6C then
  UDF1.CELabel1.Font.Color = 0xFFFFFF --white
  end

Where is the mistake?


Last edited by Razi on Thu May 28, 2020 4:26 pm; edited 1 time in total
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1532

PostPosted: Thu May 28, 2020 12:23 pm    Post subject: Reply with quote

Code:
UDF1.CETimer1.Enabled=false
UDF1.CETimer1.Interval=300

UDF1.CETimer1.OnTimer=function()
if UDF1.CELabel1.Font.Color == 0x716D6C then --grey
UDF1.CELabel1.Font.Color = 0xFFFFFF --white
else
UDF1.CELabel1.Font.Color = 0x716D6C --grey
end
end

UDF1.CELabel1.OnClick=function()
if UDF1.CETimer1.Enabled==false then
UDF1.CETimer1.Enabled=true
else
UDF1.CETimer1.Enabled=false
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
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 205

PostPosted: Thu May 28, 2020 4:23 pm    Post subject: Reply with quote

Thanks for the answer. (Found mistake in the previous code.)
I have 3 labels with character names. When the character is selected, the label should blink in gray and white. The names of other characters must be white. When the character's hp is 0, then the label should be red.
Created the following code and it works, but maybe there is a better solution for this?
Code:
  namebattle = {}
for x = 0, 2 do
  namebattle[x] = UDF1["CELabel"..x+591]
end

timer = createTimer(nil,false)
timer.Interval = 1000
timer.OnTimer = function()

local selectedcharacter = readBytes(basaddr + 0x633A7C) -- value can be only 0,1,2

  for b = 0, 2 do
    local offs = basaddr + 0x5E9748 + b*0x440
    local hp = readInteger(offs)
    if hp == 0 then
    namebattle[b].Font.Color = 0x0209B7 --red
    else
    if selectedcharacter < 3 and b ~= selectedcharacter then
    namebattle[b].Font.Color = 0xFFFFFF --white
    end
    end
  end

  if selectedcharacter < 3 then
  if namebattle[selectedcharacter].Font.Color == 0xFFFFFF then
  namebattle[selectedcharacter].Font.Color = 0x716D6C --gray
  elseif namebattle[selectedcharacter].Font.Color == 0x716D6C then
  namebattle[selectedcharacter].Font.Color = 0xFFFFFF --white
  end
  end


end
timer.Enabled = true
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