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

New Character Issues 1.7.6

Started by Endergreen117, 17 January 2016 - 07:03 AM
Endergreen117 #1
Posted 17 January 2016 - 08:03 AM
I just saw the new character functionality added be ComputerCraft 1.7.6, so I decided to play around a little bit and see what I could do with them. I decided i'd try to print a sword graphic, based on the following image:

Unfortunately, it refuses to print the one pixel at the start of the blade, as seen here:




Here's the code I used:


function getDrawingCharacter(...)  -- Bools for topLeft, topRight, left, right, bottomLeft, bottomRight
		local data = 0
		for i = 1, #arg - 1 do if arg[i] then data = data + 2^(i-1) end end
		return {char = string.char(arg[6] and 159 - data or 128 + data), inverted = arg[6]}
end

term.setBackgroundColor(32768)
term.setTextColor(1)

spr0 = mkspr(false, false, false, false, false, false)
spr1 = mkspr(false, false, false, false, false, false)
spr2 = mkspr(false, false, false, true, true, false)
spr3 = mkspr(true, true, false, true, true, false)
spr4 = mkspr(false, true, false, true, false, false)
spr5 = mkspr(false, true, true, false, true, true)
spr6 = mkspr(false, true, true, false, false, false)
spr7 = mkspr(false, false, false, false, false, false)
spr8 = mkspr(false, true, true, false, false, false)
spr9 = mkspr(false, true, false, false, false, false)
spra = mkspr(true, false, false, false, false, false)
sprb = mkspr(false, false, false, false, false, false)

term.clear()
term.setCursorPos(4, 4)
term.write(spr0.char)
term.write(spr1.char)
term.write(spr2.char)
term.write(spr3.char)
term.setCursorPos(4, 5)
term.write(spr4.char)
term.write(spr5.char)
term.write(spr6.char)
term.write(spr7.char)
term.setCursorPos(4, 6)
term.write(spr8.char)
term.write(spr9.char)
term.write(spra.char)
term.write(sprb.char)
term.setCursorPos(4, 7)

I know it's quite inefficient, but it should still work.
Bomb Bloke #2
Posted 17 January 2016 - 10:59 AM
spr5 is the only character in the set where the final point, in its lower right corner, is supposed to be white. This means that you should be inverting your text and background colours before drawing it (as indicated by the value spr5.inverted, which should end up set to true). There's otherwise no way to light that particular "pixel" up (as none of the teletext characters have it lit).

It looks like your mkspr() function (for which the source is missing) isn't a verbatim copy of getDrawingCharacter(), either? getDrawingCharacter() should be inverting ALL the points in that character, so's they appear correctly once the necessary colour change has been performed, whereas whatever code you're using clearly isn't.