Luart
Comprehensive Windows framework to develop in Lua
modules > console > y

console.y read/write property

The console.y property gets or sets the current cursor line position.

Example


local console = require "console"

function title(msg, linepos)
	local length = math.floor((console.width-string.len(msg))/2)
	console.clear("black")
	console.y = linepos or 1
	console.bgcolor = "lightblue"
	console.writecolor("blue", string.rep(string.char(0xE2, 0x96, 0x80), console.width))
	console.writecolor("brightwhite", string.rep(' ', length)..msg)
	console.write(string.rep(' ', console.width-length-string.len(msg)))
	console.bgcolor = "blue"
	console.writecolor("lightblue", string.rep(string.char(0xE2, 0x96, 0x80), console.width))
	console.bgcolor = "black"
	console.writeln("\n\n\n")
end

title("Hello World !", 1)