Jump to content




Colors in Advanced Monitor, help with Programm


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

#1 Chre903

  • Members
  • 3 posts

Posted 06 April 2013 - 07: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

#2 Telokis

  • Members
  • 88 posts
  • LocationToulouse, France

Posted 06 April 2013 - 08:09 AM

Maybe this will help you :
http://computercraft...BackgroundColor

#3 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 06 April 2013 - 08: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

#4 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 06 April 2013 - 08: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

#5 JokerRH

  • Members
  • 147 posts

Posted 06 April 2013 - 10: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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users