Legacy GM Issues with adding to lists and displaying the values

M

Master_of_Balls

Guest
I'm trying to make several list with string and integer values and a grid with integer values, whose values are added to the respective data structures every time I click a menu button. The values are created randomly prior to adding them. When it comes to displaying the results, the grid works fine, but not the lists.

To go into detail, I want to display a roster of characters drawn with random image indexi representing different colored bodies, clothes and hair as a composite made from those 3 sprites. The idexi are stored in a grid whose cells are called in the draw_sprite line. As I said, that part works fine.

I'm also storing randomly created values in different lists, then assign the values to local vars and I call those to be drawn as strings with the draw_text function. That part doesn't work so well, the text that's being drawn is always 0, 0, 0, 0 ... I tried to call the list values directly in the draw_text lines without using locals, and it was the same result so, clearly, that's what the lists are storing when I add to them: '0'. That's what the debugger shows when using the local variables.



first room:

first object:

create event:

Code:
  //declare and randomize variables for 3x3 image indexi
  global.randImg1 = irandom(2);
  global.randImg2 = irandom(2);
  global.randImg3 = irandom(2);
  global.randImg4 = irandom(2);
  global.randImg5 = irandom(2);
  global.randImg6 = irandom(2);
  global.randImg7 = irandom(2);
  global.randImg8 = irandom(2);
  global.randImg9 = irandom(2);

  //declare array of possible names
  global.name[0] = "angela";
  global.name[1] = "andrew"
  global.name[2] = "betty";
  global.name[3] = "chris";
  global.name[4] = "dana";
  global.name[5] = "evan";
  global.name[6] = "fiona";
  global.name[7] = "gerald";
  global.name[8] = "harriet";

  //declare and randomize variables for 3 arrays to draw 3 names with
  global.randN1 = irandom(8);
  global.randN2 = irandom(8);
  global.randN3 = irandom(8);

  //declare and randomize variables for 3 wage values in range
  global.randWage1 = irandom_range(20, 50);
  global.randWage2 = irandom_range(20, 50);
  global.randWage3 = irandom_range(20, 50);

  //declare and randomize variables for 3 fortitude values in range
  global.randFort1 = irandom_range(20, 40);
  global.randFort2 = irandom_range(20, 40);
  global.randFort3 = irandom_range(20, 40);

  //declare and randomize variables for 3 constitution values in range
  global.randConst1 = irandom_range(1, 10);
  global.randConst2 = irandom_range(1, 10);
  global.randConst3 = irandom_range(1, 10);

  //declare and randomize variables for 3 charisma values in range
  global.randChar1 = irandom_range(1, 10);
  global.randChar2 = irandom_range(1, 10);
  global.randChar3 = irandom_range(1, 10);
second object:

mouse event:
Code:
  global.i += 1;

  ds_list_add(global.name_list, global.i - 1, string(global.name[global.randN1]));
  ds_list_add(global.wage_list, global.i - 1, global.randWage1);
  ds_list_add(global.fort_list, global.i - 1, global.randFort1);
  ds_list_add(global.const_list, global.i - 1, global.randConst1);
  ds_list_add(global.char_list, global.i - 1, global.randChar1);
  //this is for the image index
  ds_grid_add(global.apImInd_grid, global.i - 1, 0, global.randImg1);
  ds_grid_add(global.apImInd_grid, global.i - 1, 1, global.randImg2);
  ds_grid_add(global.apImInd_grid, global.i - 1, 2, global.randImg3);
second room:

draw event:
Code:
  var nameV = ds_list_find_value(global.name_list, global.i - 1);
  var wageV = ds_list_find_value(global.wage_list, global.i - 1);
  var fortV = ds_list_find_value(global.fort_list, global.i - 1);
  var constV = ds_list_find_value(global.const_list, global.i - 1);
  var charV = ds_list_find_value(global.char_list, global.i - 1)

  if global.i = 1
  {
  if surface_exists(surfEmployees)
  {
  image_xscale = 4;
  image_yscale = 4;

  surface_set_target(surfEmployees);
  draw_clear_alpha(c_green, 0);  
  //draws left applicant
  //bod = j pos 0, clothes = j pos 1, hair = j pos 2
  draw_sprite_ext(spr_apBody, ds_grid_get(global.apImInd_grid, global.i - 1, 0), 120, 160, 4, 4, 0,  c_white, 1);
  draw_sprite_ext(spr_apClothes, ds_grid_get(global.apImInd_grid, global.i - 1, 1), 120, 160, 4, 4, 0, c_white, 1);
  draw_sprite_ext(spr_apHair, ds_grid_get(global.apImInd_grid, global.i - 1, 2), 120, 160, 4, 4, 0, c_white, 1);
  //draws name
  draw_text(120, 320, string(nameV));
  //draws wage
  draw_text(120, 340, string(wageV));
  //draws fortitude
  draw_text(120, 360, string(fortV));
  //draws constitution
  draw_text(120, 380, string(constV));
  //draws charisma
  draw_text(120, 400, string(charV));
  surface_reset_target();
   
  draw_clear_alpha(c_green, 0);
  draw_surface(surfEmployees, 0, 0);
  }
  else
  {
  surfEmployees = surface_create(720, 480);
  surface_set_target(surfEmployees);
  draw_clear_alpha(c_green, 0);
  surface_reset_target();
  }
  }
 
Top