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 


2 questions, [Help] for Single Project.

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

Joined: 16 Feb 2017
Posts: 1260

PostPosted: Thu Jun 27, 2019 8:59 am    Post subject: 2 questions, [Help] for Single Project. Reply with quote

I'm trying to complete a project.
I must correct and use one of the following 2 alternatives.

Let me tell you from the start:
I've used the CEF search function for 3 days.
I didn't get a close conclusion.
My question: The line I clicked in CEMemo should write to CEEdit.
But the following code writes all CEMemo lines.
Is there a way to get the text on the line?

Code:
function CEMemo1Click(sender)
   index = control_getCaption(UDF1.CEMemo1);
   if index then
UDF1.CEEdit1.Text=(index)
end
end


or I can get another suggestion:
I can get a list from a txt file.
but the whole list comes as a single line into CEComboBax.
How do I get the entire list one after the other?

(Code Creator: @mgr.inz.Player and Thanks)
Code:
function ListLoad(sender)
  if path then
    local settingsFile = io.open(path.."List.txt", "r")
    if (settingsFile ~= nil) then
      name = settingsFile:read("*a")
      UDF1.CEComboBox1.Items.Add(name)
      settingsFile:close()
    end
  end
end


Whichever proposal is resolved, I will use it. Smile
Thanks in advance for the help.

_________________
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
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Jun 27, 2019 2:48 pm    Post subject: Reply with quote

This seems to work to get the line the cursor is in for a Memo, there doesn't seem to be an option for that currently...
Code:
function getMemoLineWithCursorOrSelection(m)
  local start = m.SelStart
  local ending = m.Lines.Text:find('\n', start)
  if ending then ending = ending - 2 else ending = #m.Lines.Text end
  -- adjust start by finding previous new line for start of "selected" line
  start = m.Lines.Text:sub(0,start):match('^.*()\n')
  if start then start = start+1 else start = 0 end
  return m.Lines.Text:sub(start, ending)
end
local s = getMemoLineWithCursorOrSelection(UDF1.CEMemo1)
return ("got '%s' as the line"):format(s)
Of course if you're willing to make them select the line then you can just use UDF1.CEMemo1.SelText

edit: I should note that the function ignores "soft" line wrapping, which is on by default. So if the user writes a long line without pressing enter which then wraps onto the next line visually in the memo, the function will still see everything until an actual newline as one "line".

the latter should be as simple as
for line in settingsFile:read("*a"):gmatch('[^\n]+') do UDF1.CEComboBox1.Items.Add(line) end

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1260

PostPosted: Thu Jun 27, 2019 3:52 pm    Post subject: Reply with quote

big thanks @FreeER, Your critical codes saved me.

Code:
for line in settingsFile:read("*a"):gmatch('[^\n]+') do UDF1.CEComboBox1.Items.Add(line) end


Code:
function ListLoad(sender)
UDF1.CEComboBox1.Clear()
  if path then
    local settingsFile = io.open(path.. "List.txt", "r")
    if (settingsFile ~= nil) then
--      name = settingsFile:read("*a")
    for line in settingsFile:read("*a"):gmatch('[^\n]+') do
    UDF1.CEComboBox1.Items.Add(line)
    --  settingsFile:close()
    end
    settingsFile:close()
  end
end
end


and the CEComboBox1 solution is better than using CEMemo.
Too much space opened and convenient. Wink

Thanks again @FreeER ..

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

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Jun 29, 2019 8:05 am    Post subject: Reply with quote

or select every time text has selected on CEMemo then CEEdit text will display the selected text. Select texts on CEMemo by hold left mouse button and drag to selecting text.

Code:
UDF1.show()

function CEMemo1MouseUp(sender, button, x, y)
UDF1.CEEdit1.Text = UDF1.CEMemo1.SelText
end

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1260

PostPosted: Sat Jun 29, 2019 9:04 am    Post subject: Reply with quote

Corroder wrote:
or select every time text has selected on CEMemo then CEEdit text will display the selected text. Select texts on CEMemo by hold left mouse button and drag to selecting text.

Code:
UDF1.show()

function CEMemo1MouseUp(sender, button, x, y)
UDF1.CEEdit1.Text = UDF1.CEMemo1.SelText
end


This is a good solution thanks @Corroder
However, during the registration of the list title:
"(space character)" should be replaced with "_".
So: If "Game Code" is written,
Must be Game_Code.
CEMemo1 selects the word, not the line,
So the word should be written united, without spaces.
If the user leaves a space between words,
this space must be replaced by "_".
Is there a solution to this? Smile

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

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Jun 29, 2019 9:22 am    Post subject: Reply with quote

Code:
UDF1.show()

function CEMemo1MouseUp(sender, button, x, y)
txt = UDF1.CEMemo1.SelText
txt = txt:gsub("%s+", "_")  -- change every space with _
-- or
-- txt = txt:gsub("%s+", "")  -- delete every space
UDF1.CEEdit1.Text = txt
end

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sat Jun 29, 2019 9:26 am    Post subject: Reply with quote

Code:
UDF1.CEEdit1.Text = (UDF1.CEMemo1.SelText):gsub(' ','_');

Edit:
beat me to it Smile)

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1260

PostPosted: Sat Jun 29, 2019 11:05 am    Post subject: Reply with quote

Smile Smile Thanks DaSpamer Smile

Here's the last question.
New titles are available in the list, test whether:
Here's an example, but it didn't give me the result I wanted.

Code:
function CEButton2Click(sender)
txt = UDF1.CEEdit2.Text
txt = txt:gsub("%s+", "_")
if txt==UDF1.CEMemo2.seltext then
showMessage("Code available in the list!")
else
UDF1.CEMemo2.Lines.Add(txt)
ListSave()
CreateFile()
showMessage("Code page successfully added to list!")
end
end


Final Proge:



Ekran 23.JPG
 Description:
 Filesize:  71.94 KB
 Viewed:  4110 Time(s)

Ekran 23.JPG



_________________
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
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sat Jun 29, 2019 11:37 am    Post subject: Reply with quote

Couldn't quite understand what are you trying to do?
Exaplain what you're trying to do?
create file and save memo content based on the on the selection in the listbox?

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1260

PostPosted: Sat Jun 29, 2019 11:51 am    Post subject: Reply with quote

The following code:
opens a new file with the given name and
saves this file to the list.
Question: The name of the new file,
How to check if it is available in the list?

Code:
function CEButton2Click(sender)
txt = UDF1.CEEdit2.Text
txt = txt:gsub("%s+", "_")
if txt==UDF1.CEMemo2.seltext then
showMessage("Name Available in list. Please use another name.")
else
UDF1.CEMemo2.Lines.Add(txt)
ListSave()
CreateFile()
showMessage("Code page successfully added to list!")
end
end

_________________
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
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sat Jun 29, 2019 1:05 pm    Post subject: Reply with quote

Code:
function CEButton2Click(sender)
   local caption = (UDF1.CEEdit2.Text):gsub(' ','_');
   for line in (UDF1.CEMemo2.Lines.Text):gmatch('[^\r\n]+') do
      if (line == caption) then
         showMessage('Name already exists in the list\npick a different one');
         return; -- end the function here
      end
   end
   UDF1.CEMemo2.Lines.Add(caption);
   ListSave()
   CreateFile()
   showMessage("Code page successfully added to list!")
end

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1260

PostPosted: Sat Jun 29, 2019 1:28 pm    Post subject: Reply with quote

DaSpamer wrote:
Code:
function CEButton2Click(sender)
   local caption = (UDF1.CEEdit2.Text):gsub(' ','_');
   for line in (UDF1.CEMemo2.Lines.Text):gmatch('[^\r\n]+') do
      if (line == caption) then
         showMessage('Name already exists in the list\npick a different one');
         return; -- end the function here
      end
   end
   UDF1.CEMemo2.Lines.Add(caption);
   ListSave()
   CreateFile()
   showMessage("Code page successfully added to list!")
end



Thanks @DaSpamer.
Again, the codes were created with the help of many masters,
but it gave good results for the archive. Smile

I'il share this. (Of course, mentioning the contributors)
I'm gonna shoot a video.
I will then share the Lua extension.

_________________
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 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