This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
hbomb79's profile picture

New Characters

Started by hbomb79, 07 January 2016 - 03:09 AM
hbomb79 #1
Posted 07 January 2016 - 04:09 AM
I give up looking for it, I cannot find out how to draw the new smaller characters added in 1.76.
Anavrins #2
Posted 07 January 2016 - 04:28 AM
There are two ways of drawing them.
Either by using string.char, with s = string.char(169), or using escape characters, like s = "\169"
Both option will have the © character in the s variable.
Edited on 07 January 2016 - 03:30 AM
Bomb Bloke #3
Posted 07 January 2016 - 05:21 AM
If you're wondering how to draw images with them, then the code here gives a pretty good illustration of the mechanics involved.
3d6 #4
Posted 07 January 2016 - 01:36 PM

local function box(bc) -- Box drawing api by 3d6
if #bc ~= 8 then return false end
local a = {}
for i=1,8 do
  a[i] = bc:sub(i,i)
end
for i=1,6 do
  if not string.gmatch("01",a[i]) then return false end
  a[i] = tonumber(a[i])
end
for i=7,8 do
  if not string.gmatch("0123456789abcdef",a[i]) then return false end
  a[i] = 2^tonumber(a[i],16)
end
if a[6] == 1 then
  term.setBackgroundColor(a[7])
  term.setTextColor(a[8])
else
  term.setBackgroundColor(a[8])
  term.setTextColor(a[7])
end
local c = 128
for i=1,5 do
  if a[i] ~= a[6] then
   c = c + 2^(i-1)
  end
end
term.write(string.char(c))
return true
end
This function takes an 8 character string as instructions to draw a box drawing character. The first six are either 0 or 1, and control which color each "pixel" takes on, from left to right, top to bottom. The last two are the color codes in paint format, one for the background (0s) and one for the foreground (1s). I use this for most box-drawing situations.

Example: "box(10101078)"