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 


Animation that plays before the form shows up

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

Joined: 02 Oct 2017
Posts: 39

PostPosted: Wed Nov 15, 2017 5:42 am    Post subject: Animation that plays before the form shows up Reply with quote

Hello guys!

I want to make a short animation (1-2second long), that plays before the trainer form shows up.
I already read some stuff about the animation, and how to make it work using a timer, but i dont know if it's possible to run it before the trainer shows up.
Any suggestions?
I tried to search for a thread or something related, but i can't find anything.

Thanks!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25281
Location: The netherlands

PostPosted: Wed Nov 15, 2017 7:13 am    Post subject: Reply with quote

create a new form (borderless, centered on the screen) with the animation in it.

when the last frame has been rendered (or after 2 seconds) hide/destroy that form, and show the trainer form

(So don't show the trainerform when it launches, show the animationform instead)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Gou
Cheater
Reputation: 0

Joined: 02 Oct 2017
Posts: 39

PostPosted: Wed Nov 15, 2017 10:52 pm    Post subject: Reply with quote

oh! That makes sense.
Thanks DB!
Back to top
View user's profile Send private message
Gou
Cheater
Reputation: 0

Joined: 02 Oct 2017
Posts: 39

PostPosted: Fri Nov 17, 2017 7:29 am    Post subject: Reply with quote

Hello once again Razz
I am trying to figure out how to hide the form when the last frame gets rendered, but i cant seem to figure it out. I used the timer from /viewtopic.php?t=579732 , and it works like a charm. But i cant figure out how to stop it..

From my understanding, some thing like
Code:
If frame == 30 then
     UDF1.Close()

should work. But it doesnt. It just keeps cycling through the frames.

Thanks once again, and sorry!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25281
Location: The netherlands

PostPosted: Fri Nov 17, 2017 7:58 am    Post subject: This post has 1 review(s) Reply with quote

add a showMessage() to see if your code gets executed (perhaps frame is never 30)

(and your animation form is called UDF1?l

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Gou
Cheater
Reputation: 0

Joined: 02 Oct 2017
Posts: 39

PostPosted: Fri Nov 17, 2017 9:20 am    Post subject: Reply with quote

I guess that you meant to add it in the if statement i mentioned. Well, it works and it displays my message. But not when frame_030 gets rendered. It shows up everytime i execute the code.
And yes, i didn't name the form(for now). I thought that i understand timers, but i guess not Razz

Here is the code
Code:

UDF1.Show();
playSound(findTableFile("test.wav"))

local ts,r=tostring,nil;
r = function(s,c,l)s,c,l=ts(s),ts(c),l+0;s=(#s<l and r(c..s,c,l) or s);return s;end; -- simple function to pad zeros
local main = UDF1.CEImage1; -- target
local fmin,fmax = 0,30; -- min frame, max frame
animation = animation or createTimer(getMainForm(),true);
animation.Interval = math.floor(1/30*1000); -- 30 fps
animation.onTimer = function (t)

   local tag,id = string.match(main.Hint,"(%a+)_(%d+)"); -- find frame and the number from Hint
   if (tag and id) then
      id = (id+0>=fmax and fmin or id+1);
   else
      tag,id = 'frame',0; -- hint is not set, so let's set it.
   end

   local frame = string.format('frame_%03d.gif',id) -- frame_001.gif for example
   main.Hint = frame; -- Storage.. lazy to use a variable;
   main.picture.loadFromStream(findTableFile(frame).stream); -- find table file and load it into the image object
end
   if frame == frame_030 then
      showMessage("works")
   end

UDF1.OnClose = function (sender)
    return caFree
end


Thanks once again
Back to top
View user's profile Send private message
Gou
Cheater
Reputation: 0

Joined: 02 Oct 2017
Posts: 39

PostPosted: Sat Nov 25, 2017 1:01 pm    Post subject: Reply with quote

Anyone? Very Happy Sorry for double posting
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sat Nov 25, 2017 2:38 pm    Post subject: Reply with quote

Gou wrote:
Well, it works and it displays my message. But not when frame_030 gets rendered. It shows up everytime i execute the code.

That's because you have something like this
Code:

animationForm.show()

-- setup animation timer that will start to change the image
animation.onTimer = function (t)
  ... -- change image
end

-- check if on frame_030
-- note the timer was just created, it may not have even had time to run yet
-- also using global 'frame' variable not the 'frame' variable created in the animation timer (which is "local" to that function)
if frame == frame_030 then
   showMessage("works")
end



put the check inside the timer so that it's checked when the frame is changed.
Back to top
View user's profile Send private message
Gou
Cheater
Reputation: 0

Joined: 02 Oct 2017
Posts: 39

PostPosted: Sat Nov 25, 2017 3:23 pm    Post subject: Reply with quote

Well, i feel stupid now. That makes sense. Thanks man!
Using showMessage ended up just spamming the string that i typed, but Close() seems to work fine.

This is the code right now, and it seems to work fine
Code:
UDF1.Show();

local ts,r=tostring,nil;
r = function(s,c,l)s,c,l=ts(s),ts(c),l+0;s=(#s<l and r(c..s,c,l) or s);return s;end; -- simple function to pad zeros
local main = UDF1.CEImage1; -- target
local fmin,fmax = 0,30; -- min frame, max frame
animation = animation or createTimer(getMainForm(),true);
animation.Interval = math.floor(1/30*1000); -- 30 fps
animation.onTimer = function (t)

   local tag,id = string.match(main.Hint,"(%a+)_(%d+)"); -- find frame and the number from Hint
   if (tag and id) then
      id = (id+0>=fmax and fmin or id+1);
   else
      tag,id = 'frame',0; -- hint is not set, so let's set it.
   end

   if id == 30 then
      UDF1.Close()
   end

   local frame = string.format('frame_%03d.gif',id) -- frame_001.gif for example
   main.Hint = frame; -- Storage.. lazy to use a variable;
   main.picture.loadFromStream(findTableFile(frame).stream); -- find table file and load it into the image object
end


UDF1.OnClose = function (sender)
    return caHide
end

Thanks once again!
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