Log In  
Follow
scottmada

This maybe not new for some users, but I did search the forums and I didn't found any post about this, so...

ANSI escape codes do work on Pico-8!
when using
printh()

Let me explain. ANSI escape codes are sets of commands to use in terminals to "control the formatting, color, and other output options on video text terminals".

Yes. And what? (you say)

It means a lot! Look at this piece of code. It clears the screen on _init(). And it sets text to green, then resets it to the default color afterwards. (PSST... It may be useful for debugging purposes!)

function _init()
   init_console()
   printh("what is this? color??")
end

function init_console()
  -- note: ansi escape codes 
  -- are case-sensitive.
  -- note: printh still adds a 
  -- new line each time you
  -- call it, even if it only 
  -- contains escape codes.

  -- clear the screen
  -- ("\27" is esc char)
  -- ("\74" is capital j)
  a_clear = "\27[2\74"

  -- reset the cursor top left
  -- ("\72" is capital h)
  a_cur_tl = "\27[1;1\72"

  -- set to green
  a_col_gr = "\27[32m"

  -- reset color to default
  a_col_df = "\27[39;49m"

  -- let's print some text
  printh(
    a_clear ..
    a_cur_tl ..
    a_col_gr ..
    "==> console initialized..." ..
    a_col_df
  )
end

[ Continue Reading.. ]

6
1 comment



Cart #23349 | 2016-06-21 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

View on Github.com

You miss built-in lua functions such as ipairs or getmetatable in pico-8? Well, fear no more.

Currently supported Lua "built-in" functions

    getmetatable
    setmetatable
    rawget
    unpack
    ipairs
    table.pack
    table.unpack as an alias to unpack
    table.insert
    table.remove
    table.sort

Tested to imitate their counterparts

Travis-CI is set to test missing.lua against test.lua, which compares results of this library functions with the built-in ones. Well, tests may be incomplete, so do not hesitate to flag a bug to the issue tracker if something goes wrong.

[b]How to use

[ Continue Reading.. ]

4
4 comments