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 add an image to trainer? ( for a button )

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

Joined: 25 Mar 2014
Posts: 17

PostPosted: Mon Jan 04, 2016 4:59 pm    Post subject: How to add an image to trainer? ( for a button ) Reply with quote

I'm trying to add images to my trainer, and use onClick so I can use them as a button.

I have tried everything, I've read the main.lua docs and tried things from there, tried reading wiki and several threads here.

How can I do this? I've attached the image to the program in the Add files, and compiled it, but it's not working?

Here's the most recent thing I have tried:

Code:

bmenuattach = createImage(MAXGUI[1])
image_loadImageFromFile(bmenuattach, [attach.png])
control_setPosition(bmenuattach, 20, 110)


and also tried this, taking something from another thread,

Code:

bmenuattach = createImage(MAXGUI[1])
image_loadImageFromFile(bmenuattach, [attach.png])
control_setPosition(bmenuattach, 20, 110)

local p = image_getPicture(bmenuattach)
local s = findTableFile('attach.png');

picture_loadFromStream(p,s);


I've spent all day on this now, and I can't get it working - maybe I'm being stupid, is anyone able to help?


While anyone looks at this, I also have another side question -

Is it possible to integrate some kind of chat into my trainer, whether I use some kind of iframe to show a php chat I have on my website, or some other way?


Thanks to any help anyone can give Smile
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Mon Jan 04, 2016 5:08 pm    Post subject: Reply with quote

the second one shoukd work although it's extremely outdated (not even using classes)

is MAXGUI a table where element 1 is your form?
is the form visible?
does the image show?


you can make it open a browser window with chat
alternatively you could write your own chat implementation using tbe internet class object and use a timer to refresh the chat you show in a memo

_________________
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


Last edited by Dark Byte on Mon Jan 04, 2016 5:13 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
damento
Newbie cheater
Reputation: 0

Joined: 25 Mar 2014
Posts: 17

PostPosted: Mon Jan 04, 2016 5:12 pm    Post subject: Reply with quote

Here is the code for my program - and no, the image does not show it just produces an error.

Code:

showMessage("LOADED \nTESTING...")

----------------------------------------- VARIABLES -----------------------------------------
title=      "TEST"

white=      "0x0052D6E9"
black=      "0x00000000"
red=        "0x00000FFF"
green=      "0x0000FF00"
Dark=       "0x0052D6E9"
list=       "0x00CA59C7"


----------------------------------------- MAIN GUI-----------------------------------------

MAXGUI        = {}
MAXGUI[1]     = createForm(false)


-----------------------------------------MAIN WINDOW PROPERTIES-----------------------------------------

MAXGUI        = {}
MAXGUI[1]     = createForm(false)

setProperty(MAXGUI[1] , "color", black)
setProperty(MAXGUI[1] , "ShowInTaskBar", 'stAlways')
setProperty(MAXGUI[1] , "Position", "poScreenCenter")
setProperty(MAXGUI[1] , "BiDiMode", "bdLeftToRight")

control_setSize(MAXGUI[1], 736, 549)
x,y = control_getSize(MAXGUI[1])

control_setCaption(MAXGUI[1],    title.." ")

 function CloseTrainer()
   form_hide(MAXGUI[1])
   closeCE()
  end

form_show(MAXGUI[1])
form_onClose(MAXGUI[1], CloseTrainer)

-----------------------------------------GLOBAL FUNCTIONS-----------------------------------------
 
 function CloseTrainer()
   form_hide(MAXGUI[1])
   closeCE()
  end
 
 
-----------------------------------------IMAGING----------------------------------------- 

 ----------------------------------------BACKGROUND
 
 function attachBackground(wc,tblFile)
  local p = createPicture()
  p.loadFromStream(findTableFile(tblFile).Stream)
  wc.OnPaint = function(sender)
    local c = sender.getCanvas()
    local bitmap = p.getBitmap()
    c.draw(0,0,bitmap)
  end
end
attachBackground(MAXGUI[1] ,[[abg.png]])

----------------------------------------ATTACH BUTTON

bmenuattach = createImage(MAXGUI[1])
image_loadImageFromFile(bmenuattach, [attach.png])
control_setPosition(bmenuattach, 20, 110)

local p = image_getPicture(bmenuattach)
local s = findTableFile('attach.png');

picture_loadFromStream(p,s);

function attachClickk()

showMessage("ATTACH BUTTON CLICKED FROM BOTTOM MENU")

end


I literally cannot get this working for the life of me!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Mon Jan 04, 2016 6:06 pm    Post subject: This post has 1 review(s) Reply with quote

Code:

showMessage("LOADED \nTESTING...")

----------------------------------------- VARIABLES -----------------------------------------
title=      "TEST"

white=      "0x0052D6E9"
black=      "0x00000000"
red=        "0x00000FFF"
green=      "0x0000FF00"
Dark=       "0x0052D6E9"
list=       "0x00CA59C7"


----------------------------------------- MAIN GUI-----------------------------------------

MAXGUI        = {}
MAXGUI[1]     = createForm(false)


-----------------------------------------MAIN WINDOW PROPERTIES-----------------------------------------

MAXGUI        = {}
MAXGUI[1]     = createForm(false)

setProperty(MAXGUI[1] , "color", black)
setProperty(MAXGUI[1] , "ShowInTaskBar", 'stAlways')
setProperty(MAXGUI[1] , "Position", "poScreenCenter")
setProperty(MAXGUI[1] , "BiDiMode", "bdLeftToRight")

control_setSize(MAXGUI[1], 736, 549)
x,y = control_getSize(MAXGUI[1])

control_setCaption(MAXGUI[1],    title.." ")

 function CloseTrainer()
   form_hide(MAXGUI[1])
   closeCE()
  end

form_show(MAXGUI[1])
form_onClose(MAXGUI[1], CloseTrainer)

-----------------------------------------GLOBAL FUNCTIONS-----------------------------------------

 function CloseTrainer()
   form_hide(MAXGUI[1])
   closeCE()
  end


-----------------------------------------IMAGING-----------------------------------------

 ----------------------------------------BACKGROUND

 function attachBackground(wc,tblFile)
  local p = createPicture()
  p.loadFromStream(findTableFile(tblFile).Stream)
  wc.OnPaint = function(sender)
    local c = sender.getCanvas()
    local bitmap = p.getBitmap()
    c.draw(0,0,bitmap)
  end
end
attachBackground(MAXGUI[1] ,[[abg.png]])

----------------------------------------ATTACH BUTTON

bmenuattach = createImage(MAXGUI[1])
bmenuattach.Stretch=true

bmenuattach.setPosition(20,110)

local s = findTableFile('attach.png').stream;
bmenuattach.Picture.loadFromStream(s)

bmenuattach.OnClick=function(s)
  showMessage("Clicked")
end


function attachClickk()

showMessage("ATTACH BUTTON CLICKED FROM BOTTOM MENU")

end



example.ct
 Description:

Download
 Filename:  example.ct
 Filesize:  50.11 KB
 Downloaded:  798 Time(s)


_________________
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
damento
Newbie cheater
Reputation: 0

Joined: 25 Mar 2014
Posts: 17

PostPosted: Mon Jan 04, 2016 6:19 pm    Post subject: Reply with quote

Great, I appreciate this so much, thank you VERY much for helping me with this Smile

Can I suggest, maybe a developers section? Where people can request a developer/good coder can help/do things with/for them?
I'd 100% pay for a few little projects to be done, however I'm going to put all my time into learning Lua so I don't need to bother anyone for help aha.

Thanks again.
Back to top
View user's profile Send private message
Fluffer_Nutter
Advanced Cheater
Reputation: 0

Joined: 26 Feb 2015
Posts: 67

PostPosted: Mon Jan 04, 2016 6:50 pm    Post subject: Reply with quote

You can also do it all without using Lua to attach the pictures. This is just a second way of doing it. I prefer to write the code out but is also something to know. This way is done under the "Create Form".


damento.CT
 Description:

Download
 Filename:  damento.CT
 Filesize:  48.4 KB
 Downloaded:  781 Time(s)

Back to top
View user's profile Send private message
damento
Newbie cheater
Reputation: 0

Joined: 25 Mar 2014
Posts: 17

PostPosted: Mon Jan 04, 2016 7:05 pm    Post subject: Reply with quote

Fluffer_Nutter wrote:
You can also do it all without using Lua to attach the pictures. This is just a second way of doing it. I prefer to write the code out but is also something to know. This way is done under the "Create Form".


thanks for your, do you know much about Lua? I have a few little questions, I understand if you can't help, I'm trying my hardest to learn and putting lots of time in anyway.

Thanks again pal Smile
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