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 


CE 6.8+ makes printing new lines as "\r\n" instead

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

Joined: 02 May 2018
Posts: 28

PostPosted: Tue Nov 13, 2018 6:11 pm    Post subject: CE 6.8+ makes printing new lines as "\r\n" instead Reply with quote

EDIT: Appears that this is due to a Windows update and not CE itself

As of Cheat Engine 6.8 and above, the Lua print command will not output "\n" as a new line, instead I have to use "\r\n"

For example:
Code:
print("hello\nworld")
prints:
helloworld

Code:
print("hello\r\nworld")
prints:
hello
world

Is there any way to make "\n" work again?


Last edited by Kamd on Tue Nov 13, 2018 7:59 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25295
Location: The netherlands

PostPosted: Tue Nov 13, 2018 6:28 pm    Post subject: Reply with quote

Perhaps some system setting on your windows install. Did you recently update windows ?

\n won't work in 6.7 (or 6.8)
\n\r also won't work in 6.7 (or 6.8)

Wait for 6.9 which scans for /n and then splits up the lines into separate strings before sending it to the output (TMemo object)

_________________
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
View user's profile Send private message MSN Messenger
Kamd
Cheater
Reputation: 1

Joined: 02 May 2018
Posts: 28

PostPosted: Tue Nov 13, 2018 7:29 pm    Post subject: Reply with quote

Yeah, I think it's due to Windows. Just tried on CE 6.6 right now, and "\n" still doesn't work.

I'll have to wait for 6.9. Thanks.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1257

PostPosted: Tue Nov 13, 2018 7:37 pm    Post subject: Re: CE 6.8+ makes printing new lines as "\r\n" ins Reply with quote

Kamd wrote:


Is there any way to make "\n" work again?



You can use a memo for now, Example:

Code:
form = createForm(true)
form.Position = poDesktopCenter
form.Width = 200
form.Height = 100

memo1 = createMemo(form)
memo1.Top = 0
memo1.Left = 0
memo1.Width = form.Width
memo1.Height = form.Height
memo1.Lines.Text = "hello\nworld\nhello\nworld"

_________________
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
Kamd
Cheater
Reputation: 1

Joined: 02 May 2018
Posts: 28

PostPosted: Tue Nov 13, 2018 8:27 pm    Post subject: Re: CE 6.8+ makes printing new lines as "\r\n" ins Reply with quote

Aylin wrote:
You can use a memo for now


Thanks for your suggestion. However I want to stick with print and not memo

Here is my simple workaround for now:
Code:

function print2(text)
  local newTxt = text:gsub("\n","\r\n")
  print(newTxt)
end

print2("hello\nworld")


My main concern is for existing scripts/no-window trainers which rely on print "\n" for newline.
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 55

Joined: 01 Oct 2008
Posts: 942

PostPosted: Tue Nov 13, 2018 11:32 pm    Post subject: Reply with quote

was being blocked before, don't why...
http://fearlessrevolution.com/viewtopic.php?f=16&t=8249
... has been unblocked?

ADDED:
modify the line containing 'select' allow to post.

previous post:
---------------
You may make an autorun lua script to replace print function:
Code:

if not ori_print then
  crlf, ori_print, print = "\r\n", print, function(...)
    local r, sel = {}, select
    for i=1,sel("#",...)do r[i]=tostring(sel(i,...)) end
    return ori_print( (table.concat(r,"\t"):gsub("[\r]*[\n]",crlf)) )
  end
end

--- test
local ss = "a test\n\n\r\r\n\n2test"
ori_print(1,nil,2,3,4,ss)
print(1,nil,2,3,4,ss)
-- output on console look like (being edited)
1  2 3 4 a test
2test
1   nil   2   3   4   a test



2test

_________________
- Retarded.
Back to top
View user's profile Send private message
Kamd
Cheater
Reputation: 1

Joined: 02 May 2018
Posts: 28

PostPosted: Thu Nov 15, 2018 7:59 pm    Post subject: Reply with quote

panraven wrote:
You may make an autorun lua script to replace print function:


Nice! I'll use this, thanks Smile
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