The type of the expression must be an array type. But it resolved to int.

//NPC intellegence

PImage assgolem1;
PImage assgolem12;
PImage assgolem13;

PImage assgolem2;
PImage assgolem22;
PImage assgolem23;

PImage assgolem3;
PImage assgolem32;
PImage assgolem33;

PImage assgolem4;
PImage assgolem42;
PImage assgolem43;

float[] npcx = new float[500];
float[] npcy = new float[500];
boolean[] npctf = new boolean[500];
int[] npclevel = new int[500];
String[] thenpc = new String[500];

PImage[] npcimage1 = new PImage[500];
PImage[] npcimage12 = new PImage[500];
PImage[] npcimage13 = new PImage[500];

PImage[] npcimage2 = new PImage[500];
PImage[] npcimage22 = new PImage[500];
PImage[] npcimage23 = new PImage[500];

PImage[] npcimage3 = new PImage[500];
PImage[] npcimage32 = new PImage[500];
PImage[] npcimage33 = new PImage[500];

PImage[] npcimage4 = new PImage[500];
PImage[] npcimage42 = new PImage[500];
PImage[] npcimage43 = new PImage[500];

Ai[] ais = new Ai[500];


void newai() {
  for (int i = 0; i < 500; i ++ ) {
    thenpc[i] = "assgolem";
    if (thenpc[i] == "assgolem") {
      npcimage1[i] = assgolem1; 
      npcimage12[i] = assgolem12; 
      npcimage13[i] = assgolem13; 
      npcimage2[i] = assgolem2;
      npcimage22[i] = assgolem22;
      npcimage23[i] = assgolem23; 
      npcimage3[i] = assgolem3; 
      npcimage32[i] = assgolem32; 
      npcimage33[i] = assgolem33; 
      npcimage4[i] = assgolem4;
      npcimage42[i] = assgolem42;
      npcimage43[i] = assgolem43;
    }
  }

  for (int i = 0; i < 500; i ++ ) {
    npcx[i] = npcx[i] + ((locx-npcx[i])*.01);
    npcy[i] = npcy[i] + ((locy-npcy[i])*.01);
  }

  for (int i = 0; i < 500; i ++ ) {
    npctf[i] = true;
  }

  for (int i = 0; i < 500; i ++ ) {
    ais[i] = new Ai(thenpc[i], npcimage1[i], npcimage12[i], npcimage13[i], npcimage2[i], npcimage22[i], npcimage23[i], npcimage3[i], npcimage32[i], npcimage33[i], npcimage4[i], npcimage42[i], npcimage43[i], level[i], npcx[i], npcy[i], npctf[i]);
  }
}


class Ai {
  PImage npcimage1;
  PImage npcimage12;
  PImage npcimage13;
  PImage npcimage2;
  PImage npcimage22;
  PImage npcimage23;
  PImage npcimage3;
  PImage npcimage32;
  PImage npcimage33;
  PImage npcimage4;
  PImage npcimage42;
  PImage npcimage43;
  String thenpc;
  int level;
  float npcx;
  float npcy;
  boolean npctf;

  Ai(PImage nimg1, PImage nimg12, PImage nimg13, PImage nimg2, PImage nimg22, PImage nimg23, PImage nimg3, PImage nimg32, PImage nimg33, PImage nimg4, PImage nimg42, PImage nimg43, String tn, int lvl, float nx, float ny, boolean ntf) {
    npcimage1 = nimg1;
    npcimage12 = nimg12;
    npcimage13 = nimg13;
    npcimage2 = nimg2;
    npcimage22 = nimg22;
    npcimage23 = nimg23;
    npcimage3 = nimg3;
    npcimage32 = nimg32;
    npcimage33 = nimg33;
    npcimage4 = nimg4;
    npcimage42 = nimg42;
    npcimage43= nimg43;
    thenpc = tn;
    level = lvl;
    npcx = nx;
    npcy = ny;
    npctf = ntf;
  }

  void move() {
    if (npctf == true) {
      image(npcimage, npcx, npcy);
    }
  }
}
Tagged:

Answers

  • I cannot figure out why this has decided to become an integer? it is clearly not, i am missing something. Thankyou

  • At what line is the error?

  • edited December 2013

    oh sorry about that... Line 73 this is not intended to execute on its own.

  • first parameter in Ai constructor is defined as a PImage, you're giving it a String.

  • i changed it to but it still doesnt work

        ais[i] = new Ai(npcimage1[i], npcimage12[i], npcimage13[i], npcimage2[i], npcimage22[i], npcimage23[i], npcimage3[i], npcimage32[i], npcimage33[i], npcimage4[i], npcimage42[i], npcimage43[i], thenpc[i], level[i], npcx[i], npcy[i], npctf[i]);
    
  • Double-check all the parameter list, at call site and at definition of the constructor.

    Note: you can create 2D arrays:

    PImage[][] npcimages = new PImage[43][500];

Sign In or Register to comment.