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 


Perform an advanced search of the CE Lua Documentation.

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

Joined: 16 Feb 2017
Posts: 1462

PostPosted: Fri Jul 05, 2024 8:21 am    Post subject: Perform an advanced search of the CE Lua Documentation. Reply with quote

And hello again.

To briefly explain this article;
*Search the CE Lua document and Defines.
*Get links that also display results on the CE Forum via Google search.

How to use;

(Make sure you see the description picture.
However, if you are having trouble viewing the images on the site, click on the link of the image.
https://i.hizliresim.com/jfghp0u.PNG )

The options mentioned in the picture are, in order:

1) It provides a ready search list of the word indices taken from the CE Lua document and the defines document, respectively.
Choose and get the results.

2) Type the word you want to search. (For healthy results, write one word.)

3) Searches for the term written in box 2 in the Lua document, defines and Google.

4) Searches for the term written in box 2 in the CE lua document. If the box is empty, CE prints the entire Lua document.

5) Searches for the term written in box 2 in the CE Defines document. If the box is empty, CE Defines prints the entire document.

6) Result outputs are displayed here.

7) It takes the results of the Google search that are related to the CE Forum and creates a clickable and visitable list with their titles and links.

(Copy the code, put it in a text document with a ".lua" extension, and drop the document into the CE>>Autorun folder.)

You can start using it with a menu title called "CE_LUA_Docs" in the CE main menu.

The full code is as follows: (A lua package containing the entire code has been added at the end of the topic.
Download it, open it with notepad and check it (Make sure the links in the code do not take you to the wrong places!), then drop it into the "autorun" folder in the CE main folder and start using it.)

Code:
function ldLbrry()
if Lbry1 then Lbry1.Destroy() Lbry1=nil end
DP1=getScreenDPI()/96
Lbry1=createForm()
Lbry1.height=460*DP1 Lbry1.width=560*DP1
Lbry1.PopupMode=0 Lbry1.caption="AylinCE Trainers (2024)"
Lbry1.Position="poDesktopCenter" Lbry1.ShowInTaskBar="stAlways"
Lbry1.BorderStyle="bsNone"
Lbry1.setLayeredAttributes(0x000100, 255, LWA_COLORKEY | LWA_ALPHA )
Lbry1.Color=0x000100

-------------------------
local doc = {}
----------------------- doc.libmn1 ----- 
doc.libmn1=createPanel(Lbry1)
doc.libmn1.AutoSize=false
doc.libmn1.height=38*DP1 doc.libmn1.width=540*DP1 doc.libmn1.left=10*DP1 doc.libmn1.top=5*DP1
doc.libmn1.caption="Search  CE  Library"
doc.libmn1.Color=0x616161 doc.libmn1.Font.Color=0xF5F5F5
doc.libmn1.Font.Style="fsBold" doc.libmn1.Font.Size=14*DP1
doc.libmn1.BevelWidth=4
doc.libmn1.OnMouseDown=function() Lbry1.DragNow() end
doc.libmn1.Cursor = -22
-----------------------
----------------------- doc.libmn2 ----- 
doc.libmn2=createPanel(Lbry1)
doc.libmn2.AutoSize=false
doc.libmn2.height=400*DP1 doc.libmn2.width=540*DP1 doc.libmn2.left=10*DP1 doc.libmn2.top=47*DP1
doc.libmn2.caption=""
doc.libmn2.BevelWidth=4
doc.libmn2.Color=0x616161 doc.libmn2.Font.Color=0xF5F5F5
doc.libmn2.Font.Style="fsBold" doc.libmn2.Font.Size=10*DP1
-----------------------
----------------------- doc.btn1 ----- 
doc.btn1=createPanel(doc.libmn1)
doc.btn1.AutoSize=false
doc.btn1.height=24*DP1 doc.btn1.width=30*DP1 doc.btn1.left=5*DP1 doc.btn1.top=7*DP1
doc.btn1.caption="--"
doc.btn1.alignment="2"
doc.btn1.Font.Style="fsBold" doc.btn1.Font.Size=14*DP1
-----------------------
----------------------- doc.btn2 ----- 
doc.btn2=createPanel(doc.libmn1)
doc.btn2.AutoSize=false
doc.btn2.height=24*DP1 doc.btn2.width=30*DP1 doc.btn2.left=505*DP1 doc.btn2.top=7*DP1
doc.btn2.caption="X"
doc.btn2.alignment="2"
doc.btn2.Font.Style="fsBold" doc.btn2.Font.Size=14*DP1
-----------------------
----------------------- doc.edt1 ----- 
doc.edt1=createEdit(doc.libmn2)
doc.edt1.AutoSize=false
doc.edt1.height=25*DP1 doc.edt1.width=80*DP1 doc.edt1.left=190*DP1 doc.edt1.top=8*DP1
doc.edt1.text=""
doc.edt1.Color=0x616161
doc.edt1.Font.Style="fsBold" doc.edt1.Font.Color=0xF5F5F5
-----------------------
----------------------- doc.btn3 ----- 
doc.btn3=createPanel(doc.libmn2)
doc.btn3.AutoSize=false
doc.btn3.height=25*DP1 doc.btn3.width=70*DP1 doc.btn3.left=280*DP1 doc.btn3.top=8*DP1
doc.btn3.caption="Search"
doc.btn3.alignment="2"
doc.btn3.Font.Style="fsBold" doc.btn3.Font.Size=10*DP1
-----------------------
----------------------- doc.cmbx1 ----- 
doc.cmbx1=createComboBox(doc.libmn2)
doc.cmbx1.AutoSize=true
doc.cmbx1.height=25*DP1 doc.cmbx1.width=170*DP1 doc.cmbx1.left=10*DP1 doc.cmbx1.top=8*DP1
doc.cmbx1.text=""
doc.cmbx1.Font.Style="fsBold" doc.cmbx1.Font.Size=10*DP1
doc.cmbx1.ReadOnly=true doc.cmbx1.Style="csDropDownList"
-----------------------
----------------------- doc.rmemo1 ----- 
doc.rmemo1=createMemo(doc.libmn2)
doc.rmemo1.AutoSize=false
doc.rmemo1.height=225*DP1 doc.rmemo1.width=520*DP1 doc.rmemo1.left=10*DP1 doc.rmemo1.top=37*DP1
doc.rmemo1.Color=0x616161
doc.rmemo1.Font.Style="fsBold" doc.rmemo1.Font.Color=0xF5F5F5
doc.rmemo1.wordWrap=true
-----------------------
----------------------- doc.btn4 ----- 
doc.btn4=createPanel(doc.libmn2)
doc.btn4.AutoSize=false
doc.btn4.height=25*DP1 doc.btn4.width=90*DP1 doc.btn4.left=360*DP1 doc.btn4.top=8*DP1
doc.btn4.caption="Lua  Docs"
doc.btn4.alignment="2"
doc.btn4.Font.Style="fsBold" doc.btn4.Font.Size=10*DP1
-----------------------
----------------------- doc.btn5 ----- 
doc.btn5=createPanel(doc.libmn2)
doc.btn5.AutoSize=false
doc.btn5.height=25*DP1 doc.btn5.width=70*DP1 doc.btn5.left=460*DP1 doc.btn5.top=8*DP1
doc.btn5.caption="Defines"
doc.btn5.alignment="2"
doc.btn5.Font.Style="fsBold" doc.btn5.Font.Size=10*DP1
-----------------------

function createScrollBox(Parent)
local box = createComponentClass('TScrollBox', Parent)
 box.Parent = Parent
 return box
end
--############################################################################--
--############################################################################--

 executeCodeLocalEx('uxtheme.SetWindowTheme', doc.cmbx1.handle, "", "")
 doc.cmbx1.Color=0x616161 doc.cmbx1.Font.Color=0xF5F5F5
doc.rmemo1.ScrollBars=ssAutoBoth

function panelClickEffect(item2)
item2.BevelColor=clDefault
item2.BevelInner="bvRaised" item2.BevelWidth=3 item2.Font.Color=0xF5F5F5
item2.Font.Style="fsBold" item2.Hint=thint item2.ShowHint=true item2.OptimalFill=true
item2.Font.Name="Lucida" item2.Cursor=-21 item2.Color=0

item2.OnMouseMove=function() item2.BevelColor="0x00ffff" end
item2.OnMouseLeave=function() item2.BevelColor=clDefault end

end

panelClickEffect(doc.btn1) panelClickEffect(doc.btn2)
panelClickEffect(doc.btn3) panelClickEffect(doc.btn4)
panelClickEffect(doc.btn5)

--############################################################################--
--############################################################################--

local LTxt1 = ""
local LTxt2 = ""
local nextTop=5*DP1
local srcsend = 1

-----------------------
doc.Scrbx1=createScrollBox(doc.libmn2)
doc.Scrbx1.AutoSize=false
doc.Scrbx1.height=126*DP1 doc.Scrbx1.width=520*DP1 doc.Scrbx1.left=10*DP1 doc.Scrbx1.top=265*DP1
doc.Scrbx1.Color=0x616161 doc.Scrbx1.Font.Style="fsBold" doc.Scrbx1.Font.Size=10
-----------------------

function pageClear()
nextTop=5*DP1
doc.Scrbx1.Destroy() doc.Scrbx1=nil
doc.Scrbx1=createScrollBox(doc.libmn2)
doc.Scrbx1.AutoSize=false
doc.Scrbx1.height=126*DP1 doc.Scrbx1.width=520*DP1 doc.Scrbx1.left=10*DP1 doc.Scrbx1.top=265*DP1
doc.Scrbx1.Color=0x616161 doc.Scrbx1.Font.Style="fsBold" doc.Scrbx1.Font.Size=10
end

local doc1 = {}

function crtLabel(cpt,lnk, idx, opt)
doc1["titleLbl"..idx]=createLabel(doc.Scrbx1)
doc1["titleLbl"..idx].Left=10*DP1
doc1["titleLbl"..idx].Top=nextTop
doc1["titleLbl"..idx].Caption=cpt
doc1["titleLbl"..idx].Font.Size=11
doc1["titleLbl"..idx].height=40*DP1
doc1["titleLbl"..idx].width=500*DP1
doc1["titleLbl"..idx].Tag=490
doc1["titleLbl"..idx].Font.Color=0xF5F5F5
doc1["titleLbl"..idx].Cursor = -21
doc1["titleLbl"..idx].Font.Style = "fsBold"

 if opt==1 then
  doc1["titleLbl"..idx].OnClick=function()
   shellExecute(lnk)
  end

  doc1["titleLbl"..idx].OnMouseMove=function(sender)
   sender.Font.Color=0x00ff00
   sender.Font.Style = "fsBold,fsUnderline"
  end

  doc1["titleLbl"..idx].OnMouseLeave=function(sender)
   sender.Font.Style = "fsBold"
   sender.Font.Color=0xF5F5F5
  end
 end
nextTop=tonumber(nextTop) + 50
end

--############################################################################--
function LoadUrl(link)
  local int=getInternet()
  s=int.getURL(link)
  int.destroy()
  return s
end

local hex_to_char = function(x)
  return string.char(tonumber(x, 16))
end

local urldecode = function(url)
  if url == nil then
    return
  end
  url = url:gsub("+", " ")
  url = url:gsub("%%(%x%x)", hex_to_char)
  return url
end

function urlencode(str)
   str = string.gsub (str, "([^0-9a-zA-Z !'()*._~-])", -- locale independent
      function (c) return string.format ("%%%02X", string.byte(c)) end)
   str = string.gsub (str, " ", "+")
   return str
end

function srcLnk()
local aa11 = ""
if srcsend==1 then aa11=urlencode(doc.edt1.text) end
if srcsend==2 then aa11=urlencode(doc.cmbx1.text) end
aa1 =[[https://www.google.com/search?q=site%3Acheatengine.org+]]..aa11
aa2 = LoadUrl(aa1)

aa3 = (aa2):gsub([[href%=%"]], "\n"):gsub([[%/url%?q%=]], "\n")
--print(aa3)
sl = createStringList()
sl.Text = aa3
for i=0, sl.count -1 do
  aa4 = (sl[i])
  if string.find(aa4,[[www%.cheatengine%.org%/forum%/viewtopic%.php]]) then
    aa5=string.match(aa4,[[https://www%.cheatengine%.org%/forum%/viewtopic%.php(.-)&amp]])
    if aa5~=nil then
      aa6 = [[https://www.cheatengine.org/forum/viewtopic.php]]..aa5
      aa7 = (urldecode(aa6)):match("(.-)%&")
      --print(aa7)
      aa8 = LoadUrl(aa7)
      sl8 = createStringList()
      sl8.Text = (aa8):gsub('&',"")
      for i=0, sl8.count -1 do
        aa9 = urldecode(sl8[i])
        --print(aa9)
          aa10 = string.match(aa9, [[%<title%>(.-)%<%/title%>]])
          if aa10~=nil then
            --print(aa10)
            crtLabel(aa10,aa7,i,1)
          end
      end
      sl8.Destroy()
    end
  end
end
crtLabel("***   ***   ***   ***   ***","",222,2)
sl.Destroy()
end

--############################################################################--


cdir = getCheatEngineDir()

function all_trim(s)
   return s:match( "^%s*(.-)%s*$" )
end

doc.cmbx1.Items.Add("Search List")

function ldtxt()
local f1 = assert(io.open(cdir.."celua.txt", "r"))
LTxt1 = f1:read("*a")
f1:close()
local f2 = assert(io.open(cdir.."defines.lua", "r"))
LTxt2 = f2:read("*a")
f2:close()

   sl1 = createStringList()
   sl1.Text = LTxt1
   for i=0, sl1.Count -1 do
     a2 = sl1[i]
      if string.find(a2, "%:") then
        a3 = all_trim(string.match(a2, [[(.-)%:]]))
        if #a3>10 then
          doc.cmbx1.Items.Add(a3)
        end
      end
   end
   sl1.Destroy()
   sl2 = createStringList()
   sl2.Text = LTxt2
   for i=0, sl2.Count -1 do
     a2 = sl2[i]
      if string.find(a2, "%-%-") then
        a3 = all_trim(string.match(a2, [[%-%-(.-)]]))
        if #a3>10 then
          doc.cmbx1.Items.Add(a3)
        end
      end
   end
   sl2.Destroy()
 doc.cmbx1.ItemIndex=0
end

ldtxt()
--print(LTxt2)

function srchLst(tx,opt)
pageClear()
local sv = 0
local txt = string.lower(tx)
 if opt==1 then
   doc.rmemo1.Lines.Text=""
   sl = createStringList()
   sl.Text = LTxt1
   for i=0, sl.Count -1 do
     a1 = (sl[i]):lower()
      if sv == 1 then doc.rmemo1.Lines.Add(sl[i]) end
       if string.find(a1, txt) then
        doc.rmemo1.Lines.Add(" ")
        doc.rmemo1.Lines.Add("****** Lua  Documentation - Lines: "..i.." ******")
        doc.rmemo1.Lines.Add(sl[i])
        sv = 1
      end
      i2 = sl.Count - 2
     if i<i2 then
      a2 = sl[tonumber(i) + 1]
      if string.find(a2, "%:") then sv = 2 end
     end
   end
   sl.Destroy()
   srcLnk()
 end
 if opt==2 then
   doc.rmemo1.Lines.Text=""
   sl = createStringList()
   sl.Text = LTxt2
   for i=0, sl.Count -1 do
     a1 = (sl[i]):lower()
     if sv == 1 then doc.rmemo1.Lines.Add(sl[i]) end
     if string.find(a1, txt) then
       doc.rmemo1.Lines.Add(" ")
       doc.rmemo1.Lines.Add("****** CE  Defines - Lines: "..i.." ******")
       doc.rmemo1.Lines.Add(sl[i])
       sv = 1
     end
      i2 = sl.Count - 2
     if i<i2 then
      a2 = sl[tonumber(i) + 1]
      if string.find(a2, "%-%-") then sv = 2 end
     end
   end
   sl.Destroy()
   srcLnk()
 end
 if opt==3 then
   doc.rmemo1.Lines.Text=""
   sl = createStringList()
   sl.Text = LTxt1
   for i=0, sl.Count -1 do
     a1 = (sl[i]):lower()
     if sv == 1 then doc.rmemo1.Lines.Add(sl[i]) end
     if string.find(a1, txt) then
       doc.rmemo1.Lines.Add(" ")
       doc.rmemo1.Lines.Add("****** Lua  Documentation - Lines: "..i.." ******")
       doc.rmemo1.Lines.Add(sl[i])
       sv = 1
     end
      i2 = sl.Count - 2
     if i<i2 then
      a2 = sl[tonumber(i) + 1]
      if string.find(a2, "%:") then sv = 2 end
     end
   end
   sl.Destroy()
   sl1 = createStringList()
   sl1.Text = LTxt2
   sv = 0
   for i=0, sl1.Count -1 do
     a1 = (sl1[i]):lower()
     if sv == 1 then doc.rmemo1.Lines.Add(sl1[i]) end
     if string.find(a1, txt) then
       doc.rmemo1.Lines.Add(" ")
       doc.rmemo1.Lines.Add("****** CE  Defines - Lines: "..i.." ******")
       doc.rmemo1.Lines.Add(sl1[i])
       sv = 1
     end
      i2 = sl.Count - 2
     if i<i2 then
      a2 = sl[tonumber(i) + 1]
      if string.find(a2, "%-%-") then sv = 2 end
     end
   end
   sl1.Destroy()
   srcLnk()
 end
end

doc.btn3.OnClick=function()
  if doc.edt1.text=="" then
    showMessage("Please type the text to search for in the box!")
  else
    srcsend=1
    srchLst(doc.edt1.text,3)
  end
end

doc.btn4.OnClick=function()
  if doc.edt1.text=="" then
    doc.rmemo1.Lines.Text=""
   sl = createStringList()
   sl.Text = LTxt1
   for i=0, sl.Count -1 do
     a1 = sl[i]
    doc.rmemo1.Lines.Add(i.." -> "..a1)
   end
   sl.Destroy()
  else
    srcsend=1
    srchLst(doc.edt1.text,1)
  end
end

doc.btn5.OnClick=function()
  if doc.edt1.text=="" then
    doc.rmemo1.Lines.Text=""
   sl = createStringList()
   sl.Text = LTxt2
   for i=0, sl.Count -1 do
     a1 = sl[i]
    doc.rmemo1.Lines.Add(i.." -> "..a1)
   end
   sl.Destroy()
  else
    srcsend=1
    srchLst(doc.edt1.text,2)
  end
end

doc.cmbx1.OnChange=function()
local indd1=doc.cmbx1.ItemIndex
  if indd1~=0 then
    srcsend=2
    srchLst(doc.cmbx1.text,3)
  end
end


doc.btn1.OnClick=function()
 Lbry1.WindowState="wsMinimized"
end

doc.btn2.OnClick=function()
 Lbry1.Close()
end

end

--############################################################################--
--############################################################################--
mf11 = MainForm
mMenu11=mf11.Menu.Items

if ceLibrry1 then ceLibrry1.Destroy() ceLibrry1=nil end
ceLibrry1=createMenuItem(mf11.mMenu11)
ceLibrry1.Caption="CE_LUA_Docs"
menuItem_setShortcut(ceLibrry1,"Ctrl+L")

mMenu11.insert(mMenu11.Count-1, ceLibrry1)
ceLibrry1.OnClick = ldLbrry
--############################################################################--
--############################################################################--


Until we meet again on another topic, I hope you can get a little closer to the codes.
Enjoy it.



ek1.PNG
 Description:
 Filesize:  22.79 KB
 Viewed:  7812 Time(s)

ek1.PNG



ce_srch_lua_lbrry.lua
 Description:

Download
 Filename:  ce_srch_lua_lbrry.lua
 Filesize:  13.45 KB
 Downloaded:  451 Time(s)


_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3282

PostPosted: Mon Jul 08, 2024 5:28 am    Post subject: Reply with quote

Can ChatGPT help with this?
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 34

Joined: 16 Feb 2017
Posts: 1462

PostPosted: Mon Jul 08, 2024 10:32 am    Post subject: Reply with quote

Csimbi wrote:
Can ChatGPT help with this?


ChatGPT wrote:
Of course, you can search for a specific string within a specific txt file with a simple Lua code like this:

Code:
function searchInFile(fileName, searchTerm)
  local file = io.open(fileName, "r")
  if not file then
    return " File not found!"
  end

  local found = false
  for line in file:lines() do
    if string.find(line, searchTerm) then
      print(line.."\n"..searchTerm) -- "AylinCE" added this line! ;)
      found = true
      break
    end
  end

  file:close()

  if found then
    return "Searched string found"
   else
     return " The searched string was not found"
   end
end

local fileName = "example.txt" -- Add the name and path of the file to search here.
local searchTerm = "specific_string" -- Add the word or string you're looking for here.

print(searchInFile(fileName, searchTerm))


When you run this code it will check if the specified string exists in the specified txt file. You will need to update the `fileName` and `searchTerm` variables to suit your needs.
I hope it helps the friend who asked the question.


Quote:
I hope it helps the friend who asked the question.

Cool Very Happy

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Extensions 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