If it helps, I am trying to print shell.programs() then scroll the text up or down according to the stroke, and no, I do not want to use term.scroll().
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Scrolling the contents of a table
Started by SuicidalSTDz, 14 March 2013 - 09:44 AMPosted 14 March 2013 - 10:44 AM
I had just looked at the wiki and noticed the event; mouse_scroll. I sat and thought, now I how could I capture a scrollStroke and move a printed table on the screen accordingly? I'm fairly new to this event and would like to know how it works. Out of all of the events, this one caught my eye the most (Seeing as i've never used it ^_^/>) Any help is appreciated.
If it helps, I am trying to print shell.programs() then scroll the text up or down according to the stroke, and no, I do not want to use term.scroll().
If it helps, I am trying to print shell.programs() then scroll the text up or down according to the stroke, and no, I do not want to use term.scroll().
Posted 14 March 2013 - 11:02 AM
Load all lines you want to display in the future into a table. If it's size is larger then the terminal's height, that's not a problem. Set up an offset variable. Then change offset when a "mouse_scroll" event occurs. Ehh, it's easier inside code tags…
EDIT: Removed code tags (formatting killed code…)
http://pastebin.com/EC7MEMKi (not tested, should work though)
EDIT2: You could've asked me on Skype…
EDIT: Removed code tags (formatting killed code…)
http://pastebin.com/EC7MEMKi (not tested, should work though)
EDIT2: You could've asked me on Skype…
Posted 14 March 2013 - 11:38 AM
Yeah, I figured I would have to use an offset variable.
My Skype account was acting up. I just called their support center and they got everything straightened(<— lol did I spell that right?) out.
My Skype account was acting up. I just called their support center and they got everything straightened(<— lol did I spell that right?) out.
Posted 15 March 2013 - 04:25 AM
Have you ever actually tried to scroll? Because the first time it calles redraw is when you scroll down…
Should call redraw right after declaring it… Oh! And figured! math.max() instead of math.min()
Fixed code on pastedbin, same url…
Should call redraw right after declaring it… Oh! And figured! math.max() instead of math.min()
Fixed code on pastedbin, same url…
Posted 15 March 2013 - 07:54 AM
Ah, I should have seen that. I also did try to scroll ;)/> Thanks again ^_^/>
Posted 15 March 2013 - 08:43 AM
NP - BTW a "mouse_scroll" returns direction and coordinates, eg,
p1 is now 1 or -1 (direction) and p2 and p3 are the X and the Y coordinates of the mouse.
local event, p1, p2, p3 = os.pullEvent("mouse_scroll")
p1 is now 1 or -1 (direction) and p2 and p3 are the X and the Y coordinates of the mouse.
Posted 15 March 2013 - 08:56 AM
Oh, hmm. Interesting, well thanks for the tip (Mouse scroll expert over here ^_^/>)NP - BTW a "mouse_scroll" returns direction and coordinates, eg,local event, p1, p2, p3 = os.pullEvent("mouse_scroll")
p1 is now 1 or -1 (direction) and p2 and p3 are the X and the Y coordinates of the mouse.
When was I a Pro Coder? When did people start pressing my green vote button? Why do I have so many friends? God I need to pay attention moar.