|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sat Jan 07, 2017 11:59 pm Post subject: Unfinish Project - Change Image Via Button Click (sender) |
|
|
Hi again...
I am trying make a function button click (sender)
Code: | function createPictureImg(data)
local picture = createPicture()
local stream = createStringStream(data)
picture.loadFromStream(stream)
return picture
end
function Btn_ChangeImageClick(sender)
path = UDF2.Edit_ImageFile.Text
file = io.open(string.format(path), "rb")
image = file:read("*a")
if image == nil then
image = createImage(UDF1)
end
if picture == nil then
picture = createPictureImg(image)
UDF1.Trainer_Img.Picture = picture
end
end |
Script above about :
1. Change UDF1.Trainer_Img.Picture by an image file given by user via text box
2. Script above has work
Problem :
1. Script above worked just one time. If user give image file path for second or third times, it's not work (UDF1.Trainer_Img.Picture not change)
2. Need parameters for - if file not found and or file is not an image file
3. Need get UDF1.Trainer_Img picture variable / bitmap first, to store to a variable (or file?) which will loading / calling to set UDF1.Trainer_Img picture as default when user clicking a Reset Button.
Other case :
How to save the trainer as a new table / new file after made some changes on variables. class, hack code, etc on the trainer it self which changes done through a "form trainer control" and not through normal edting Lua Script Table?.
Thank you for helps and solutions..
Description: |
|
Filesize: |
162.07 KB |
Viewed: |
8012 Time(s) |
|
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Sun Jan 08, 2017 3:36 am Post subject: |
|
|
1:
If picture exist then you never create a new picture, and never assign it to UDF1.Trainer_Img.Picture
1+2:
Code: |
function createPictureImg(data)
local picture = createPicture()
local stream = createStringStream(data)
picture.loadFromStream(stream)
stream.destroy()
return picture
end
function Btn_ChangeImageClick(sender)
path = UDF2.Edit_ImageFile.Text
file = io.open(string.format(path), "rb")
image = file:read("*a")
if image == nil then
showMessage('Invalid pacture')
return
end
--todo: check image if it's a valid image. (e.g check the header or something, I don't know)
UDF1.Trainer_Img.Picture=createPictureImg(image)
end
|
3:
Just put in any image in your tablefile list and use that image (use the stream of the tablefile for the picture object)
Once loaded, destroy the tablefile (for your other question down)
Quote: |
Other case :
How to save the trainer as a new table / new file after made some changes on variables. class, hack code, etc on the trainer it self which changes done through a "form trainer control" and not through normal edting Lua Script Table?.
|
I recommend just writing the .CT using pure text and tell your user to save that as .EXE, but alternatively,
Code: |
UDF2.DoNotSaveInTable=true
|
and do that for any other form related to your trainermaker as well. (So NOT UDF1 as that is the one you do wish to save)
also make sure there are no more 'table files' in the list that are related to your trainer maker. (so get their data when loaded and then delete them)
_________________
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 |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sun Jan 08, 2017 8:01 am Post subject: |
|
|
Thank so much DB,
SOLVED for 1, 2 and 3
Code: | function createPictureImg(data)
local picture = createPicture()
local stream = createStringStream(data)
picture.loadFromStream(stream)
stream.destroy()
return picture
end
function Btn_ChangeImageClick(sender)
path = UDF2.Edit_ImageFile.Text
if GetFileExtension(path) == '.jpg' or GetFileExtension(path) == '.png' then
file = io.open(string.format(path), "rb")
image = file:read("*a")
else
showMessage('Invalid picture or path. Only accept JPG or PNG image file')
return
end
if image == nil then
showMessage('Can not open file...')
return
end
UDF1.Trainer_Img.Picture=createPictureImg(image)
end
function GetFileExtension(path)
local str = path
local temp = ""
local result = "."
for i = str:len(), 1, -1 do
if str:sub(i,i) ~= "." then
temp = temp..str:sub(i,i)
else
break
end
end
for j = temp:len(), 1, -1 do
result = result..temp:sub(j,j)
end
return result
end
function Btn_ResetImageClick(sender)
UDF1.Trainer_Img.Picture.loadFromStream(findTableFile('default_image.png').Stream)
end |
Now, for other case as mentioned at first post, according to your suggestion, several things I must to do :
1. Need re-writing script for FORM (made by lua script) not by form designer and save it as a lua or a text file since current forms has made by form designer.
2.it is necessary in order to call and execute this lua or text file later via a function
3. I am not sure how to save metadata such as picture to a lua file or text file. Is it must be convert to strings first ?
4. Is it possible we save all things change made on the trainer to a trainer.dat or trainer.ini file which will loading when open the trainer for next chance ?.
something like this (by mgr.inz.Player), even I don't know how to use it.
Code: | function getTrainerRealPath()
local t
local f = io.open("TrainerRealPath.txt", "r")
if (f ~= nil) then
t = f:read("*all")
f:close()
else
t = nil
end
return t
end
function SaveSettings()
if MyPath then
settingsFile = io.open(MyPath.."Settings.ini", "w")
if (settingsFile ~= nil) then
settingsFile:write(control_getCaption(EDIT1).."\n") --diamonds
settingsFile:write(control_getCaption(EDIT2)) --playerspeed
settingsFile:close()
end
end
end
function LoadSettings()
if MyPath then
settingsFile = io.open(MyPath.."Settings.ini", "r")
if (settingsFile ~= nil) then
tmpAddDiamonds = settingsFile:read() --read line
tmpPlayerSpeed = settingsFile:read() --read line
settingsFile:close()
end
end
end
--EXIT
function FormClose(Form)
SaveSettings() -- save settings on exit
form_hide(Form)
closeCE()
return caFree
end
|
Regards..
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Sun Jan 08, 2017 8:38 am Post subject: |
|
|
why 1? If the form is designed using the designer it's just as usable as without.
before save you just set DoNotSaveInTable to true/false depending on what you wish, and restore it or not afterwards
_________________
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 |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sun Jan 08, 2017 7:33 pm Post subject: |
|
|
Actually, the project that I was working, just give user to change the look of trainers who had been there before. Where, previously trainer is already equipped with image, title, code hacks and others.
If game update or hack code update, user also able to updating his hack codes, image, title and so on for the new trainer via button "environment" as shown above on the picture post.
To get new trainer, after made some changes needed by user via form "Trainer Environment Class Properties", up to user shall save the trainer via cheat engine by use "Save As" and give new name for new trainer. Also up to user want save the new trainer as CT or stand alone trainer.
So, if no way to save the "modified trainer" via button "save" on UDF2 form, then button "save" UDF2, only will pop-up a message to tell user to save the trainer as new trainer (CT or stand alone) by use "Save As" through CE facility.
Thank and regards..
EDIT : TESTING for save change on UDF1
Code: | last_label = UDF1.CELabel1.Caption -- defaut label = "TEST"
UDF1.CEEdit1.Text = last_label -- put give textbox text same as label for 1st look
function DynamicLabel_Ttl() --- change label caption according to editbox input
new_label = UDF1.CEEdit1.Text
UDF1.CELabel1.Caption = new_label
end
UDF1.CEEdit1.OnChange = DynamicLabel_Ttl
function CEButton1Click(sender) --- confirm changed will save
control_setCaption(UDF1.CElabel1, new_label)
showMessage("Done. Go to CE MENU and save as SAVE AS")
return
end
UDF1.Show() |
Problem :
When change made for CELabel1 via textbox CEEdit1 and save the trainer using SAVE AS for new CT file, when open the new trainer has been saved, all classes not change / not save. It's return as default on old CT file.
How to fix it ?
Thanks
EDIT 2 : Testing use
Code: | settings=getSettings('mytrainerstuff')
settings.Value['blabla']=value |
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Mon Jan 09, 2017 9:02 pm Post subject: |
|
|
EDIT 3 : SOLVED - store and load trainer stuffs.
Code: | UDF1.DoNotSaveInTable=false
UDF1.show()
UDF2.hide()
function CEButton1Click(sender)
UDF2.show()
return
end
settings=getSettings('mytrainerstuff')
old_label=settings.Value[UDF1.CELabel1]
UDF1.CELabel1.Caption = old_label
UDF2.CEEdit1.Text = old_label
function DynamicLabel_Ttl()
new_label = UDF2.CEEdit1.Text
UDF1.CELabel1.Caption = new_label
end
UDF2.CEEdit1.OnChange = DynamicLabel_Ttl
function reset()
UDF1.CELabel1.Caption = last_label
end
function saveChange()
settings.Value[UDF1.CELabel1]=new_label
showMessage("Done. Go to CE MENU and save as SAVE AS")
return
UDF2.hide()
end
UDF2.CEButton1.onClick = reset
UDF2.CEButton2.onClick = saveChange
form_onClose(UDF1, FormClose)
UDF1.Show() |
Even can't make that stuff above like this : http://forum.cheatengine.org/viewtopic.php?t=550742
Because no hint there....
Rgds
|
|
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
|
|