| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| GH*master Expert Cheater
 
  Reputation: 8 
 Joined: 10 Jan 2008
 Posts: 159
 
 
 | 
			
				|  Posted: Tue Jul 26, 2011 2:49 pm    Post subject: Serious programming Lua-Trainer |   |  
				| 
 |  
				|   
 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 |  | 
	
		|  | 
	
		| atom0s Moderator
 
  Reputation: 205 
 Joined: 25 Jan 2006
 Posts: 8587
 Location: 127.0.0.1
 
 | 
			
				|  Posted: Tue Jul 26, 2011 6:57 pm    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| GH*master Expert Cheater
 
  Reputation: 8 
 Joined: 10 Jan 2008
 Posts: 159
 
 
 | 
			
				|  Posted: Thu Jul 28, 2011 2:43 am    Post subject: |   |  
				| 
 |  
				| 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???
   
 
  	  | 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 |  | 
	
		|  | 
	
		| Dark Byte Site Admin
 
  Reputation: 470 
 Joined: 09 May 2003
 Posts: 25807
 Location: The netherlands
 
 | 
			
				|  Posted: Thu Jul 28, 2011 7:35 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| GH*master Expert Cheater
 
  Reputation: 8 
 Joined: 10 Jan 2008
 Posts: 159
 
 
 | 
			
				|  Posted: Thu Jul 28, 2011 9:19 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		| Dark Byte Site Admin
 
  Reputation: 470 
 Joined: 09 May 2003
 Posts: 25807
 Location: The netherlands
 
 | 
			
				|  Posted: Thu Jul 28, 2011 9:31 am    Post subject: |   |  
				| 
 |  
				| 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 |  | 
	
		|  | 
	
		|  |