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

Weird text overlapping/formatting in monitor

Started by nmdanny, 15 April 2014 - 12:37 PM
nmdanny #1
Posted 15 April 2014 - 02:37 PM
Hi, I have a program that shows information about my RF energy grid, for each energy cell/capacitor bank it shows the amount of energy stored, maximum energy and energy percent.
It also calculates the total energy stored and maximum energy in the entire grid, and shows all of this information on an advanced monitor.

I do so by looping a transmitted message from every computer that is connected to an energy cell/bank to a specific channel which the master computer(the one that displays the information) listens to.
The message contains the transmitting computer's label, the energy stored and energy maximum of its energy cell and the percent - separated by spaces, and then the master computer builds a table out of this information and displays it, I also tried to organise the labels of each statistic ("Maximum Energy Stored, Energy Stored, Energy Percent") to line up so that their colons share the same column.

Here's how my monitor looks like: http://i.imgur.com/2fKIVrY.jpg
The problem is, I have weird text overlapping, for example, after an energy cell's label colon there should be empty space, but there's "ergy Grid Information:" , on the units, I sometimes get RFF or other weird things.
In addition, when I start up the computer for the first time I get a purple background behind some of the text below the title, this requires me to clear the monitor then restart the program.

I am also using a button API from a tutorial however it's not the cause of these glitches.

*I'm playing on FTB Monster 1.09


Link for the master computer program(including the button): http://pastebin.com/dSV0gFAn
Link to the master computer program without the button API: http://pastebin.com/q1ZYnLu6
Link to transmitter computer program(shouldn't be any problem with it): http://pastebin.com/P5scYLVF
CometWolf #2
Posted 15 April 2014 - 03:34 PM
The issue is how you're clearing the monitor

		for row=1,height do
				monitor.write(string.rep(" ",width))
		end
monitor.write will not move the cursor down, meaning this basically just writes a ton of long empty strings on the same line. You'd be better of just using monitor.clear really :P/>
However, a better approach would be to concat the required amount of empty spaces onto the strings when they're being written to the monitor.

Edit: nvm, you're already doing that. What's the point of clearing the entire monitor every time though? Or well, attempt to anyways…

I'd suggest you check what your sub computers are actually sending, just to be safe.
Edited on 15 April 2014 - 01:37 PM