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

Terminal Glass objects not drawing

Started by Sudsey, 26 September 2013 - 10:25 PM
Sudsey #1
Posted 27 September 2013 - 12:25 AM
Title: Terminal Glass objects not drawing

For the last couple days I have been working on a small project for another user on the IRC, and have hit a small snag when attempting to draw Terminal Glass objects after they've been created based on data read from a file.

The program is a heads-up variable energy meter, which can have peripherals added and removed from it through the use of a chat command, and is designed to show energy percentages using labeled progress bars on the left hand side of the screen.

Recently, I added a feature where the table of peripherals being tracked is written to a file when it is updated, and is read on the program's startup, so that the monitored peripherals would persist upon reboot. However, upon testing it, I discovered that while the objects were created successfully, and the tinted grey background behind where the bars should have been expanded as it should to accommodate for them, the progress bars themselves (and the associated text) appeared to be fully transparent.

However, when the peripherals were removed with the use of a chat command and re-added in the same execution session, they would appear and function normally, and would adjust their position to accommodate for where the other progress bars should have been.

Upon closer examination, all the values associated with the objects, such as width, height, and opacity, appeared as they should have been.

Here is a screenshot of the objects when they have been removed and re-added (and also as they should appear) (taken at night for better visibility):
Spoiler

Here is a screenshot of the apparently invisible objects shortly after being loaded from a file:
Spoiler

I'm running FTB Unleased in the screenshots.

Associated files:
The main program (Usage: $$add <peripheralID> [color:<hex>], $$remove <peripheralID>, $$exit): http://pastebin.com/pchSsrqD
The current database of functions required for gathering data (required, save as '.energyMonitor_functions', functionality to expand this when an unknown peripheral is detected will be added later):
{["batbox"]={[1]="getStored",[2]="getCapacity",},["redstone_energy_cell"]={[1]="getEnergyStored",[2]="getMaxEnergyStored",},}
The peripheral file used in the screenshots (in case you want it, make sure you use peripherals with these IDs if you do, save as '.energyMonitor_peripherals')
{[1]="redstone_energy_cell_0",[2]=5818086,}
{[1]="batbox_1",[2]=503330,}


This has already been looked over by me and another member of the IRC thoroughly, and neither of us could come up with any ideas as to what was wrong.

If any sort of answer to this issue is found, or if you have any general code improvement tips, they would be greatly appreciated!

Thanks!
Lyqyd #2
Posted 27 September 2013 - 12:32 AM
Split into new topic.

Just move your clear() from line 108 to above line 101.
Sudsey #3
Posted 27 September 2013 - 12:52 AM
Solved: Thanks to Lyqyd for pointing out to me on the IRC that
terminalGlassesBridge.clear()
on line 108 was deleting the objects created by the file-scanning chunk on lines 101-106. Moving it above line 101 worked.
Created a duplicate of the current, broken code in the OP and updated the link to it for legacy reasons.