9 posts
Posted 13 August 2012 - 09:42 PM
So… I finally got around the whole status-saving thing when trying to get a turtle to do whatever it was doing before.
But… After the turtle comes to drop the second time, it… acts weird and gives the following error after some time:
bios:15: vm error: java.lang.ArrayIndexOutOfBoundsException: 256
help?
This is my code:
http://codeviewer.org/view/code:28e2write mine.start() to start the quarry. Everything should be clear…
you can decipher the code by watching the turtle :P/>/>
It must have something to do with all the while-loops…
1214 posts
Location
The Sammich Kingdom
Posted 13 August 2012 - 11:53 PM
I have has this error on almost all of my programs on a server before. I would suggest if you are doing this on a server to restart the server(most of the time fixes the error),
Or possible files are corrupt which is what has caused this error once or twice before(can't confirm this).
I looked at the code several times and everything is fine.
9 posts
Posted 14 August 2012 - 05:32 AM
I was testing this on singleplayer, so the server has nothing to do with it :P/>/>
8543 posts
Posted 14 August 2012 - 05:41 AM
You have functions that call each other, but never return. You're trying to make a loop, but you just keep filling up the stack. You'll want to use return statements in north and south (at least, this was where I noticed the cross-recursion), and then have a main loop to test the return values and call the next appropriate function. The way you have it now, north() calls south() and then waits for it to return, but it calls north() again and so on, until the stack shits the bed and you get the VM error.
1111 posts
Location
Portland OR
Posted 14 August 2012 - 05:53 AM
You probably have a while loop that is nesting. Meaning it never stops and another of the same loop starts while the first is still running. This can be due to it not having a break or not reaching the condition to end the loop. I'm at work and can't go through and play with it to try and find it but thought I would give you an idea of what to look for.
9 posts
Posted 14 August 2012 - 10:24 PM
Alright… I've put the north() and south() out of the while loops. Testing it now.
EDIT: works fine, except when it drops the last time. It … starts walking in weird patterns. i'll try to find what's going on here…
EDIT: probably has something to do with me calling north() around line 140, while the turtle should stand still. Time to add another variable… :P/>/>
EDIT: It finally works… adding another variable h to see if north() should be called again worked, but the turtle still started derping. I forgot to remove a south() somewhere :D/>/> I'm happy! :D/>/> This is my current code:
http://codeviewer.org/view/code:28ebAnyone thinks I should post this to the api thread-thing?
Best regards,
Boldy97