I have three objects. All of them in the create event contain an action each (execute a piece of code):
Image (to clarify what I have tried to explain):
So far so good, but I have one more object that modifies the variables of these other three:
The obj_control contains two events: create and draw.
crete event (obj_control):
obj_r01.r01=irandom(9); obj_r02.r02=irandom(9); obj_r03.r03=irandom(9);
draw event (obj_control):
This event contains three actions, precisely three "execute a piece of code":
draw_text(x,y,obj_r01.r01); => applies to obj_r01
draw_text(x,y,obj_r02.r02); => applies to obj_r02
draw_text(x,y,obj_r03.r03); => applies to obj_r03
The objects are arranged as follows in the room:
In execution this is what happens:
The value of r01 is randomized, but that of r02 and r03 is not. I also tried to modify the obj_control creation event code to:
randomize(); obj_r01.r01=irandom(9); randomize(); obj_r02.r02=irandom(9); randomize(); obj_r03.r03=irandom(9);
However the result does not change. With this I could only suspect that the
irandom () function can only create a storable random value, would it solve such a problem?
I tried putting randomize() only at the beginning of the code as suggested to me by @Philipp and @DH.:
randomize(); obj_r01.r01=irandom(9); obj_r02.r02=irandom(9); obj_r03.r03=irandom(9);
But there was no change in the result.
I also did a test to be sure if the value was not even being randomized or if the values of r02 and r03 were being randomized to 0 and for that I modified their values in the creation of each object:
The first value (not surprisingly) was randomized, but the second and third values were not. Thus it is clear that the randomization is not being made or that the draw event is occurring before the radomization of r02 and r03.