Change Images By Timer

Anything Cheat Engine related, bugs, suggestions, helping others, etc..
Post Reply
User avatar
corroder
Novice Cheater
Novice Cheater
Posts: 17
Joined: Fri Mar 03, 2017 1:54 am
Reputation: 1

Change Images By Timer

Post by corroder »

Hi, how do this :

First try : (stupid way)

Code: Select all

f = createForm()
f.Width = 500
f.Height = 500
i1 = createImage(f)
i1.Width = 500
i1.Height = 500
i1.Stretch = true
i1.Picture.loadFromStream(findTableFile('mainWall.jpg').Stream)

t_index = 1
counter = 3
c=createTimer(nil)
c.Interval= 5000
c.OnTimer=function(c)
 if t_index <= counter then
  i1.Picture.loadFromStream(findTableFile('mainWall1.jpg').Stream)
  t_index = t_index + 1
 else
  i1.Picture.loadFromStream(findTableFile('mainWall2.jpg').Stream)
  t_index = 1
 end
end
c.Enabled=true

function closeGLP()
 c.destroy()
 closeCE()
 return caFree
end

f.onClose = closeGLP
f.show()

-- result : Images change as timer provided, but only display 2 images from 3 images want to show

Second way : more than stupid, it's a dumb way

Code: Select all

t = {}
t[1] = 'mainWall.jpg'
t[2] = 'mainWall1.jpg'
t[3] = 'mainWall2.jpg'
t[4] = 'mainWall3.jpg'

f = createForm()
f.Width = 400
f.Height = 400
img = createImage(f)
img.Width = 400
img.Height = 400
img.Stretch = true

timer=createTimer(nil, false)
timer.Interval=3000
timer.OnTimer=function(timer)
for i=1, 4 do
 img.Picture.loadFromStream(findTableFile(t[i]).Stream)
 i=i+1
end
end
timer.Enabled=true

result : only image t[4] shown
How do 2nd way in smart way ?

Thanks

Eric
Hall of Famer
Hall of Famer
Posts: 174
Joined: Thu Mar 02, 2017 11:01 pm
Reputation: 90

Re: Change Images By Timer

Post by Eric »

Code: Select all

t = {}
t[1] = 'mainWall.jpg'
t[2] = 'mainWall1.jpg'
t[3] = 'mainWall2.jpg'
t[4] = 'mainWall3.jpg'

pics={}
for i=1,4 do
  pics[i]=createPicture()
  pics[i].loadFromStream(findTableFile(t[i]).Stream)
end


f = createForm()
f.Width = 400
f.Height = 400
img = createImage(f)
img.Width = 400
img.Height = 400
img.Stretch = true

pics.currentPicture=1

timer=createTimer(f, false)
timer.Interval=3000
timer.OnTimer=function(timer)
  img.Picture=pics[pics.currentPicture] --same as img.Picture.assign(pics[pics.currentPicture])
  pics.currentPicture=(pics.currentPicture % 4)+1
end
timer.Enabled=true

User avatar
corroder
Novice Cheater
Novice Cheater
Posts: 17
Joined: Fri Mar 03, 2017 1:54 am
Reputation: 1

Re: Change Images By Timer

Post by corroder »

Eric wrote:
Thu Mar 09, 2017 2:00 pm

Code: Select all

t = {}
t[1] = 'mainWall.jpg'
t[2] = 'mainWall1.jpg'
t[3] = 'mainWall2.jpg'
t[4] = 'mainWall3.jpg'

pics={}
for i=1,4 do
  pics[i]=createPicture()
  pics[i].loadFromStream(findTableFile(t[i]).Stream)
end


f = createForm()
f.Width = 400
f.Height = 400
img = createImage(f)
img.Width = 400
img.Height = 400
img.Stretch = true

pics.currentPicture=1

timer=createTimer(f, false)
timer.Interval=3000
timer.OnTimer=function(timer)
  img.Picture=pics[pics.currentPicture] --same as img.Picture.assign(pics[pics.currentPicture])
  pics.currentPicture=(pics.currentPicture % 4)+1
end
timer.Enabled=true
Well done, work proper;y without issue.
Thanks so much Eric..

Regards

Post Reply

Who is online

Users browsing this forum: No registered users