|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Razi Expert Cheater Reputation: 1
Joined: 17 Jan 2018 Posts: 205
|
Posted: Thu Mar 14, 2019 2:58 am Post subject: How to change picture with click of the button? |
|
|
How to change picture with click of the button?
3 pictures added with Table menu add an image file. Table created:
Code: | local picturestbl = { [1] = 'pict-1.gif', [2] = 'pict-2.gif', [3] = 'pict-3.gif' } |
How to change pictures with 2 buttons in the CEImage1? If CEButton1 is clicked, then show pict-1.gif, if CEButton2 is clicked, then show pict-2.gif.
How to change pictures with 2 buttons in the UDF1 form with same way?
Can you make a .CT file for example?
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 34
Joined: 16 Feb 2017 Posts: 1432
|
Posted: Thu Mar 14, 2019 4:22 am Post subject: Re: How to change picture with click of the button? |
|
|
Razi wrote: | How to change picture with click of the button?
3 pictures added with Table menu add an image file. Table created:
Code: | local picturestbl = { [1] = 'pict-1.gif', [2] = 'pict-2.gif', [3] = 'pict-3.gif' } |
How to change pictures with 2 buttons in the CEImage1? If CEButton1 is clicked, then show pict-1.gif, if CEButton2 is clicked, then show pict-2.gif.
How to change pictures with 2 buttons in the UDF1 form with same way?
Can you make a .CT file for example? |
CE still does not support .gif.
You should create a gif with the help of the following code.
How to:
1) .CT "Add File" (create gifi: split into .png and upload to CT)
2) Set picture names: (Example: There are 9 pictures ..
Names: frame_001 .. frame_002 .. frame_003 .. frame_009 etc. )
3) Process the image numbers in the code: For gif1: "for i = 1,9 do"
Example for gif2: "for i = 10,18 do"
4) Give ButtonClick approvals: "gif1.image.stretch = false
gif1.image.Visible = false "or gif2 etc.
Code: | function createGIF(form, width, top, frames, doCenter)
---- ImageGIF Code Creator: FreeER and Corroder Thanks to +1 Rep..
-------------------------------------------------------
local pics={}
for _,frame in pairs(frames) do
local pic
if frame.ClassName == 'TMemoryStream' then
pic = createPicture()
pic.loadFromStream(frame)
else -- first try to load as a tableFile then as a filepath
local file = findTableFile(frame)
if file then
pic = createPicture()
pic.loadFromStream(file.Stream)
else
-- loadFromFile doesn't report success, nor does the Picture object
-- have a way to check, so do it ourselves first.
local function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
if file_exists(frame) then
pic = createPicture()
pic.loadFromFile(frame)
end
end
end
-- if successfully loaded then add it
if pic then pics[#pics+1] = pic end
end
-- if we failed to load any frames
if #frames ~= 0 and #pics == 0 then return nil end
pics.currentPicture = 1
local mImage = createImage(form)
mImage.width = width
mImage.top = top
mImage.height = form.height
if doCenter then
mImage.left = (form.width-mImage.width) / 2
end
--mImage.stretch = true
local gif = {}
gif.image = mImage
gif.pics = pics
gif.next = function()
pics.currentPicture = (pics.currentPicture % #pics) + 1
mImage.Picture = pics[pics.currentPicture]
end
gif.timer = createTimer(mImage)
gif.timer.Interval = 3500 / #gif.pics -- frames per second
gif.timer.OnTimer = function(sender) gif.next() end
return gif
end
local frameNameFormat = 'frame_%03d.png'
-- create a gif with frames 1-14, dual flames
local t = {}
for i=1,14 do
t[i] = findTableFile(frameNameFormat:format(i)).Stream
end
gif1 = createGIF(UDF1, UDF1.width, 200, t, true)
-- create a gif with frames 21-38, rainbowy explosion
local t = {}
for i=15,29 do
t[#t+1] = findTableFile(frameNameFormat:format(i)).Stream
end
gif2 = createGIF(UDF2, 30, 30, t, true)
--------------------------------------------------
function CEButton2Click(sender)
gif1.image.stretch = false
gif2.image.stretch = false
gif1.image.Visible = false
gif2.image.Visible = false
end
function CEButton1Click(sender)
gif1.image.stretch = true
gif1.image.Visible = true
end
|
_________________
|
|
Back to top |
|
|
Razi Expert Cheater Reputation: 1
Joined: 17 Jan 2018 Posts: 205
|
Posted: Thu Mar 14, 2019 12:18 pm Post subject: |
|
|
@Corroder: Thank you
Is it possible to improve the following code?
Code: | picturestbl = {
{p_img='pict-1.gif'},
{p_img='pict-2.gif'},
{p_img='pict-3.gif'},
{p_img='pict-4.gif'},
{p_img='pict-5.gif'},
{p_img='pict-6.gif'},
{p_img='pict-7.gif'}
}
UDF1.CEImage1.Visible = false
UDF1.CEImage2.Visible = false
UDF1.CEImage3.Visible = false
UDF1.CEImage4.Visible = false
UDF1.CEImage5.Visible = false
UDF1.CEImage6.Visible = false
UDF1.CEImage7.Visible = false
UDF1.CEImage8.Visible = false
UDF1.CEImage9.Visible = false
UDF1.CEImage10.Visible = false
UDF1.CEImage11.Visible = false
UDF1.CEImage12.Visible = false
UDF1.CEImage13.Visible = false
UDF1.CEImage14.Visible = false
UDF1.CEImage15.Visible = false
UDF1.CEImage16.Visible = false
function picShow()
for x = 1, 16 do
local offset1 = (x-1) % 8
local offset11 = 0x84*((x-1) // 8)
local equippedwpn = readBytes(0x009E8640+offset11)
local offset2 = 0x2C*equippedwpn
local valuemat = readBytes(0x009BF7C0+offset1+offset2)
if valuemat == 1 then
index = picturestbl[1]
UDF1['CEImage'..x].Visible = true
UDF1['CEImage'..x].Picture.loadFromStream(findTableFile(index.p_img).Stream)
elseif valuemat == 2 then
index = picturestbl[2]
UDF1['CEImage'..x].Visible = true
UDF1['CEImage'..x].Picture.loadFromStream(findTableFile(index.p_img).Stream)
elseif valuemat == 3 then
index = picturestbl[3]
UDF1['CEImage'..x].Visible = true
UDF1['CEImage'..x].Picture.loadFromStream(findTableFile(index.p_img).Stream)
elseif valuemat == 5 then
index = picturestbl[5]
UDF1['CEImage'..x].Visible = true
UDF1['CEImage'..x].Picture.loadFromStream(findTableFile(index.p_img).Stream)
elseif valuemat == 6 then
index = picturestbl[6]
UDF1['CEImage'..x].Visible = true
UDF1['CEImage'..x].Picture.loadFromStream(findTableFile(index.p_img).Stream)
elseif valuemat == 7 then
index = picturestbl[7]
UDF1['CEImage'..x].Visible = true
UDF1['CEImage'..x].Picture.loadFromStream(findTableFile(index.p_img).Stream)
elseif valuemat == 0 then
UDF1['CEImage'..x].Visible = false
elseif valuemat == nil then
UDF1['CEImage'..x].Visible = false
end
end
end
UDF1.Show()
UDF1.CEButton1.onClick = picShow |
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Thu Mar 14, 2019 7:40 pm Post subject: |
|
|
Code: | Is it possible to improve the following code? |
1. You have 7 pictures on the table but make 16 CEImage objects. Are you sure need 16 images on your form?
2. This code
Code: | for x = 1, 16 do
local offset1 = (x-1) % 8
local offset11 = 0x84*((x-1) // 8)
local equippedwpn = readBytes(0x009E8640+offset11)
local offset2 = 0x2C*equippedwpn
local valuemat = readBytes(0x009BF7C0+offset1+offset2)
..
..
end |
Are you sure 'valuemat' value contains the number 1 to 7 ?. Not numbers with a decimal point or string or others except an integer?
If yes, then perhaps change to something like this :
Code: | for x = 1, 16 do
local offset1 = (x-1) % 8
local offset11 = 0x84*((x-1) // 8)
local equippedwpn = readBytes(0x009E8640+offset11)
local offset2 = 0x2C*equippedwpn
local valuemat = readBytes(0x009BF7C0+offset1+offset2)
index = picturestbl[valuemat]
UDF1.CEImage1.Visible = true
UDF1.CEImage1.Picture.loadFromStream(findTableFile(index.p_img).Stream)
..
..
end
|
Anyhow, I still doubt if need a looping by use for...end.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
Razi Expert Cheater Reputation: 1
Joined: 17 Jan 2018 Posts: 205
|
Posted: Fri Mar 15, 2019 3:41 am Post subject: |
|
|
Corroder wrote: |
1. You have 7 pictures on the table but make 16 CEImage objects. Are you sure need 16 images on your form?
2.Are you sure 'valuemat' value contains the number 1 to 7 ?. Not numbers with a decimal point or string or others except an integer?
Anyhow, I still doubt if need a looping by use for...end. |
1. The form should have 144 CEImage objects.
2. The 'valuemat' value always contains a number from 0 to 7, if the address contains a value 1-7, then this is a picture, if the address contains a value of 0, then there is no picture.
The following code works correctly. Thanks for the help.
Code: | picturestbl = {
{p_img='pict-1.gif'},
{p_img='pict-2.gif'},
{p_img='pict-3.gif'},
{p_img='pict-4.gif'},
{p_img='pict-5.gif'},
{p_img='pict-6.gif'},
{p_img='pict-7.gif'}
}
for x = 1, 16 do
UDF1['CEImage'..x].Visible = false
end
function picShow()
for x = 1, 16 do
UDF1['CEImage'..x].Visible = false
local offset1 = (x-1) % 8
local offset11 = 0x84*((x-1) // 8)
local equippedwpn = readBytes(0x009E8640+offset11)
local offset2 = 0x2C*equippedwpn
local valuemat = readBytes(0x009BF7C0+offset1+offset2)
if valuemat > 0 then
index = picturestbl[valuemat]
UDF1['CEImage'..x].Visible = true
UDF1['CEImage'..x].Picture.loadFromStream(findTableFile(index.p_img).Stream)
elseif valuemat == 0 then
UDF1['CEImage'..x].Visible = false
elseif valuemat == nil then
UDF1['CEImage'..x].Visible = false
end
end
end
UDF1.Show()
UDF1.CEButton1.onClick = picShow |
Can we put or draw two pictures in one CEImage1 and place them in different places? (Something like a combination of pictures in one CEImage1)
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Sat Mar 16, 2019 1:50 am Post subject: |
|
|
Quote: | Can we put or draw two pictures in one CEImage1 and place them in different places? (Something like a combination of pictures in one CEImage1) |
Maybe, need to know how to fill canvas drawn by a stream image file.
Something like 'Canvas.Brush / Canvas.fillRect / etc'
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
|
|
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
|
|