Jump to content




Error- whats wrong with my code?


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

#1 Apfeldstrudel

  • Members
  • 161 posts

Posted 04 March 2013 - 03:18 AM

Title: Error- whats wrong with my code?
Spoiler

its supposed to quarry out a 16 by 16 area, dumping all of its items when full

When i run the program i get "java.lang.ArrayIndexOutOfBoundsExeption"


HEEELP D:

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 04 March 2013 - 07:04 AM

Split into new topic.

#3 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 04 March 2013 - 07:36 AM

I was getting the same error one time and someone said to me that it was because
I used too many functions, And well... You use alot.

#4 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 04 March 2013 - 07:39 AM

refuel calls itself. And turtle.refuel is nowhere... That's the problem...

I mean
function refuel()
    while turtle.getFuelLevel() < 5000 do
        turtle.refuel()
    end
end


#5 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 04 March 2013 - 07:41 AM

And why do you do this?
function refuel()
while turtle.getFuelLevel() < 5000 do
  refuel() --You are calling the fuction in itself... Why? Did you mean to use the turtle.refuel()
end
  end

--[[
This just repeats the function 'refuel()' over and
over if the fuel level isn't equal or more than 5000
Try to use 'turtle.refuel()' instead of 'refuel()'
]]--

EDIT: Damn got ninja'd

#6 Apfeldstrudel

  • Members
  • 161 posts

Posted 04 March 2013 - 07:54 AM

Wow, THANKS LBPhacker (it wasn't inteded ;D)

#7 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 04 March 2013 - 02:04 PM

View PostHellkid98, on 04 March 2013 - 07:41 AM, said:

And why do you do this?
function refuel()
while turtle.getFuelLevel() < 5000 do
  refuel() --You are calling the fuction in itself... Why? Did you mean to use the turtle.refuel()
end
  end

--[[
This just repeats the function 'refuel()' over and
over if the fuel level isn't equal or more than 5000
Try to use 'turtle.refuel()' instead of 'refuel()'
]]--

EDIT: Damn got ninja'd
Just for future reference, what you are doing within the function is not by any means "proper". You are looping a check for a fuel level lower than 5000 which will sooner or later return an error (Too long without yielding). Also, you say it checks for a fuel level less than or equal to. Then why do you say (< 5000) when it should, in reality, be (<= 5000).

#8 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 04 March 2013 - 02:06 PM

View PostSuicidalSTDz, on 04 March 2013 - 02:04 PM, said:

sooner or later return an error (Too long without yielding)
Actually as it is in OP it would say 'java.lang.ArrayIndexOutOfBoundsExeption' before it would error to yielding as the program stack fills up quicker than the 10 seconds.

#9 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 04 March 2013 - 02:55 PM

View PostTheOriginalBIT, on 04 March 2013 - 02:06 PM, said:

View PostSuicidalSTDz, on 04 March 2013 - 02:04 PM, said:

sooner or later return an error (Too long without yielding)
Actually as it is in OP it would say 'java.lang.ArrayIndexOutOfBoundsExeption' before it would error to yielding as the program stack fills up quicker than the 10 seconds.
Hmm, guess you're right again... Either way they are both a pain ( That's something I think we can both agree on ;) )

EDIT: I don't think Semi-Proffesional ComputerCrafter fits your knowledge (One more thing we can agree on)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users