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 


Labels are not drawn accurate

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

Joined: 03 Jan 2017
Posts: 7

PostPosted: Sun Jan 08, 2017 7:42 am    Post subject: Labels are not drawn accurate Reply with quote

Hi,
I use a lua script which sets the position of a label on a form based on the position of the player in the game.
The problem is that the label isnt drawn accurately in the form.

I cant link the picture directly so here is a link:
fotos-hochladen.net/uploads/label0epf42yo3v.png

The red square-label in the middle is the current position of the player.
When I walk around the position of the label is changed but there are always those small lines which stay there.
Its very hard for me to explain but I guess you see what I mean Very Happy
Did I make any mistake or is there a solution? Or do I have to code the GUI in c++ for example to make this work?

Thanks for help Smile

(Sorry if this is in the wrong sub forum. I wasnt sure whether this is more Lua or CE related)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sun Jan 08, 2017 8:25 am    Post subject: Reply with quote

are you sure it's a label and not a cancas you draw on?

anyhow, call formname.repaint() after a move

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

Joined: 03 Jan 2017
Posts: 7

PostPosted: Sun Jan 08, 2017 10:48 am    Post subject: Reply with quote

Dark Byte wrote:
are you sure it's a label and not a cancas you draw on?

Im not sure what you mean. I just move the label around on the form.

Dark Byte wrote:
anyhow, call formname.repaint() after a move

Thanks, it works but now I have another problem.

The window freezes after a few (~10-20) seconds. Neither the label which should be moved nor any other labels can change any more.

When I delete the following 2 lines it doesnt freeze.
Quote:

playerLabel.setLeft( math.floor( playerX) )
playerLabel.setTop( math.floor( playerY) )

playerLabel is the label I want to move and playerX and playerY are the address values (float) of the player coordinates.

There is no error massage. Somehow I still can call functions of the script. For example even though the window is frozen, a double click still calls a function as it should be. Im completely confused right now ^^
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Mon Jan 09, 2017 11:10 am    Post subject: Reply with quote

are you using threads? If so, call the gui related code inside a synchronize(function)

calling gui controls from threads without sync will cause issues

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

Joined: 03 Jan 2017
Posts: 7

PostPosted: Thu Jan 12, 2017 9:51 am    Post subject: Reply with quote

Thanks again for your help ! Very Happy

It is working now.



edit:
I just leave this here in case somebody finds this and has the same problem...

So as I said my script changes the position of a label every few miliseconds in another thread. The strange thing was that first the label wasnt drawn accurate and i called form.repaint() to fix it which first seemed to work fine. But then I realized that the window freezed after a few seconds.
As DarkByte suggested I called synchronize(function) of the function which changes the label but it still didnt work and the window freezed.
After i deleted the "form.repaint()" somehow it works awesome.
I guess the first problem (that the label wasnt drawn accurate) was caused of a ciritcal read/write section which happens in multiple threads if you dont use synchronize.
I hope this helps somebody ... xD
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