Just a short reply as I am also going to bed. The code i posted in my former reply can be slightly shorter, since you don't need two variables "t" and "sprite_choise". One is sufficient, "t", and you don't need to turn that one into a string:
t=instance_number(pic);
switch (t)
{
case 1: sprite_index=choice1; break;
case 2: sprite_index=choice2; break;
case 3: sprite_index=choice3; break;
// etc. ....
case 32: sprite_index=choice32; break;
}***
But you might want to store the sprites in an array since you also want to use them in the other code you posted, and the array can be used in both cases.
sprite_array[0] = choice1;
sprite_array[1] = choice2;
// etc. up to:
sprite_array[31] = choice32;
Then you only need this simple code in the create event of pic:
t=instance_number(pic);
sprite_index=sprite_array[t-1];
***
You could make the array global unless you want to refer to the instance where the array is initialized, could be in a controller object.
Global array:
global.sprite_array[0] = choice1;
// etc.
or if the array is initialized in an object named obj_ctrl:
obj_ctrl.sprite_array[0] = choice1;
// etc
***
or you could initialize the array in a script and call that script whenever you want to use the array:
A script named scr_array:
sprite_array[0] = choice1;
sprite_array[1] = choice2;
// etc. up to:
sprite_array[31] = choice32;
Create event of pic:
scr_array();
t=instance_number(pic);
sprite_index=sprite_array[t-1];
Edited by Weird Dragon, 03 May 2012 - 12:30 AM.