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

Lua quarry... almost there.

Started by Boldy97, 13 August 2012 - 07:42 PM
Boldy97 #1
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:28e2


write 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…
Sammich Lord #2
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.
Boldy97 #3
Posted 14 August 2012 - 05:32 AM
I was testing this on singleplayer, so the server has nothing to do with it :P/>/>
Lyqyd #4
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.
Luanub #5
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.
Boldy97 #6
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:28eb

Anyone thinks I should post this to the api thread-thing?


Best regards,
Boldy97