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 


Editboxes

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Thu Apr 18, 2013 3:40 pm    Post subject: Editboxes Reply with quote

Well,
Is it possible to do this,
I have made an trainer for stats.
I want to allow in the editboxes to be written ONLY numbers
I tried the following,
Code:
function CEEdit1KeyDown(sender, key)
local text = control_getCaption(UDF1_CEEdit1)
print(text)
a = isKeyPressed(VK_0)
b = isKeyPressed(VK_1)
c = isKeyPressed(VK_2)
d = isKeyPressed(VK_3)
e = isKeyPressed(VK_4)
f = isKeyPressed(VK_5)
g = isKeyPressed(VK_6)
h = isKeyPressed(VK_7)
i = isKeyPressed(VK_8)
j = isKeyPressed(VK_9)
if a then print(0)
   elseif b then print(1)
   elseif c then print(2)
   elseif d then print(3)
   elseif e then print(4)
   elseif f then print(5)
   elseif g then print(6)
   elseif h then print(7)
   elseif i then print(8)
   elseif j then print(9)
          else
          control_setCaption(UDF1_CEEdit1, text)
          end
  return key
end

Didn't prevent anything.

Don't see any option to set allowed characters

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Thu Apr 18, 2013 4:06 pm    Post subject: Reply with quote

you're close

but try something like this:
Code:

function CEEdit1KeyDown(sender, key)
  if (string.byte(key)<string.byte('0')) or (string.byte(key)>string.byte('9')) then
    key=nil
  end
  return key
end

_________________
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
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Thu Apr 18, 2013 4:24 pm    Post subject: Reply with quote

Dark Byte wrote:
you're close

but try something like this:
Code:

function CEEdit1KeyDown(sender, key)
  if (string.byte(key)<string.byte('0')) or (string.byte(key)>string.byte('9')) then
    key=nil
  end
  return key
end

Gonna test Razz
Tested, backspace does not work nor the digit 6 Razz

Also found alternatives..
Code:

function CEEdit1KeyPress(sender, key)
if (tonumber(key))==0 then return key
elseif(tonumber(key))==1 then return key
elseif(tonumber(key))==2 then return key
elseif(tonumber(key))==3 then return key
elseif(tonumber(key))==4 then return key
elseif(tonumber(key))==5 then return key
elseif(tonumber(key))==6 then return key
elseif(tonumber(key))==7 then return key
elseif(tonumber(key))==8 then return key
elseif(tonumber(key))==9 then return key
else return end
end

which does not allows backspace.
but this does
Code:
function CEEdit1KeyPress(sender, key)
a = isKeyPressed(VK_0)
b = isKeyPressed(VK_1)
c = isKeyPressed(VK_2)
d = isKeyPressed(VK_3)
e = isKeyPressed(VK_4)
f = isKeyPressed(VK_5)
g = isKeyPressed(VK_6)
h = isKeyPressed(VK_7)
i = isKeyPressed(VK_8)
j = isKeyPressed(VK_9)
k = isKeyPressed(VK_BACK)
if a then return key
   elseif b then return key
   elseif c then return key
   elseif d then return key
   elseif e then return key
   elseif f then return key
   elseif g then return key
   elseif h then return key
   elseif i then return key
   elseif j then return key
   elseif k then return key
else return end
end

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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