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

Scrolling Text

Started by hbomb79, 30 December 2014 - 08:32 AM
hbomb79 #1
Posted 30 December 2014 - 09:32 AM
In my adventures of instant messaging I want a GUI that displays the messages in a list most recent at the bottom, oldest at the top, depending on the size of the message etc.. I can see problems in it, for instance how would I work out the last message, I thought maybe put all the messages in a table then display the most recent 5 or 6, but the issue of large text remains. Any help on this would be great

For reference I am aiming for something like Skypes IM UI.

Haven't got any code as I've just been messing around and cant really get very far…
MKlegoman357 #2
Posted 30 December 2014 - 11:42 AM
You're heading to the right direction, the best way is probably just storing messages into a table. Now about multiline messages. You could make a function which would wrap the text around the screen width. Then you would apply some math to calculate which messages and which parts of messages to show according to screen size, scroll value and the messages themselves. I hope this helps to at least get an image about how you should address this problem :)/>
Edited on 30 December 2014 - 10:43 AM
metron80 #3
Posted 03 January 2015 - 05:53 AM
Perhaps this post should help you:

http://www.computercraft.info/forums2/index.php?/topic/19413-scroll-through-printed-text/page__fromsearch__1

I needed help with this same problem, and made that post.
SquidDev #4
Posted 03 January 2015 - 10:30 AM
There are two implementations I can think of:

The first one is as MKlegoman357 suggested. Just store the messages in a table work out where you should start printing from. This could be harder to work with but probably would run quicker than the alternative.

The (probably) easier solution is to use a buffer of some sort. I wrote a little implementation for ElvishJerricco's ClamShell. This uses an adaptation of Lyqyd's framebuffer. The buffer is here and example usage can be found here.