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 


I can't get io.stdout:write to work... Any ideas?

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

Joined: 30 Jan 2023
Posts: 156

PostPosted: Tue Jun 10, 2025 2:31 pm    Post subject: I can't get io.stdout:write to work... Any ideas? Reply with quote

For the first time ever, I've been trying to utilize io.stdout:write ...but I'm not having any success, and I'm wondering what I may be doing wrong since I've never used it before.

When I open the LUA Engine and execute this as a test, nothing gets printed...

Code:
io.stdout:write("Hi")


Based on suggestions I found when searching, I also have tried using io.flush() along with it, without success.

I'm wondering what I may be missing when it comes to using io.stdout:write instead of print? I need to print some lines without the default ending space/newline that "print" applies by default, and I thought io.stdout:write could be the solution.

Possible important detail: I will be running 2 instances of CE while using this, if that matters at all... however, even when I test using only 1 instance of CE, it still fails.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 36

Joined: 16 Feb 2017
Posts: 1512

PostPosted: Tue Jun 10, 2025 4:25 pm    Post subject: Reply with quote

It promises to simply remove the extra space at the end of the line in the output of "print".

Use:

Code:
local output, exitCode = runCommand("cmd.exe", {"/C", "echo Hi World!"})
print("Command Output:", output) -- Redirecting through cmd

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

Joined: 30 Jan 2023
Posts: 156

PostPosted: Wed Jun 11, 2025 2:25 pm    Post subject: Reply with quote

AylinCE wrote:
Code:
local output, exitCode = runCommand("cmd.exe", {"/C", "echo Hi World!"})
print("Command Output:", output) -- Redirecting through cmd


This works great on one of the CE instances I run, but the second CE instance is an older version that doesn't support runCommand. Is there possibly a way to duplicate this result (no trailing space on print) on the older CE also, which is CE 6.5?
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 36

Joined: 16 Feb 2017
Posts: 1512

PostPosted: Thu Jun 12, 2025 3:58 am    Post subject: This post has 1 review(s) Reply with quote

I assume this will work on all CE versions.

Instead of "print()" for printing, you should use the "Lines.Add()" method.

The "Lines.Add()" method does not add a space at the end of the line.
It is easy to copy and print. (Lines.Text)

Code:
local obj = getLuaEngine()
local prtMemo

for i = 0, obj.ComponentCount - 1 do
  if obj.Component[i].className=='TMemo' then
    prtMemo = obj.Component[i]
    print("Output name: "..obj.Component[i].Name) -- 7.5..>mOutput
  end
end

prtMemo.Lines.Add("Hello CE")
prtMemo.Lines.Add("Hello CE..1")
prtMemo.Lines.Add("Hello CE..2")

text = prtMemo.Lines.Text

print(text)


And this is the "print()" method:

Code:
local obj = getLuaEngine()
local prtMemo

for i = 0, obj.ComponentCount - 1 do
  if obj.Component[i].className=='TMemo' then
    prtMemo = obj.Component[i]
    --print("Output name: "..obj.Component[i].Name) -- 7.5..>mOutput
  end
end

local print = function(s) return prtMemo.Lines.Add(s) end

print("Hello CE")
print("Hello CE..1")
print("Hello CE..2")
print("<<<--->>>")

text = prtMemo.Lines.Text

print(text)

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

Joined: 30 Jan 2023
Posts: 156

PostPosted: Thu Jun 12, 2025 11:55 am    Post subject: Reply with quote

Both of these methods you supplied are working great on older versions I tested. This is a fantastic workaround to avoid those white spaces everywhere. Thank you very much for your help and creativity with this!
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 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