Jump to content




New Characters


  • You cannot reply to this topic
3 replies to this topic

#1 hbomb79

  • Members
  • 352 posts
  • LocationOrewa, New Zealand

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.

#2 Anavrins

  • Members
  • 775 posts

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 by Anavrins, 07 January 2016 - 04:30 AM.


#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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.

#4 3d6

  • Members
  • 336 posts

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)"





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users