Jump to content




Index Expected, Got Nil

help lua

  • You cannot reply to this topic
8 replies to this topic

#1 whatxDxDxD

  • Members
  • 18 posts

Posted 26 September 2013 - 01:29 PM

Spoiler

I'm having trouble with the tables. I wrote the program not directly in computercraft, it workd fine, but now if I try to run the program there's an error-message expected index, got nil referring to the first list[n] (and all the others). The function is just a piece of the program, the setTable function is called with the parameter "dummy". I get the same message no matter what i use as index, tried numbers and strings, the variable n is just the length of the list (had some wierd problems with table.getn(..) that's why I used there the custom function length()).
Somehow every "index" is nil.
Thank you in advance :D

#2 makerimages

  • Members
  • 236 posts

Posted 26 September 2013 - 01:44 PM

Why would yo need the
[n]
behind the list? if it is there, N is used as an index, remove
 [n]
from all list`s and try then

also
#list
returns the lengtht of the list

#3 whatxDxDxD

  • Members
  • 18 posts

Posted 26 September 2013 - 01:57 PM

Well the [n] makes it easier for me to navigate.
oh, well that's pretty handy, didn't know about that :D

hm.. still the same problem if i remove the [n].

#4 Exerro

  • Members
  • 801 posts

Posted 26 September 2013 - 02:52 PM

Is this your whole code? If it is you should be getting an attempt to call nil error with length( ). Otherwise,make it print n ( or other method that let's you see n ) right after you declare it, I am guessing that there isn't a table list[n] so maybe n isn't what you think it should be.
And as always, whole code really helps us to solve errors. If it is really long put it on pastebin or a in a spoiler.

#5 whatxDxDxD

  • Members
  • 18 posts

Posted 26 September 2013 - 03:18 PM

tested it, n got the value it should.

pastebin : http://pastebin.com/LcqtDt0B
Spoiler

So this is the whole code, at the moment a lot of the code is in the testing-state, I'm very sorry, if it is too unorganized, I'm also pretty sure there's stuff that isn't correct or probably not done the best way ( for example the "#list-thing"). :) Last time I worked on the code mistyped "legth", but i will replace it anyway..

#6 MR_nesquick

  • Members
  • 106 posts
  • LocationNorway

Posted 26 September 2013 - 04:37 PM

error code: parallel :22: <name> :443: attempt to index ? (a nil value)

line 443 = < button.checkxy(x,y) >
it should be < buttonAPI.checkxy(x,y) >

#7 whatxDxDxD

  • Members
  • 18 posts

Posted 26 September 2013 - 04:47 PM

View PostMR_nesquick, on 26 September 2013 - 04:37 PM, said:

error code: parallel :22: <name> :443: attempt to index ? (a nil value)

line 443 = < button.checkxy(x,y) >
it should be < buttonAPI.checkxy(x,y) >
oh thank you, but why did the program run that far? If I run the program it stops around line 85 I think. So i never got that far ;).
Was there a big change in one of the CC versions? Or what's the difference, did you find the problem with the table?

#8 MR_nesquick

  • Members
  • 106 posts
  • LocationNorway

Posted 26 September 2013 - 04:51 PM

i'm using FTP direwolf 1,5 v2. and a fresh install of dire button API. i didn't get any error code with your tables. but i get one black screen and one light blue one but nothing is happening

#9 whatxDxDxD

  • Members
  • 18 posts

Posted 26 September 2013 - 05:15 PM

Ah yes, I didn't adjust all background colors, had different priorities. Oh but that's great to hear :D.

Edit:
Did test the program in a new test world, didn't get the table problem. :D Seems that my test world was somehow a little broken. Well it wasn't what I expected, but as long as the problem is gone I'm fine. There're still problems with the program, but these seem to be normal programming mistakes. So thank you everybody for this fast help :D, I think I would have tested for hours in the old world ^^. great forum :D





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users