Sidebar

x

Console library for Lua 5.3 (Linux)

Lua 5.3 Console library is a basic remake of Console class from C# language, which, has goal to help you make sprites or manage the console's I/O

It does have more options for some functions, such as ReadLine(hide Input?, timeout?), ReadKey(hide Input?, maxKeys?, timeout?) or ClearLine(from begin of the line?)

The script is new, and does not have all the abilities of the original Console class from C#..


Requirements :

  1. ‚ÄčBash,
  2. Sleep command,


Exemple:

local Console = require("console")

Console.Write("Hello ")
Console.WriteLine("World!")
Console.Write("Enter your name: ")

local name = Console.ReadLine()

Console.Write("Good day, ")
Console.Write(name)
Console.WriteLine("!")


Features and Properties: 

Write: Outputs something to the console.

nil Console.Write([string / float / boolean Data = ""])

WriteLine: Outputs something to the console, with a line-return at the end.

nil Console.Write([string / float / boolean Data = ""])

Read: Reads and returns the console input's data to lua. File I/O Reference: https://www.tutorialspoint.com/lua/lua_file_io.htm

string Console.Read([string / int Mode = "*a"])

ReadLine: Reads one line from the console input's data.

string Console.ReadLine([boolean hideInput = false, float timeout = nil])

ReadKey: Reads only one or more length from the console input's data.

string Console.ReadKey([boolean hideInput = false, int maxKeys = 1, float timeout = nil])

Clear: Clears the whole console's screen.

nil Console.Clear()

ClearLine: Clears the current cursor's line, from it's begining or not.

nil Console.ClearLine([boolean fromBegining = true])

ClearLength: Basicly clears the following charaters next to the cursor.

nil Console.ClearLength(int Length)

Echo: Displays or not the console's user input (unrecommended if your script is not stable !!!)

nil Console.Echo([boolean show])

Cursor: Shows or hides the cursor, if the argument is omitted, it toggles.

nil Console.Cursor([boolean show])

Fonts:

Colorize: Colorizes the next outputs.

nil Console.Fonts.Colorize([int Text, int Background])

Underline: Sets or remove an underline, if the argument is omitted, it toggles.

nil Console.Fonts.Underline([boolean underline])

Reset: Resets the underline and colors.

nil Console.Fonts.Reset()

Movements:

SetPosition: Sets the cursor's coordinates.

nil Console.Move.SetPosition(<int X, int Y>)

Save: Saves the current coordinates

nil Console.Move.Save()

Restore: Restores to the saved coordinates

nil Console.Move.Restore()

Back: Returns to the begining of the current line.

nil Console.Move.Back()

Up/Down/Right/Left: Moves relatively to the current cursor's coordinates.

nil Console.Move.Up(<int Amount = 1>)


Download:

Click here to download and here to see the source code (Version 1.1)



Install CloudLinux OS on CentOS 7
 

Comments

No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Guest
Sunday, 18 November 2018