Dagoba
Member
Hello!
Once again an array problem (sigh).
I am trying to create a random item like this:
This is the simple creation for the code, but I need to create multiple objects at the same, given each of them a "quality".
The thing I want is to add variable "item_quality" to the next dimension of that array, but item[i,i] would not work.
What could be the solution for this?
Thanks in advance!
EDIT: Wait, I can use it like (item[item,item_quality]) isn't it like that? I am going to try.
EDIT2: Did a small new project for this problem and here is the following code:
scr_choose_random();
obj_controller:
CREATE:
DRAW:
Will create this error:
Any ideas?
Once again an array problem (sigh).
I am trying to create a random item like this:
Code:
var item;
item = choose("Apple","Banana","Carrot","Potato");
Code:
var rn, item_quality;
rn = irandom_range(1,5);
for (i = 0; i < rn; i++) {
//The first slot of array is the item, second is for the quality
item[i,0] = choose("Apple","Banana","Carrot","Potato");
item_quality = choose("High","Average","Bad");
}
What could be the solution for this?
Thanks in advance!
EDIT: Wait, I can use it like (item[item,item_quality]) isn't it like that? I am going to try.
EDIT2: Did a small new project for this problem and here is the following code:
scr_choose_random();
Code:
var quality, item, item_id, randomizer;
randomizer = irandom_range(1,5);
for (i = 0; i < randomizer; i+=1) {
item_id = choose("Apple","Banana","Carrot","Potato");
quality = choose("Best","Average","Bad");
var_item_returned = item[item_id,quality];
return var_item_returned;
}
CREATE:
Code:
var_item_returned = 0;
scr_choose_random();
Code:
for (i = 0; i < item[i]; i+=1) {
draw_text(0,16+item[i]*2,var_item_returned);
}
Code:
___________________________________________
ERROR in
action number 1
of Create Event
for object obj_item:
In script scr_choose_random:
Error in code at line 8:
var_item_returned = item[item_id,quality];
^
at position 31: Wrong type of array index
Last edited: