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

Computerized to do list

Started by echoz89, 08 July 2013 - 12:17 PM
echoz89 #1
Posted 08 July 2013 - 02:17 PM
I've been looking around via google and this site to try and find a To Do list script that will output to a monitor and have yet to find one. So I basically started trying to write a basic one of my own but honestly, it SUCKS lol, it's basically just printed lines of text that I'm trying to edit the colour of but it's not going so well.

So basically what I was wondering if anyone has a script like the one I'm about to describe or could give me some tips on how to get it working how I want then that'd be much appreciated even though my CC coding is pretty poor I could probably manage it eventually with some guidance

What I'm looking for:
The script will be outputting to a 2w x 3h advanced monitor placed on the right, I'd like to have TO DO LIST: at the top centralized in blue then below it a kind of table style pattern so it would be like

-background grey- #1 To Do Item 1
-background light grey- #2 To Do item 2
-background grey- #3 To Do Item 3
-background light grey- #4 To Do item 4

Then once the page is full of list items for it to have an option at the bottom to change page and the list will change to a new page and start all over again

Here's an image of the idea I have:


then so on like that, I'm not 100% sure if you can have bullet points or not in CC so if someone could let me know if that's possible also that'd be great. As I'd rather have it bullet pointed that numbered cause you know what it's like you never do a to do list in the order it says :P/> you just pick what you fancy at the time

Thanks in advance for any help.
Lyqyd #2
Posted 08 July 2013 - 08:07 PM
Split into new topic.
MatazaNz #3
Posted 08 July 2013 - 09:27 PM
Try something like this:

page1 = {
  ["Item1"] = {line = 1, backColor = colors.grey, txtColor = colors.black};
  ["Item2"] = {line = 2, backColor = colors.lightGrey, txtColor = colors.black};
  ["Item3"] = {line = 3, backColor = colors.grey, txtColor = colors.black}
}

The table stores the items in each page, then to call them just do this,


for k,v in pairs do
  term.setCursorPos(1,v.line)
  term.setBackgroundColor(v.backColor)
  term.setTextColor(v.txtColor)
  write(k)
end

This is a very simplified version, but you get the idea.

Also, lyqyd, what does split into new topic mean?
MatazaNz #4
Posted 08 July 2013 - 09:30 PM
Try something like this:

page1 = {
  ["Item1"] = {line = 1, backColor = colors.grey, txtColor = colors.black};
  ["Item2"] = {line = 2, backColor = colors.lightGrey, txtColor = colors.black};
  ["Item3"] = {line = 3, backColor = colors.grey, txtColor = colors.black}
}

The table stores the items in each page, then to call them just do this,


for k,v in pairs do
  term.setCursorPos(1,v.line)
  term.setBackgroundColor(v.backColor)
  term.setTextColor(v.txtColor)
  write(k)
end

This is a very simplified version, but you get the idea.

Also, lyqyd, what does split into new topic mean?

Sorry, to print them uniform, do this:

page1 = {
  ["  Chop trees  "] = {line = 1, backColor = colors.grey, txtColor = colors.black};
  [" Cook up iron "] = {line = 2, backColor = colors.lightGrey, txtColor = colors.black};
  ["     Mine     "] = {line = 3, backColor = colors.grey, txtColor = colors.black}
}

I changed the items, just to show different string lengths
echoz89 #5
Posted 08 July 2013 - 09:35 PM
Thanks for the help I will give this a shot tomorrow, would you happen to have any idea how to do a touch button that will allow me to change pages once I have it all written up?
I'm basically just doing this all in a test program and doing it piece by piece at the moment so hopefully I can get this to work out

And also any ideas on how to do the title type part where it says "To Do List:"

Also, lyqyd, what does split into new topic mean?

This is because I'm a new member I have to post the topic in the top thread on the Ask a Pro page the a moderator decides if it's worthy of help/it's own thread and splits it into it's own topic. I'm guessing this is to stop spam and needless topics
Lyqyd #6
Posted 08 July 2013 - 09:57 PM
The "split into new topic" post also serves to bump the newly-split topic to the top of the topic list, as if it was newly posted. This is done because at times, the newly split post isn't even on the first page when it's created.
echoz89 #7
Posted 09 July 2013 - 05:31 PM
Anyone got any more advice on how to achieve what I'm looking for?
Bubba #8
Posted 09 July 2013 - 05:38 PM
Anyone got any more advice on how to achieve what I'm looking for?

What is wrong with the advice MetazaNZ gave you?
echoz89 #9
Posted 09 July 2013 - 06:23 PM
Anyone got any more advice on how to achieve what I'm looking for?

What is wrong with the advice MetazaNZ gave you?

I am looking to put this into multiple pages, also to have a touchscreen next and previous. I'm also stuggling to figure out how to centralize my header of "To Do List:"
Bubba #10
Posted 10 July 2013 - 12:25 AM
Check this out. Looks to be exactly what you want.

As to centering though, you can do so like this:

local termX, termY = term.getSize()

local function centerPrint(text, yPos)
  term.setCursorPos(termX/2-#text/2, yPos) --#Half of the screen-half of the text will center it on the screen
  term.write(text)
end
Tjakka5 #11
Posted 10 July 2013 - 01:49 AM
How I did my Todo list -In a nutshell-

First, I got a little function going that counted how long the monitor was, say, were saving it as Y, and then would print Y-2 numbers on the screen. (The minus 2 was for the header and the next/previous page.

I then maked a variable called 'page' and I adjusted the function mentioned above to, for every page it would add Y-2 numbers, and then print them.

local page = 1
function printNum(length)
  fixLength1 = length-2   --For the header and the previous/next.
  fixLength2 = fixLength1+(length*page)  --So it adds that.
  for i = 1, fixLength2 do
    term.setCursorPos(1, i)
    print("" ..i)
  end
end

That would basically be the printing (UNTESTED)
Then I just added some snippets of code to make it look nice, etc.

For the saving of tasks however.
I made a local table which would load all the tasks from a file,
and after every update on a tasks it would first update it's own table, and then the table in the file.

That's… about it, I hope this helped you… I don't think so…
echoz89 #12
Posted 10 July 2013 - 07:18 AM
Check this out. Looks to be exactly what you want.

As to centering though, you can do so like this:

local termX, termY = term.getSize()

local function centerPrint(text, yPos)
  term.setCursorPos(termX/2-#text/2, yPos) --#Half of the screen-half of the text will center it on the screen
  term.write(text)
end

Thanks for the help and especially the link, seems like Tjakka made exactly what I was looking for.

How I did my Todo list -In a nutshell-

First, I got a little function going that counted how long the monitor was, say, were saving it as Y, and then would print Y-2 numbers on the screen. (The minus 2 was for the header and the next/previous page.

I then maked a variable called 'page' and I adjusted the function mentioned above to, for every page it would add Y-2 numbers, and then print them.

local page = 1
function printNum(length)
  fixLength1 = length-2   --For the header and the previous/next.
  fixLength2 = fixLength1+(length*page)  --So it adds that.
  for i = 1, fixLength2 do
	term.setCursorPos(1, i)
	print("" ..i)
  end
end

That would basically be the printing (UNTESTED)
Then I just added some snippets of code to make it look nice, etc.

For the saving of tasks however.
I made a local table which would load all the tasks from a file,
and after every update on a tasks it would first update it's own table, and then the table in the file.

That's… about it, I hope this helped you… I don't think so…
I'm not the best programmer if I'm honest I can barely just edit code so I think rather than spend days making a to do list I shall use yours, it seems to be exactly what I was looking for :)/>