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 


Help with lua scripting

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

Joined: 10 Nov 2016
Posts: 17

PostPosted: Fri Dec 16, 2016 4:01 am    Post subject: Help with lua scripting Reply with quote

I want to make a trainer that if i put a number on the box, the script will read the number.

Can someone help me with the lua script? thank you
Back to top
View user's profile Send private message AIM Address  
ParkourPenguin
I post too much
Reputation: 150

Joined: 06 Jul 2014
Posts: 4657

PostPosted: Fri Dec 16, 2016 9:50 am    Post subject: Reply with quote

Use either the OnChange event or the OnExit event. The OnChange event will be called whenever the text of the editbox is changed, while the OnExit event will be called when the editbox looses focus.
Code:
function CEEdit1Change(sender)
  print(tonumber(sender.Text))
end

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message  
herrick92
Newbie cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 17

PostPosted: Fri Dec 16, 2016 1:11 pm    Post subject: Reply with quote

what im trying to do is like for example when i put number in the box, another script will use that number for the script.

so lets say i put 50
then another script is like when "this address" value is below 50 then send keystroke B.
does that make sense?
Back to top
View user's profile Send private message AIM Address  
ParkourPenguin
I post too much
Reputation: 150

Joined: 06 Jul 2014
Posts: 4657

PostPosted: Fri Dec 16, 2016 1:59 pm    Post subject: Reply with quote

Code:
function CEEdit1Change(sender)
  someGlobal = tonumber(sender.Text) or someGlobal
end

Code:
-- somewhere else
if someGlobal < 50 then doKeyPress(VK_B) end

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message  
herrick92
Newbie cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 17

PostPosted: Fri Dec 16, 2016 7:40 pm    Post subject: Reply with quote

thank you! i will try doing the full script later

*edit: actually i dont want to write 50 on the script, what i meant is that whatever number i put on the box, the script will automatically get that number
Back to top
View user's profile Send private message AIM Address  
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Fri Dec 16, 2016 7:51 pm    Post subject: Reply with quote

Code:
getfrEdit = control_getCaption(UDF1.CEEdit1)
if tonumber(getfrEdit) == nil or type(getfrEdit) == 'string' then
showMessage('Input is not number')
end
if type(getfrEdit) == "number" and getfrEdit < 50 then  --- remove "and getfrEdit < 50 to allow input any number
doKeyPress(VK_B)
//.... or do stuff here
end
Back to top
View user's profile Send private message  
herrick92
Newbie cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 17

PostPosted: Fri Dec 16, 2016 7:53 pm    Post subject: Reply with quote

@Corroder

Some misunderstanding, my bad.

I dont want the script to write anything about 50, I meant that whatever number i put on the box will be use by another script.
Back to top
View user's profile Send private message AIM Address  
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Fri Dec 16, 2016 7:55 pm    Post subject: Reply with quote

see on that script it said :

Code:
--- remove "and getfrEdit < 50" to allow input any number


that mean user can input what ever number as user want on edit box. then this is script :

Code:
getfrEdit = control_getCaption(UDF1.CEEdit1)
if tonumber(getfrEdit) == nil or type(getfrEdit) == 'string' then
showMessage('Input is not number')
end
if type(getfrEdit) == "number" then
doKeyPress(VK_B)
//.... or do stuff here
end
Back to top
View user's profile Send private message  
panraven
Grandmaster Cheater
Reputation: 61

Joined: 01 Oct 2008
Posts: 958

PostPosted: Fri Dec 16, 2016 8:14 pm    Post subject: Reply with quote

Using ParkourPenguin's code
Code:
function CEEdit1Change(sender)
  MinimumSpeed = tonumber(sender.Text) or MinimumSpeed or 0
end

Code:
-- somewhere else
MinimumSpeed = MinimumSpeed or 0 -- in case MinimumSpeed not initialized as number type yet
if MinimumSpeed > readFloat"BusSpeed" or 99999999 --[[if not readable, do nothing]] then doKeyPress(VK_B) end


btw, Edit should use Text instead of Caption.

_________________
- Retarded.
Back to top
View user's profile Send private message  
herrick92
Newbie cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 17

PostPosted: Fri Dec 16, 2016 9:12 pm    Post subject: Reply with quote

thanks guys, lemme play with it for a bit.
im really new to lua scripting and its hard to make it works right away
Back to top
View user's profile Send private message AIM Address  
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