LocalPlayer():ConCommand

Is there a delay in this command? I have the following code and it always clears console after completing the other operations.

[lua]concommand.Add(“print_table”, function()
LocalPlayer():ConCommand(“clear”)
for k,v in pairs(table) do
print(v)
end
end)[/lua]

Am I doing something wrong? Is there another, better method of doing this?


(User was banned for this post ("Undescriptive thread title" - Gran PC))

Why are you using a console command to run a console command? What is it you’re trying to do?

I want it so that the command print_table will clear console and then print a table full of different text…

For example;
[lua]
table = {
“Hello”,
“my name is”,
“zeppelin”
}[/lua]

I would want, in this example, for “Hello, my name is zeppelin” to appear in console, without any other text in my console.

Try running the print in the next frame

[lua]
concommand.Add(“print_table”, function()
LocalPlayer():ConCommand(“clear”)
timer.Simple(0, function()
for k,v in pairs(table) do
print(v)
end
end)
end)
[/lua]

Also it really isn’t a good idea to use “table” as a global variable name, you don’t want to overwrite the table library.

I still get the same effect when I run the command.

Also, table wasn’t the actual variable, but it would have been difficult to paste my entire function with variables.

Try 0.1 instead of 0, hacky but I don’t think there’s any other way around it

First; use RunConsoleCommand instead of LocalPlayer():ConCommand.
Second; A bit dirty but you could try running the “echo” concommand instead of doing the print.

Lua does not work that way.
Closest command however would probably be Msg( “shit here” )

RunConsoleCommand( “echo”, “shit here” )

I can’t use RunConsoleCommand(“clear”) (wiki page). Would it really be beneficial to use echo instead of print?

Since it’s clearing the screen after the prints I’m assuming that concommands get added to some kind of queue to be processed later on. If that’s the case using the echo command would add the prints to the same queue but after the clear command.