|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
FIRESKY Cheater Reputation: 0
Joined: 01 Mar 2017 Posts: 34
|
Posted: Wed May 08, 2024 12:05 pm Post subject: Lua string.match, only positive form etc. |
|
|
This string.match allows to digit only positive or negative number forms
based on: https://www.lua.org/pil/20.2.html
I was running some tests, in any case I'm writing here too
because I was looking for a couple of correct lua based on my string:
1) How do I get only "positive number" form from my code? (The rest remains unchanged).
2) How do I get only "negative number" form from my code? (The rest remains unchanged).
3) How do I get only "text + space, no numbers etc" form with my code? (The rest remains unchanged).
4) How do I get only "dot, !, ?" form with my code? (The rest remains unchanged).
5) How do I to add at my code a statment for only "number >= to 100"? (if possible add this statment to the same code string,
so rest remains unchanged).
If possible an example directly on my script, repeated 5 times with the desired form will be great.
Code: | if (tonumber(MYEDIT) ~= nil or (string.match(MYEDIT, '[^%d%-%.]') == '')) then |
Thanks.
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 34
Joined: 16 Feb 2017 Posts: 1418
|
Posted: Wed May 08, 2024 2:28 pm Post subject: |
|
|
I think there are better examples.
For now, it contains beginner level examples;
Code: | if frm1 then frm1.Destroy() frm1=nil end
DP1=getScreenDPI()/96
frm1=createForm()
frm1.height=161*DP1 frm1.width=220*DP1
frm1.PopupMode=0 frm1.caption="separations"
frm1.Position="poDesktopCenter" frm1.ShowInTaskBar="stAlways"
frm1.BorderStyle="bsSingle"
-------------------------
local sprt = {}
----------------------- sprt.edt1 -----
sprt.edt1=createEdit(frm1)
sprt.edt1.AutoSize=true
sprt.edt1.height=23*DP1 sprt.edt1.width=160*DP1 sprt.edt1.left=10*DP1 sprt.edt1.top=29*DP1
sprt.edt1.text=""
sprt.edt1.alignment="taLeftJustify"
sprt.edt1.Font.Style="fsBold" sprt.edt1.Font.Size=0*DP1
-----------------------
----------------------- sprt.edt2 -----
sprt.edt2=createEdit(frm1)
sprt.edt2.AutoSize=true
sprt.edt2.height=23*DP1 sprt.edt2.width=30*DP1 sprt.edt2.left=180*DP1 sprt.edt2.top=29*DP1
sprt.edt2.text=""
sprt.edt2.alignment="taLeftJustify"
sprt.edt2.Font.Style="fsBold" sprt.edt2.Font.Size=0*DP1
-----------------------
----------------------- sprt.edt3 -----
sprt.edt3=createEdit(frm1)
sprt.edt3.AutoSize=true
sprt.edt3.height=23*DP1 sprt.edt3.width=160*DP1 sprt.edt3.left=10*DP1 sprt.edt3.top=100*DP1
sprt.edt3.text=""
sprt.edt3.alignment="taLeftJustify"
sprt.edt3.Font.Style="fsBold" sprt.edt3.Font.Size=0*DP1
-----------------------
----------------------- sprt.btn1 -----
sprt.btn1=createButton(frm1)
sprt.btn1.AutoSize=false
sprt.btn1.height=25*DP1 sprt.btn1.width=75*DP1 sprt.btn1.left=50*DP1 sprt.btn1.top=60*DP1
sprt.btn1.caption="Format"
sprt.btn1.Font.Style="fsBold" sprt.btn1.Font.Size=0*DP1
-----------------------
--############################################################################--
--############################################################################--
function separations(txt,opt)
local res = ""
if opt==1 then -- negative
if tonumber(txt) then
pst,ngt = math.modf(tonumber(txt))
res=ngt
else
res="No number to parse found!"
end
elseif opt==2 then -- positive
if tonumber(txt) then
pst,ngt = math.modf(tonumber(txt))
res=pst
else
res="No number to parse found!"
end
elseif opt==3 then -- return Punctuation
if string.find(txt,"%p") then
res = string.gsub(txt,"%w"," ") -- or no space: (txt,"%w","")
else
res="Punctuation not found!"
end
elseif opt==4 then -- delete Punctuation
if string.find(txt,"%p") then
res = string.gsub(txt,"%p"," ") -- or no space: (txt,"%p","")
else
res="Punctuation not found!"
end
elseif opt==5 then -- delete Word and Punctuation
if string.find(txt,"%w") then
res = string.gsub(txt,"%D",""):gsub("%p","")
else
res="Word not found!"
end
elseif opt==6 then -- delete number and Punctuation
if string.find(txt,"%w") then
res = string.gsub(txt,"%d",""):gsub("%p","")
else
res="Number not found!"
end
end
return res
end
--sprt.edt1.Text="223.44556600" -- test: 1,2
sprt.edt1.Text="33 hello, lua! 24and CE..?" -- test: 3,4,5,6
sprt.btn1.OnClick=function(sender)
txt=sprt.edt1.Text
opt=tonumber(sprt.edt2.Text)
sprt.edt3.Text=separations(txt,opt)
end |
_________________
|
|
Back to top |
|
|
FIRESKY Cheater Reputation: 0
Joined: 01 Mar 2017 Posts: 34
|
Posted: Wed May 08, 2024 3:30 pm Post subject: |
|
|
Hey AylinCE thanks!
But just out of curiosity if I wanted these in my code exactly as they would be, in the sense of an example on my code, only on this string
Code: | if (tonumber(MYEDIT) ~= nil or (string.match(MYEDIT, '[^%d%-%.]') == '')) then |
Even just now I'm running into some unsuccessful tests on one simple thing:
that is, I tried to create a simple statement that says:
If the value is >= 100 then the CEEDIT returns empty
but I get nil errors for now...
TEST 1 (But take nill error):
Code: | local TEST1 = CEtrainer.Ceedit1;
if TEST1 >= 100 then
CEtrainer.Ceedit1.Text="" |
TEST 2 (doesn't seem to read the comparison):
Code: | if tonumber(getAddressList().getMemoryRecordByDescription("bla bla")Value) >= 100 then
CEtrainer.Ceedit1.Text="" |
ok it seems trivial but I was just running some tests now without success on something like this...
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 465
Joined: 09 May 2003 Posts: 25509 Location: The netherlands
|
Posted: Wed May 08, 2024 5:36 pm Post subject: |
|
|
Test1:
use tonumber(CEtrainer.Ceedit1.Text)
test 2:
that should give an error as the . before value is missing. Everything after that fails (and should have given an error)
tip:
instead of
Code: |
getAddressList().getMemoryRecordByDescription("bla bla")
|
you can do:
Code: |
AddressList['bla bla']
|
unless you're on a really old CE version
_________________
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 |
|
|
FIRESKY Cheater Reputation: 0
Joined: 01 Mar 2017 Posts: 34
|
Posted: Wed May 08, 2024 6:15 pm Post subject: |
|
|
Hey ok try your tip,
anyway 7.4, cause any new version have bugs that block the opening of CETRAINER, I've tried to describe numerous times by also sending some videos in the past, the problem seems to be linked in some way to the "Reset Windows Position" setting, if you disable this check, the CETRAINER will return to opening normally, this problem is hard to notice, because it doesn't happen right away... it happens after about 10 times you try to open a CETRAINER.
On the other hand, if you uncheck the "Reset Windows Position" setting this no longer happens, but if you put the check back on after about 10 launches the CETRAINER will no longer open.
As I tried to send you some time ago in 2 videos, this show while tried to create a new CETRAINER from 0 by only putting 1 toggle on it and generating it, even on different PC,
after about 10 opening this not can more opened, unless uncheck the "Reset Windows Position" or leave this always unchecked,
but honestly it's not feasible that every opening finds everything reset, honestly I don't think it's a problem with my PC since I tried on 2.
I think another person on Patreon described the same problem to you about 2 months ago, but you're probably thinking the Heuristic anti-virus system, but I doubt it.
Anyway thanks for the tip.
Last edited by FIRESKY on Wed May 08, 2024 7:12 pm; edited 1 time in total |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 34
Joined: 16 Feb 2017 Posts: 1418
|
Posted: Wed May 08, 2024 6:57 pm Post subject: |
|
|
Check out the examples I gave.
Take what you need from it.
Or show the one closest to you in the same example.
Code: | if frm1 then frm1.Destroy() frm1=nil end
DP1=getScreenDPI()/96
frm1=createForm()
frm1.height=161*DP1 frm1.width=220*DP1
frm1.PopupMode=0 frm1.caption="separations"
frm1.Position="poDesktopCenter" frm1.ShowInTaskBar="stAlways"
frm1.BorderStyle="bsSingle"
-------------------------
local sprt = {}
----------------------- sprt.edt1 -----
sprt.edt1=createEdit(frm1)
sprt.edt1.AutoSize=true
sprt.edt1.height=23*DP1 sprt.edt1.width=160*DP1 sprt.edt1.left=10*DP1 sprt.edt1.top=29*DP1
sprt.edt1.text=""
sprt.edt1.alignment="taLeftJustify"
sprt.edt1.Font.Style="fsBold" sprt.edt1.Font.Size=0*DP1
-----------------------
----------------------- sprt.edt3 -----
sprt.edt3=createEdit(frm1)
sprt.edt3.AutoSize=true
sprt.edt3.height=23*DP1 sprt.edt3.width=160*DP1 sprt.edt3.left=10*DP1 sprt.edt3.top=100*DP1
sprt.edt3.text=""
sprt.edt3.alignment="taLeftJustify"
sprt.edt3.Font.Style="fsBold" sprt.edt3.Font.Size=0*DP1
-----------------------
----------------------- sprt.btn1 -----
sprt.btn1=createButton(frm1)
sprt.btn1.AutoSize=false
sprt.btn1.height=25*DP1 sprt.btn1.width=75*DP1 sprt.btn1.left=50*DP1 sprt.btn1.top=60*DP1
sprt.btn1.caption="Format"
sprt.btn1.Font.Style="fsBold" sprt.btn1.Font.Size=0*DP1
-----------------------
--############################################################################--
--############################################################################--
sprt.btn1.OnClick=function()
val = getAddressList().getMemoryRecordByDescription("bla bla")
sprt.edt1.Text=""
sprt.edt3.Text=""
if tonumber(val.Value) > 100 then
sprt.edt1.Text=""
sprt.edt3.Text=val.Value
--CEtrainer.Ceedit1.Text=""
elseif tonumber(val.Value) < 100 then
sprt.edt1.Text=val.Value
else
showMessage("Value: 100")
end
end
sprt.edt1.OnChange=function(sender) -- Just numbers!
if sender.Text=="" then return end
tn = tonumber(sender.Text)
if tn==nil then
showMessage("Just numbers!")
sender.Text=""
end
end
-- paste edit text: may value 28.333300 string!
sprt.edt3.OnChange=function(sender)
val = tonumber(sender.Text)
if val==nil then
res = string.match(sender.Text,"[%d%.]+") -- or "%d+%.?%d*"
print(res)
val = tonumber(res)
--sender.Text=val
end
-- or :
pst,ngt = math.modf(val)
if ngt~=nil then
if ngt~=0.0 then
print("Extracted value; "..ngt)
sender.Text=pst
end
end
end |
_________________
|
|
Back to top |
|
|
|
|
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
|
|