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

Colors in Advanced Monitor, help with Programm

Started by Chre903, 06 April 2013 - 06:54 AM
Chre903 #1
Posted 06 April 2013 - 08:54 AM
I am not very good with lua, it took me a long time to write this simple Programm, so i hope someone can help me.

We want on our Server to make it easy to see witch Bees from Forestry we have and Monitor should be a good way for this. I made this little Program before but i tried many way to color the Background or the Text, but i couldnt do it :(/>
so what did i have to do, to make the Background in a difrent Color, so we can easy see it AND can easy change the Color when we got this kind of bee.

This is my old Programm, this it not the Programm i want to make. The new Program should only show 1 Species per "slot" and should be able to show ~184 of these "Slots".
http://pastebin.com/5ncx717u
Telokis #2
Posted 06 April 2013 - 09:09 AM
Maybe this will help you :
http://computercraft.info/wiki/Term.setBackgroundColor
PixelToast #3
Posted 06 April 2013 - 09:10 AM
you want to use tables to organize the data before printing it, that would cut lines down tremendously
then a for / pairs loop to print the data
remiX #4
Posted 06 April 2013 - 09:29 AM
It's the same thing with monitors as your terminal computer.

term.setBackgroundColour( colours.blue )

monitorObject.setBackgroundColour( colours.white )
-- your case with that pastebin code
mon.setBackgroundColour( colours.white)

same with setTextColour
JokerRH #5
Posted 06 April 2013 - 11:42 AM
So are you trying to create something like this?

local bees = {
	BeeA = true,
	BeeB = false,
	BeeC = false,
	BeeD = false,
	BeeE = true,
	BeeF = false,
}

local breed = {
  BeeC = {"BeeA", "BeeB"},
  BeeF = {"BeeD", "BeeE"}
}

local row1 = 10
local row2 = 20

local found = colors.green
local missing = colors.red
local natural = "[natural]"

function drawBee(name, x, y)
	term.setCursorPos(x, y)
	term.setBackgroundColor(bees[name] and found or missing)
	write(name)
	term.setBackgroundColor(colors.black)
end

function drawBreeding(name, y)
	if not breed[name] then
		term.setCursorPos(math.floor(row1 - #natural / 2), y)
		write(natural)
		drawBee(name, row2, y)
	else
		drawBee(breed[name][1], 1, y)
		
		term.setCursorPos(row1 - 2, y)
		write("+ ")
		
		drawBee(breed[name][2], row1, y)
		
		term.setCursorPos(row2 - 2, y)
		write("=")
		
		drawBee(name, row2, y)
	end
end

function draw()
	term.clear()

	local y = 0
	
	for ind, param in pairs(bees) do
		y = y + 1
		term.setCursorPos(1, y)
		drawBreeding(ind, y)
	end
end

draw()

Edit: You can use term.scroll() to scroll if you have more bees than rows on your terminal :D/>