summaryrefslogtreecommitdiff
path: root/img/better_disp.lua
blob: 63eb505ea3df516622b757f9ee85556c4e540282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
-- a vlorb consists of six gromlings[A
-- 1  2
-- 4  8
-- 16 Q
-- these are characters 0x80 through 0x9f in the cc charset
-- which is only 2^5 characters though. for the sixth bit you flip the colours
-- of that vlorb.

-- on colour, off colour, gromlings 1 through 6 (bools)
-- returns text colour, bg color, and vlorbchar
local function vlorb(onc,offc, g1,g2,g3,g4,g5,g6)
	local textc,bgc = onc,offc
	if g6 then textc,bgc=bgc,textc end
	local vlorbchar = 0x80
	if g1 then vlorbchar=vlorbchar+1  end
	if g2 then vlorbchar=vlorbchar+2  end
	if g3 then vlorbchar=vlorbchar+4  end
	if g4 then vlorbchar=vlorbchar+8  end
	if g5 then vlorbchar=vlorbchar+16 end
	return textc,bgc,string.char(vlorbchar)
end

local function test()
	term.clear()
	local gs = {false,false,false,false,false,false}
	while true do
		term.setCursorPos(5,5)
		local tc,bgc,char = vlorb(colors.red,colors.black, table.unpack(gs))
		term.setTextColor(tc)
		term.setBackgroundColor(bgc)
		term.write(char)
		local _,key = os.pullEvent"key"
		if 65<=key and key<=70 then
			local idx = key-64
			gs[idx] = not gs[idx]
		end
	end
end

return {vlorb=vlorb,test=test}