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

Todolist - Can't find the error

Started by Azami1990, 09 August 2016 - 04:01 PM
Azami1990 #1
Posted 09 August 2016 - 06:01 PM
Hey Guys,

first of all, sorry for my (bad?) english ;)/>

i'm working on a Todo-List (rewrite a script i found) and i'm on a point where i can't find the error.

First, here is my Code: http://pastebin.com/XmXqtk32
And a Todo-List (save as "tasks"): http://pastebin.com/9y3NwDAz

My List is working great but when i get to the last page, i get a "122: index expected, got nil" and on page 3+ the second Item is always highlighted.
My coding skills are very semi so maybe its just a logical flaw something like that.

I hope you can help me with my Script!

Greetings
Azami1990
DoganLark #2
Posted 10 August 2016 - 11:53 AM
Strange, are you sure you posted the right code? The line doesn't look like it should throw an error. Also I can't manage to reproduce the error.
Azami1990 #3
Posted 10 August 2016 - 05:21 PM
yep, its the right code (via pastebin put)

Here are some screens:
Error with Notepad++ in Background
Code in CC

Maybe it's a problem with the Modpack? Resonant Rise 3 (3.4.0.1) and CC 1.75

EDIT: Whoop. Its Line 112 not 122 :wacko:/>
Edited on 10 August 2016 - 06:58 PM
The_Cat #4
Posted 10 August 2016 - 10:44 PM
My guess is that tasks[p3-1+line].checked doesnt exist in the table as it expected index but got a nil value.
Azami1990 #5
Posted 11 August 2016 - 12:52 AM
Found two fault.
Line 102 was: if p3-1 <= (line + 13 < #tasks and line + 13 or #tasks) and p3-1 >= 1 then
But it should be: if p3-1 <= 13 and p3-1 >= 1 then.
I dont know why i wrote the original if but the "mouse_click" should be between the second and 14 line on the Terminal :/

And i need to add a check on line 37 if its the last page and how much items are left. (for i=1+line2, (line2 + (line2+13 > #tasks and #tasks-line or 0) == #tasks and line2+1 or 13+line2) do)

But now i've got a new problem. When i'm on the last Page and i click on the "next page button" he try to get on a new Page and i get a new error (sure, there are no items to be displayed). How can I prevent this?
Bomb Bloke #6
Posted 11 August 2016 - 02:32 AM
i get a new error

… which says…?
Azami1990 #7
Posted 11 August 2016 - 02:07 PM
Sorry, was late and tired.
Its working now. Some sleep and a shove from you guys and in found all my faults :wacko:/>/&amp;gt;
Here is the working code if someone is interested in it or want to "finetune" it: http://pastebin.com/nJenRqZS
Thanks guys!
Edited on 11 August 2016 - 03:50 PM