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

Java Exception Thrown

Started by jarifle, 27 June 2015 - 01:13 PM
jarifle #1
Posted 27 June 2015 - 03:13 PM
Hello everyone,

I came across a little problem while writing a program that is suppost to retrieve items from my ME system using the Peripherals++ ME bridge.
It goes through the program untill it actually tries to retrieve the items (the selecting and all that works).
The error it gives is :"Java Exception Thrown: java.lang.ArrayIndexOutOfBoundsException: 1".
And thats it here is the code

local me = peripheral.wrap("back")
local s = peripheral.wrap("right")
rednet.open("top")
local function test()
  print("Enter item code please.")
  input = read()
  print("How many " .. input .. " do you want?")
  input2 = tonumber(read())
  me.retrieve(input, input2, "left")
  term.clear()
end
test()

Thank you
Bomb Bloke #2
Posted 27 June 2015 - 03:32 PM
You're getting the error because the me.retrieve()'s Java-side code is crashing. Usually when a peripheral function errors out like this it's because it's being called incorrectly, and its author didn't bother to check for misuse so they could error out with a more useful message.

My best guess, based on this article, is that it's wanting you to enter a compass facing instead of just "left". It may alternatively be that it doesn't like the "item name" you're giving it (what exactly are you typing…? Odds are it's case sensitive).
jarifle #3
Posted 27 June 2015 - 03:39 PM
I tryed the item id and the name but if you look on the wiki of peripherals++ it says it doesnt matter. (https://github.com/a.../wiki/ME-Bridge)

Thanks for the reply

Edit: i found it you have to give in minecraft:coal for example but now my question is if you can change that?.
Edited on 27 June 2015 - 01:41 PM
KingofGamesYami #4
Posted 27 June 2015 - 03:56 PM
Edit: i found it you have to give in minecraft:coal for example but now my question is if you can change that?.

You could make your program assume everything is to be prefixed with "minecraft:", which would allow you to type in "coal". However, this will fail if it's from a mod.
jarifle #5
Posted 27 June 2015 - 04:01 PM
Edit: i found it you have to give in minecraft:coal for example but now my question is if you can change that?.

You could make your program assume everything is to be prefixed with "minecraft:", which would allow you to type in "coal". However, this will fail if it's from a mod.

Yeah also thought of that but that would indeed screw it up but thanks for the help though.

Edit: Or is there another way to extract items from the system?
Edited on 27 June 2015 - 02:14 PM