Jump to content




Lua Prompt Providing Additional Output with print()


  • You cannot reply to this topic
2 replies to this topic

#1 andrewsams

  • New Members
  • 2 posts

Posted 13 February 2014 - 05:05 PM

So if I invoke the print() function at the Lua prompt, I get what I expect to be displayed, but I also get a 1 on the following line of output. Is this a return value of 'true'?

Ex: print("Hello!")

Output:
Hello!
1

Can I suppress that second line of output (the 1) from displaying on the Lua prompt?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 13 February 2014 - 05:12 PM

What's going on here is twofold:

The print call writes a line to the screen.
The print call returns the number of lines it wrote. The Lua prompt prints the return value of the function (1).

You cannot suppress that output using the normal print function (nor should you want to), but if you really don't want to see that, you could use another function that wraps the print function and discards its return value:

function lprint(...)
  print(...)
end


#3 andrewsams

  • New Members
  • 2 posts

Posted 13 February 2014 - 10:44 PM

Most excellent, thank you for your time and expertise.





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users