31 posts
Location
forum.getUserPos("Matt21")
Posted 23 June 2013 - 08:56 AM
Hello all,
I'm actually working on a big project (600 lines), and I have an error I don't understand.
ERROR: At line 538 permgCmd[ucmdLoop] is nil and I don't know why :/ .
Pastebins:
Program:
http://pastebin.com/NqW3aySfExternals files (placed in same directory)
test.txt:
http://pastebin.com/4mFPDBLXbase.permg:
http://pastebin.com/42AuTsB9Additional info:
In read() line 204: test.txt
In read() line 233: base.permg
NOTE: Never tested in-game, using CC Emulator
Thanks.
(Sorry for my bad english)
2088 posts
Location
South Africa
Posted 23 June 2013 - 09:00 AM
What line is the error popping up on?>
31 posts
Location
forum.getUserPos("Matt21")
Posted 23 June 2013 - 09:04 AM
What line is the error popping up on?>
Oops, I missed one line in the post.
Edited.
130 posts
Posted 23 June 2013 - 09:19 AM
The pastebin doesn't seem accurate seeing as line 560 there's a print("564") and on what would be 561 based on that (or 561 in the pastebin) doesn't have any reference to permgCmd.
31 posts
Location
forum.getUserPos("Matt21")
Posted 23 June 2013 - 09:26 AM
Modified. It's now line 538.
7083 posts
Location
Tasmania (AU)
Posted 23 June 2013 - 10:12 AM
Line 546:
until ucmdLoop > #permgCmd + 1 or quitsc == true
The way I read it, that should be a "ucmdLoop == #permgCmd" there.
A "for" loop would be neater than "repeat…until":
for ucmdLoop=1,#permgCmd do
sleep(0.1) -- Only required if you're running a biiiiiig loop here.
if permgCmd[ucmdLoop] == command then
print (command.." founded in ID "..ucmdLoop.. ".")
sleep(1)
toreturn = ucmdLoop
break
end
end
And that's assuming you don't want to rebuild the table so's the key names match the commands you want to check, which'd allow you to skip the loop completely. To do it, you'd replace line 309 with:
permgCmd[line] = true
"permgCmd[command]" will then be "true" if "command" exists in that table.
31 posts
Location
forum.getUserPos("Matt21")
Posted 23 June 2013 - 10:58 AM
Okay, but this don't have any link to this error?
Or I don't have understand.
EDIT: Okay, i have understand. Your But I still want to use index tables (entry1= "fff", 2= "rrr", 3= "ggg"…) instead of "variables tables" ("/com", "/set"…) / ("/com" = true, "/set" = true).
The thing I want to know is why at line 309 I fill up the table permgCmd and at line 538 permgCmd[1] is nil.
7083 posts
Location
Tasmania (AU)
Posted 23 June 2013 - 06:23 PM
permgCmd[ucmdLoop] would eventually be nil because you allowed ucmdLoop to get all the way up to #permgCmd+2.
If permgCmd[1] is nil then you've got more serious problems in addition to that.
Reading a bit further, I see the function that fills the table for you - readPermg() - is only called by that same function. Meaning it'll never execute. Not only that, but you appear to've put that function inside the processingPart() function, which should've been ended by the time you start defining the next one.