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

Packets And Tables

Started by Kaleb702, 30 January 2012 - 06:55 AM
Kaleb702 #1
Posted 30 January 2012 - 07:55 AM
Mmkay, so… I have started work on a tic-tac-toe version, this time using multiplayer instead of an AI.

Now the issue is… "attempt to index ? (a nil value)"

This may not be able to be fixed without actual knowledge of the MineCraft mod's APIs, but it might be able to be fixed: http://pastebin.com/bQKvVW2K Essentially, it sends packet "MOVE 1 1" for instance, meaning that it moves to the first row, first column. The packet reader then checks if it starts with "MOVE", then takes the numbers and uses them to set the spot on the board.

The issue though, is that after it moves on one, they both sit for a minute… then display an error message, which was aforementioned.
Casper7526 #2
Posted 30 January 2012 - 08:01 AM
Well the error means that your trying to use a variable thats nil. The easiest way to find out where a program is crashing is to throw some debug prints in there.

print "At this place now"
print "Doing this function"
print "Ending this function"

That way you can find out where the program is crashing by what line is printed last. Add and remove those until you find out where in your program the crash is occuring, then backtrack and find out whats causing a variable to be nil or etc etc.
Kaleb702 #3
Posted 30 January 2012 - 07:20 PM
Ah. Well, there's the "infinite loop packet search" fixed. It wasn't recognizing the host because I typo'd. That has been updated in the pastebin.

Still broken. Some more debug prints have been placed, still can't find it myself.
Casper7526 #4
Posted 31 January 2012 - 04:48 AM
It prolly works, but no need for os.sleep you can just use sleep

Also when using double matrice's you have to set the first part to a table each time.

matrix[a] = matrix[a] or {}
matrix[a] = 1
Kaleb702 #5
Posted 31 January 2012 - 05:08 AM
Wait, what?
what do you mean "set the first part to a table each time"? I did that, didn't I?
Casper7526 #6
Posted 31 January 2012 - 05:17 AM
Yeah I didn't realize you had it at the top. IMO you gotta find out WHERE it's crashing with some more debug lines and let us know. You can do it Kaleb! Code the night away!
FuzzyPurp #7
Posted 03 February 2012 - 02:56 AM
Any Progress?
Kaleb702 #8
Posted 19 February 2012 - 06:49 AM
http://pastebin.com/cT1UVRwC

Now it's an infinite loop somewhere in there.