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

[Solved] Scroll An 2 Dimensional Table (x) (y) of Screen Data

Started by augustas656, 30 May 2014 - 04:45 PM
augustas656 #1
Posted 30 May 2014 - 06:45 PM
I have a two tables[x][y] with one having a character in each spot representing the text data of the screen, and another table with {textColor, backColor} of each spot on the screen, now I want to create scrollX and scrollY to scroll the screen, these functions can accept arguements with a negative and positive values, if 0 then it won't scroll if a negative value will scroll backwards, if a positive value will scroll forwards, and I'm going to make this for scrolling horizontally for the X value and vertically for the Y value. I could do this with if values to check if it's a positive, a negative or a neutral value, but I came here to find out if anyone knows a more efficient way to solve this issue for scrolling, perhaps using a for loop or something.

I don't need to trim the table with values that go over the boundaries for example if I scroll a table to go below 1 so the placeholder -2 could contain a value, I don't mind because I have a table trimming function so I can sort of like table:sub(1, 51).

Regards
Augustas
Edited on 30 May 2014 - 06:04 PM
augustas656 #2
Posted 30 May 2014 - 08:03 PM
I solved my problem, I'm just sort of re-creating the table.insert, but in this case, I even need to shift all the nil values, so you need to specify the Min and Max parameters of the table. So 1 to 10.

Regards
Augustas