Giter Club home page Giter Club logo

cc-text-formatter's Introduction

Text Formatter

Text formatter (tf) is a basic computer craft text formatting system used for creating inline coloured text.

Examples

local tf = require("tf")

local width, height = term.getSize()

local header = tf.createString("$b7 Current status ")
header = tf.align(header, width, "centre")
tf.write(header)

tf.print("$f8Turtle$f_    Mining Turtle           $feOffline")
tf.print("$f8Turtle$f_    Farming Turtle          $f5Online")
tf.print("$f8Server$f_    Chat Server             $f5Online")

Screenshot of the text produced by the above code

local tf = require("tf")

tf.print("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam eu $c74elit eu turpis$c__ porta eleifend vitae a tortor.\nQuisque congue ultricies urna, ac tincidunt urna eleifend a.\nVestibulum $c74posuere ipsum sit$c__ amet sem dapibus egestas. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc luctus $c74facilisis felis$c__ sit amet sagittis.\nPellentesque in laoreet augue, eget egestas eros. Duis tincidunt sodales elit eu feugiat. Aenean ut $c74dictum arcu, eget aliquet$c__ ex.")

Screenshot of the text produced by the above code

How to use

Formatting

Tags are used to swich or suggest the formatting of the text. Tags always start with a $ therefore in order to have a $ as text you need to type $$. The current tags are shown in the table below.

Tag Purpose
$f{1} Switch the colour of the text to be {1} where {1} is a hexadecimal digit referring to the colour in the current colour palette or a _ specifying to use the default foreground colour.
$b{1} Switch the colour of the background below the current text to be {1} where {1} is a hexadecimal digit referring to the colour in the current colour palette or a _ specifying to use the default background colour.
$c{1}{2} Switch the foreground and background colour of the text to be {1} and {2} respectively. Equivelent to $f{1}$b{2}.
$$ Writes a single $ character.

For example, to send a message such as ERROR Turtle is on fire! with the word ERROR having a red background and the word fire in orange, you would use $beERROR$bf Turtle is on $f1fire$f0!.

Quick start guide

For more detailed doccumentaion on every function please see the wiki page.

Installing

Type the following command into the terminal to download the required lua file.

wget https://raw.githubusercontent.com/Mcrevs/cc-text-formatter/main/tf.lua

Importing

Add this to the start of your program file to include the library.

local tf = require("tf")

Printing

Print a coloured string accross multiple lines if required.

tf.print("$feH$f1E$f4L$f5L$fbL$faO$f0 $cfeW$b1O$b4R$b5L$bbD$ba!")

cc-text-formatter's People

Contributors

mcrevs avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.