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 


Serious programming Lua-Trainer

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
GH*master
Expert Cheater
Reputation: 8

Joined: 10 Jan 2008
Posts: 159

PostPosted: Tue Jul 26, 2011 2:49 pm    Post subject: Serious programming Lua-Trainer Reply with quote



Can you write code better and locate the resources within Trainer.CETRAINER?

Look at my the code that I write:
Code:

<?xml version="1.0"?>
<CheatTable CheatEngineTableVersion="12">
  <CheatEntries/>
  <UserdefinedSymbols/>
  <LuaScript>
   processName = "test.exe"
   aboutTrnString = "About my Trainer:\n\r\n\r1) Save and restore value: CTRL+C+1\n\r\n\r\n\rGameHackLab[RU], MasterGH(C), 2011"
   captionWindow = "My first Lua-trainer"
   require("GamehacklabRuENGINE")
---------- Cheat1 ---------
   isCheat1Active = false
   lastValue = 0
   newValue = DEC_HEX(10000)
   
   function Cheat1Function(hotkey)
   
      TryOpenProcess()
      
      if (isCheat1Active) then
               
         autoAssemble([[
         Test.exe+5B5A4:
            dd $lastValue
         ]])

         isCheat1Active = false
      else
         lastValue = DEC_HEX(readInteger(getAddress("Test.exe+5B5A4")))
         autoAssemble([[
         Test.exe+5B5A4:
            dd $newValue
         ]])

         isCheat1Active = true
      end
      
   end

   SetHotKey(Cheat1Function, VK_1)
--------------------------
</LuaScript>
</CheatTable>


Also, I have the code in GamehacklabRuENGINE.lua (download the attach archive) from ref...
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Tue Jul 26, 2011 6:57 pm    Post subject: Reply with quote

Not sure if you are requesting some suggestions for your Lua script or if you are talking about some requests to DB for embedding stuff.

Your DEC_HEX function can be written just using string.format though like:

Code:

function DEC_HEX( IN )
    return string.format( '%x', IN );
end

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
GH*master
Expert Cheater
Reputation: 8

Joined: 10 Jan 2008
Posts: 159

PostPosted: Thu Jul 28, 2011 2:43 am    Post subject: Reply with quote

thanks, Wiccaan.

A have a problem.
I know how to load music stream from resources.

Code:

....
XMFILE = findTableFile ('Trainer.xm')
xmplayer_playXM (XMFILE)
....


But I have no idea why it is not possible??? Shocked

Code:

....
trainerForm = createForm ()
....

trImage = createImage (trainerForm)
setProperty (trImage, "AutoSize", "true")

picture = image_getPicture (trImage)
mstream = findTableFile ('Trainer.jpeg')
picture_loadFromStream (picture, mstream) -- or picture_loadFromStream (picture, mstream, ",jpeg")
.....


The my picture is not load from resources from "*.CETRAINER" file.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Jul 28, 2011 7:35 am    Post subject: Reply with quote

make sure you have added trainer.jpeg to the table/cetrainer file

this script works for me:
Code:

f=createForm()
setProperty (f, "Borderstyle", "bsNone")
control_setSize(f, 800,600)
form_centerScreen(f)

img=createImage(f)
control_setAlign(img, alClient)
image_stretch(img,true)

p=image_getPicture(img)
s=findTableFile('Trainer.jpeg');

picture_loadFromStream(p,s);


function close()
  closeCE();
end

b=createButton(f)
control_setPosition(b, 720,580)
control_setSize(b, 78,18)
control_setCaption(b, 'Close')
control_onClick(b, close)


You just need to be aware of one bug, loadFromStream will only work once on a stream object, second time running it without deleting the old file and adding it back will not work.

Hmm, didn't test with loading. I'll testthat when i get home

edit. Yup, there's the problem. The file pointer didn't get reset after loading
fixed in svn

also a tip: Instead of buttons you could place a image with an onclick handler

_________________
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
GH*master
Expert Cheater
Reputation: 8

Joined: 10 Jan 2008
Posts: 159

PostPosted: Thu Jul 28, 2011 9:19 am    Post subject: Reply with quote

Yes, it works if you run from the console CheatEngine ... Are You try running from a "*.CETRAINER"?

Please make your "*. CETRAINER" and test it. Or check out my new file: ref
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Jul 28, 2011 9:31 am    Post subject: Reply with quote

I know, as I said it's fixed in the svn now
for now load the image from file

_________________
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
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