Console script

tung's picture

Console taking keyboard input

Ever wished that Sphere's graphical engine could act a bit more like the old text consoles? This may well be what you're looking for!

The Sphere console script can display and accept text input sequentially. Could be handy if you want to make a simple text adventure in Sphere.

Screenshots

The bar on the right indicates how much text has been shown so far

Features

  • Displays text lines, scrolling them up as you go
  • Shows lines word-wrapped automatically
  • Accepts keyboard input with your printed text
  • A choice of blocking and non-blocking display methods
  • Allows custom fonts, window styles and backgrounds

Usage

Put tnb_console.js in your scripts/ directory, and include it in your main script:

RequireScript("tnb_console.js");

Create a new Console object:

var funky_console = new Console();

For output, call the Console.print method:

funky_console.print("I am some output text.");

You can display the console with the Console.render method:

if (funky_console.needUpdate) {
  funky_console.render();
  FlipScreen();
}

For input, you can provide a default value if you want:

var user_name = funky_console.input("Bob");

Download