36 posts
Posted 30 July 2012 - 03:36 PM
I'm making an IRC chat program, but I have no clue how to make a frame scroll by itself when it has reached the ending line of the frame. The default scrolling for print() won't work because that works for full screen only. Any ideas?
14 posts
Location
Florida, USA
Posted 01 August 2012 - 07:30 PM
You may want to put each message into its own section in a table. Example:
Put this on the top:
local messages = { }
local num = 0
shownMessages = 0
maxMessagesOnScreen = 10 --This can be changed to however many you want
And then this in where you get the messages
messages[num] = receivedMessage
num = num+1
Then when you go to display it, check how many lines it can show on the screen and then write that many lines from the ending (#messages will return a number, how many messages are in the table). Example:
if #messages > maxMessagesOnScreen then
shownMessages = (#messages - maxMessagesOnScreen)
elseif #messages < maxMessagesOnScreen then
shownMessages = #message
end
for b = 2, shownMessages do
print(messages[b])
end
Hope this helps you!