Quote: code
r1=random(10)r2=random(10)r3=random(10)r4=random(10)r5=random(10)if r1=5{instance_create(x,y,obj_m_enemy1)}if r2=5{instance_create(x+112,y,obj_m_enemy1)}if r3=5{instance_create(x+240,y,obj_m_enemy1)}if r4=5{instance_create(x+384,y,obj_m_enemy1)}if r5=5{instance_create(x+560,y,obj_m_enemy1)}
When you use random() it generates a random number including decimals.
ie. 3.20847294862The simplest way to fix this is to add round() to your code.ie. r1=round(random(10))Well, Siret beat me to it. It's not like I explained it right anyway. Also, SHORT BLAWG.
lol I remember learning how to do that a few weeks ago, but by my self, I was thinking how do I duplicate the dice roll event in code and then I remembered the decimals in random functions and rounded. You should browse more through the functions of the help file, search round in the help file index and it will come to a page with many functions with terrible descriptions.
According to NakedPaulToast, it's better to use floor instead of round.
Another function you might wanna know:
choose(x1,x2,x3,…)It chooses one of the arguments randomly.choose is a brilliant function. I use it all the time.
Shoot, I wrote out the full code and explanation before realizing there was already comments.
And had to post this to make myself feel better.The issue is resolved and thus this does not need to be on the front page any longer.
Taken off.