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

java.ArrayIndexOutOfBoundsException: 256 after Program start

Started by Dr. Console, 27 December 2012 - 02:19 AM
Dr. Console #1
Posted 27 December 2012 - 03:19 AM
Hey guys,
is scripted a lil Program to control my reaktors via a client and a server.
But now I got a lil problem, and i don't know why.

i got this array:

local R = {stu1 = {[1] = "Reactor 1 started up!", [2] = 16}, stu2 = {[1] = "Reactor 2 started up!", [2] = 2048}, stu3 = {[1] = "Reactor 3 started up!", [2] = 32768}, stu4 = {[1] = "Reactor 4 started up!", [2] = 1}}
and this rotine to use it:

elseif R[input] ~= nil and id == rcpc_id then
colores = R[input][2]
c = colors.combine(c, colores)
rs.setBundledOutput("top", c)
rednet.send(rcpc_id, R[input][1])
compare()
...
(This is a part of the function compare)
My intention is that i get the input e.g. "stu1" and the variable is set to 16 what is R[stu1][2].
But if i call this function with this values it gives the error from the title :

bios:148: vm error:
java.lang.ArrayIndexOutOfBoundsException: 256

I hope that someone can help me.

NG
Dr. Console
Dr. Console #2
Posted 27 December 2012 - 04:06 AM
Solved the problem, there was one line of code missing…-.-