I’m coding a game and using tables. I have a bunch of lines of code that could easily be placed in a table to lessen the code, even though i’m sure everything is correct it keeps giving me an error. “Column 4 dont exist.” The table has 20 columns & row 1 has 6 numbers in it.
roomT named room.csv
6,1,3,0,1,2,3,,,,,,,,,,,,,,,
9,4,10,4,5,6,7,8,9,10,,,,,,,,,,,,
12,11,20,11,12,13,14,15,16,17,18,19,20,,,,,,,,,
7,23,27,23,24,25,26,27,,,,,,,,,,,,,,
17,31,42,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,,,,
6,43,46,43,44,45,46,47,,,,,,,,,,,,,,
8,47,52,47,48,49,50,51,52,53,,,,,,,,,,,,
8,53,58,53,54,55,56,57,58,59,,,,,,,,,,,,
7,59,63,59,60,61,62,63,64,,,,,,,,,,,,,
7,64,68,64,65,66,67,68,69,,,,,,,,,,,,,
10,69,76,69,70,71,72,73,74,75,76,,,,,,,,,,,
10,77,84,77,78,79,80,81,82,83,84,85,,,,,,,,,,
7,85,89,85,86,87,88,89,90,,,,,,,,,,,,,
12,90,99,90,91,92,93,94,95,96,97,98,99,100,,,,,,,,
12,100,109,100,101,102,103,104,105,106,107,108,109,110,,,,,,,,
7,110,114,110,111,112,113,114,,,,,,,,,,,,,,
8,115,120,115,116,117,118,119,120,,,,,,,,,,,,,
7,124,128,124,125,126,127,128,,,,,,,,,,,,,,
8,129,134,129,130,131,132,133,134,,,,,,,,,,,,,
setup
Table roomT,storyT;
TableRow tr;
int minsx, maxsx;
ArrayList<Word> word = new ArrayList<Word>();
ArrayList<Room> room = new ArrayList<Room>();
void setup(){
size(600,600);
roomT = loadTable("room.csv");
storyT = loadTable("word.csv","header");
room.add(new Room(0));
}
void draw(){
background(125,125,125);
for (Word w: word){
w.show();
}
}
room
class Room{
int num;
Room(int n){
num = n;
tr = roomT.getRow(n);
int tn = tr.getInt(0);
for (int i = 3; i <= tn; i++){
int nt = tr.getInt(i);// here the problem
word.add(new Word(nt));
}
}
}
word
class Word{
PVector pos;
String name;
int s;
Word(int n){
pos = new PVector(0,0);
tr = storyT.getRow(n);
name = tr.getString("Name");
pos.x = tr.getFloat("X");
pos.y = tr.getFloat("Y");
s = tr.getInt("Size");
}
void show(){
fill(0);
textSize(s);
text(name,pos.x,pos.y);
}
}
storyT named word.csv
Name,X,Y,Size
Story Title,5,64,64
Play,5,192,64
Control,5,256,64
Score Board,5,320,64
Ive tried
void draw(){
tr = roomT.getRow(0);
int ts = tr.getInt(4);
textSize(32);
text(ts,5,32);
}
and 3 and 4 works just fine
i also tried
void setup(){
int page = 0;
tr = roomT.getRow(page);
int tn = tr.getInt(0);
int nt = tr.getInt(3);
word.add(new Word(nt));
nt = tr.getInt(4);
word.add(new Word(nt));
nt = tr.getInt(5);
word.add(new Word(nt));
}
error on 4