| View previous topic :: View next topic |
| Author |
Message |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Fri Jun 19, 2020 11:36 am Post subject: Ported VB 6 script to CE Lua |
|
|
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 |
|
 |
ParkourPenguin I post too much
Reputation: 153
Joined: 06 Jul 2014 Posts: 4734
|
Posted: Fri Jun 19, 2020 11:57 am Post subject: |
|
|
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 |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Fri Jun 19, 2020 6:34 pm Post subject: |
|
|
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 |
|
 |
ParkourPenguin I post too much
Reputation: 153
Joined: 06 Jul 2014 Posts: 4734
|
Posted: Fri Jun 19, 2020 7:31 pm Post subject: |
|
|
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 |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Fri Jun 19, 2020 9:03 pm Post subject: |
|
|
| 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 |
|
 |
|