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 


repaint/clear/destroy d3d script ?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
mikeem
How do I cheat?
Reputation: 0

Joined: 22 Jul 2013
Posts: 6

PostPosted: Mon Jul 22, 2013 1:53 pm    Post subject: repaint/clear/destroy d3d script ? Reply with quote

Hello everybody,

i use Darkbytes d3d menu example. it works. but when i change the coordinates of any display element and press EXECUTE in that CE LuaEngine window, the new menu is drawn OVER the old version with its old coordinates. the old menu is still visible and wont go away. i then have to close&restart the whole game and CE in order to get rid of the old stuff. what the heck is going on, can someone help/explain?

Bye bye!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Mon Jul 22, 2013 2:03 pm    Post subject: Reply with quote

It sounds like the code in the luaengine window creates sprites and textcontainers instead of just editing the properties of the existing sprites/containers/renderobjects
_________________
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
mikeem
How do I cheat?
Reputation: 0

Joined: 22 Jul 2013
Posts: 6

PostPosted: Mon Jul 22, 2013 2:27 pm    Post subject: Reply with quote

this is the relevant code:
Code:
background=createPicture()
bmp=picture_getBitmap(background);
graphic_setHeight(bmp,1)
graphic_setWidth(bmp,1)
c=rasterimage_getCanvas(bmp)
canvas_setPixel(c,0,0,0xFF00FF)
bgtexture=d3dhook_createTexture(background)
bgsprite=d3dhook_createSprite(bgtexture);
d3dhook_sprite_setWidth(bgsprite,50)
d3dhook_sprite_setHeight(bgsprite,50)
d3dhook_renderobject_setX(bgsprite, 10) -- CHANGE HERE TO 110

Execute it, then Change the x-coord, press Execute again and you will have 2 boxes. i guess i am too stupid to understand it why it keeps the old one too. my naive expectation was that when i close the LuaEngine window, the script is ended and nothing is drawn any more. or at least some method to remove a running (?) script from memory. any idea how to deal with this? i am not sure if i made myself clear enough Sad
or is this a kind of bug in the LuaEngine-window function of CE - thats how i interpreted your reply Darkbytes?

Bye bye!

P.S. thx for rapid answer!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Mon Jul 22, 2013 2:33 pm    Post subject: Reply with quote

when you execute this code
Code:

bgsprite=d3dhook_createSprite(bgtexture);


bgsprite gets replaced by a new sprite (but the old bgsprite still exists)
same for bgtexture

if you skip those two lines when they already exist then it won't recreate them but reuse them
e.g:
Code:

if background==nil then
--create them
  background=createPicture()
  bmp=picture_getBitmap(background);

  graphic_setHeight(bmp,1)
  graphic_setWidth(bmp,1)
  c=rasterimage_getCanvas(bmp)
  canvas_setPixel(c,0,0,0xFF00FF)
  bgtexture=d3dhook_createTexture(background)
  bgsprite=d3dhook_createSprite(bgtexture);
end
d3dhook_sprite_setWidth(bgsprite,50)
d3dhook_sprite_setHeight(bgsprite,50)
d3dhook_renderobject_setX(bgsprite, 10) -- CHANGE HERE TO 110

_________________
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
mikeem
How do I cheat?
Reputation: 0

Joined: 22 Jul 2013
Posts: 6

PostPosted: Mon Jul 22, 2013 2:50 pm    Post subject: Reply with quote

wunderful it works, thank you.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Jul 22, 2013 3:44 pm    Post subject: Reply with quote

Its the same with timer, hotkey and memscan object.
You must destroy it.


If you have this code:
Code:
...
createHotkey(function,key1,key2)
...




And you click execute two times, there will be two hotkey objects. This is why many of us, trainer creators using Lua script, use something like this:
Code:
...
if myHotkey~=nil then myHotkey.destroy(); myHotkey = nil; end
myHotkey = createHotkey(function,key1,key2)
...


All new variables are nil by default.

Of course, EXE trainers and CETRAINER trainers don't need that (Lua script is executed once). But, if you re developing new trainer, and you do many tests, it is better to take precautions:

- always assign new objects to variable - all createSometing functions (like: createHotkey, createTimer, createTexture), each of them returns an object you can use with destroy() method.

- check variables, if they are not nil, just destroy object OR
- do not create new object if old still exist

_________________
Back to top
View user's profile Send private message MSN Messenger
mikeem
How do I cheat?
Reputation: 0

Joined: 22 Jul 2013
Posts: 6

PostPosted: Mon Jul 22, 2013 5:43 pm    Post subject: Reply with quote

this is even better advice (hehe) thanks to you as well!
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