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 


How to read the description in the table line by line to Mem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
etioplmld
Advanced Cheater
Reputation: 0

Joined: 09 Feb 2021
Posts: 74

PostPosted: Mon Jul 05, 2021 7:50 pm    Post subject: How to read the description in the table line by line to Mem Reply with quote

to Memo, Tools for ct translation ,
After trying ,Finally it run
Code:

f = createForm(true)
f.Position=poDesktopCenter
f.Width=256
f.Height=288
f.Caption = 'Modify description '

local b1=createButton(f)
b1.Left=20
b1.Top=10
b1.caption='get'

local b2=createButton(f)
b2.Left=155
b2.Top=10
b2.caption='set'

local m=createMemo(f)
m.Height=180
m.Left=10
m.Top=50
m.Width=240
m.WordWrap=false
m.ScrollBars="ssAutoBoth"


b1.OnClick=function()
 local sr = m.getLines()
  al=getAddressList()
  for n=0, al.Count-1 do
  sr.String[n]=al[n].description
 end
end

b2.OnClick=function()
 local sr = m.getLines()
  al=getAddressList()
  for n=0, sr.Count-1 do
  al[n].description=sr.String[n]
 end
end
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Mon Jul 05, 2021 11:40 pm    Post subject: Reply with quote

A different approach..
Added some features..
Note: Asm will not receive script values. Handy for entries with addresses.

Code:
if f then f.Destroy() f=nil end
f = createForm(true)
f.Position=poDesktopCenter
f.Width=260
f.Height=288
f.Caption = 'Modify description '

local b1=createButton(f)
b1.Left=10
b1.Top=10
b1.caption='Line'

local b2=createButton(f)
b2.Left=175
b2.Top=10
b2.caption='All'

local b3=createButton(f)
b3.Left=10
b3.Top=235
b3.Width=120
b3.caption='DeleteAddrLine'

local m=createMemo(f)
m.Height=175
m.Left=10
m.Top=50
m.Width=240
m.WordWrap=false
m.ScrollBars="ssAutoBoth"

local e1=createEdit(f)
e1.Left=95 e1.Top=8 e1.Width=70 e1.ShowHint=true e1.TextHint="Line?"

local e2=createEdit(f)
e2.Left=140 e2.Top=233 e2.Width=40 e2.ShowHint=true e2.TextHint="Line or All"

local al=GetAddressList()

function formatTypes(t1)
-- source CE defines
if t1==0 then t1="Byte"
elseif t1==1 then t1="Word"
elseif t1==2 then t1="Dword"
elseif t1==3 then t1="Qword"
elseif t1==4 then t1="Single"
elseif t1==5 then t1="Double"
elseif t1==6 then t1="String"
--elseif t1==7 then t1="vtUnicodeString" --Only used by autoguess
elseif t1==7 then t1="WideString"
elseif t1==8 then t1="ByteArray"
elseif t1==9 then t1="Binary"
--vtAll=10
elseif t1==11 then t1="AutoAssembler"
end
return t1
end

function formatTypes1(t2)
t2=tostring(t2)
if t2=="Byte" then t2=0
elseif t2=="Word" then t2=1
elseif t2=="Dword" then t2=2
elseif t2=="Qword" then t2=3
elseif t2=="Single" then t2=4
elseif t2=="Double" then t2=5
elseif t2=="String" then t2=6
--elseif t1==7 then t1="vtUnicodeString" --Only used by autoguess
elseif t2=="WideString" then t2=7
elseif t2=="ByteArray" then t2=8
elseif t2=="Binary" then t2=9
--vtAll=10
elseif t2=="AutoAssembler" then t2=11
end
return t2
end
b1.OnClick=function()
  local x1=e1.Text
  if e1.Text=="" then x1=0 end
  x1=tonumber(x1)

    values=(x1.."___"..al[x1].Description.."___"..al[x1].Address.."___"..formatTypes(al[x1].Type).."___\n"):gsub(' ','_');
m.Lines.Add(values)

end

b2.OnClick=function()
m.Lines.Text=""
  for i=0, al.Count-1 do

    values=(i.."___"..al[i].Description.."___"..al[i].Address.."___"..formatTypes(al[i].Type).."___\n"):gsub(' ','_');
m.Lines.Add(values)

  end
end

m.OnDblClick=function()
  local al = getAddressList()
    local caption=(m.SelText):gsub(' ','_');

    counts=string.match(caption,"(.-)___")
    counts=tonumber(counts)
    caption=m.Lines[counts]
sleep(100)
    if caption==nil then
showMessage("Please select the line number at the beginning of the line.")
  else
  local almr = al.createMemoryRecord()
  des, addrr,typ,vl=string.match(caption,"___(.-)___(.-)___(.-)___")
  almr.Description=des
  almr.Address=addrr
  almr.Type=tonumber(formatTypes1(typ))

   end
end

b3.OnClick=function()
  local x2=e2.Text
  if e2.Text=="" then x2=0 end
  alcnt=al.Count - 1 --check 1 error message

cnt = addresslist_getCount(al)
 if e2.Text=="all" then
for i=0, cnt - 1 do
memoryrecord_delete(addresslist_getMemoryRecord(al, 0))
end
else

  x2=tonumber(x2)
  --print(x2)
for i1=0, cnt - 1 do
if i1==x2 then
desc2=al[x2].Description
  --print("desc2: "..desc2)
memoryrecord_delete(addresslist_getMemoryRecord(al, desc2))
else
if i==alcnt then
print("Row or record not listed!") end
end
end
end
end
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