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 


Ported VB 6 script to CE Lua

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Fri Jun 19, 2020 11:36 am    Post subject: Ported VB 6 script to CE Lua Reply with quote

I have old VB 6 scripts. I am writting CE Lua script according my old VB 6 script. Some statement I need to understand or how to ported the script into CE Lua syntax, as below:

Code:
1. Randomize --> math.random() ?

2. randNum = CInt(Int((11 - 0 + 1) * Rnd() + 0))

3. cap = Ucase(Mid(text, i + 1, 1))

4. num = CLng(num + (5 * Len(txt)))

5. UCase(Chr$(KeyAscii))   --> Keypress event

6. UBound( a component or object)

7. Goto  --> to a mark point on the script


Any helps?.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 153

Joined: 06 Jul 2014
Posts: 4734

PostPosted: Fri Jun 19, 2020 11:57 am    Post subject: Reply with quote

1,2: math.random
3: string.upper(string.sub(text, i+1, i+1))
4: Lua has weaker typing than VB (no concept of "long" integer, only integers); for length of text, see 6
5: Not sure what you mean... perhaps look up doKeyPress in celua.txt
6: #table
7: goto/label examples

_________________
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
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Fri Jun 19, 2020 6:34 pm    Post subject: Reply with quote

Thanks Parkour, it's enough and clear for me to understand.
And for no.5,I think something like this:

Code:
5. doKeyPress(string.upper(string.char(ASCII num)))

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 153

Joined: 06 Jul 2014
Posts: 4734

PostPosted: Fri Jun 19, 2020 7:31 pm    Post subject: Reply with quote

doKeyPress takes an integer defined globally in defines.lua as VK_something.
Code:
doKeyPress(_G['VK_' .. string.upper(string.char(ASCII num))])

_________________
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
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Fri Jun 19, 2020 9:03 pm    Post subject: Reply with quote

ParkourPenguin wrote:
doKeyPress takes an integer defined globally in defines.lua as VK_something.
Code:
doKeyPress(_G['VK_' .. string.upper(string.char(ASCII num))])


Alright, I got it. Thanks again


EDIT:

Implementing in my script (example):

Code:
virtual_keys = {}
for i, v in pairs(_G) do
 if type(i) == "string" then
   if i:sub(1, 3) == "VK_" then
      virtual_keys[v] = i
      key1 = virtual_keys[v]
   end
 end
end


function Form_KeyPress(sender, key)
 local a = virtual_keys[key]
 local kp = tostring(a)
 local i
 if key == 8 then  --> backspace
    for i = guess.Count - 1, 0, -1 do
        if guess(i).Enabled == true then
           guess_Click (i)  -- execute another function
           break -- exit for statement
        end
    end
 else
    for i = 1, #cmdChars.Count do
        if string.upper(cmdChars[i].Caption) == string.upper(kp) then
           cmdChars_Click[i]  -- execute another function
           break  -- exit for statement
        end
    end
 end
end

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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