This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Deleting Portions of Tables?
Started by Pyrif, 12 June 2015 - 10:46 PMPosted 13 June 2015 - 12:46 AM
I'm making a program that uses a table as text management. What I want to know how to do is "If any text reaches this portion of the table, delete that portion of the table and recreate it." Can anyone help me on this?
Posted 13 June 2015 - 03:09 AM
Delete what when, and recreate how?
Posted 13 June 2015 - 03:32 AM
yah, we need some clarification on what you are asking.
Is you have text stored like so:
And what do you mean by reaches this portion of the table? If the text gets too long or if the table has so many lines?
Also, recreate it? make a new table, append it somewhere else?
Is you have text stored like so:
txtTab={
"this",
"is a test",
"On storing",
"Text"
}
So each index is a new line, or do you have some other way of storing it?And what do you mean by reaches this portion of the table? If the text gets too long or if the table has so many lines?
Also, recreate it? make a new table, append it somewhere else?
Posted 13 June 2015 - 06:05 AM
Okay, I guess I should've explained better. :wacko:/>
So, what I have is a program that, when a timer event occurs, it shifts everything on the table right by one value (on a monitor). What I want to know is, if we let w=the width of the monitor, then how do we get rid of w+1 every step and restore it without moving w+1 to w+2?
So, what I have is a program that, when a timer event occurs, it shifts everything on the table right by one value (on a monitor). What I want to know is, if we let w=the width of the monitor, then how do we get rid of w+1 every step and restore it without moving w+1 to w+2?
Posted 13 June 2015 - 09:40 AM
You're still leaving out a lot of context. Why would you need to "get rid of" something that's off the screen, why would you want to "restore" it, and where would you even "restore" it to?
What are you actually trying to accomplish here? Are you making a scrolling text marquee, or attempting to make your map for Helios scroll, or… what? Where's the code you've got so far?
What are you actually trying to accomplish here? Are you making a scrolling text marquee, or attempting to make your map for Helios scroll, or… what? Where's the code you've got so far?
Posted 14 June 2015 - 04:46 AM
I was trying to make a decorative feature for a room I was making in my house, and I wanted to have everything on the screen shift to the right by one pixel, and get rid of the last horizontal pixel that wasn't on the screen. All of my colors are controlled by a table. Your closest guess was the scrolling text marquee. :3
Posted 14 June 2015 - 05:40 AM
Ok, so what's in the table, and how are you currently rendering its contents…?
Posted 14 June 2015 - 07:33 AM
The only thing i can do so far is giving you this link:
Table functions
Table functions
Posted 14 June 2015 - 11:18 AM
Is there a reason for the text that is already off-screen to be cut off? Monitors can deal with cutting text that doesn't fit by themselves, you can just write everything starting from a different position.
Posted 15 June 2015 - 01:48 AM
Each element in this table is another table containing colors (a 2D array). Every time a timer event happens, I want to shift each element to the right by one, put something new at the first column and get rid of the last column (which automatically recreates itself when I shift everything right by one).
Posted 15 June 2015 - 02:10 AM
… and get rid of the last column (which automatically recreates itself when I shift everything right by one).
wut?
Anyway, it sounds like you just want to do this:
for y = 1, #theTable do -- For each entry (sub-table) in your main table,
table.insert(theTable[y], 1, <newValue>) -- ... add an index to the front,
table.remove(theTable[y]) -- ... and remove the index from the end.
end