random(x) glitch

Bugs will be moved here once resolved.

Post » Thu Oct 20, 2011 8:33 am

the random(x) event has been a bit quirky...not sure if this a bug or just a random anomaly

random(x) works in 1 part of my code but doesn't work in another

when i open a new doc and enter the same code it works fine...is this a problem with the current project or is it just a very "random" glitch
???

i'd rather not create an entirely new project just to clear up 2 lines (albeit vital) of code

B
16
S
2
G
1
Posts: 43
Reputation: 1,473

Post » Thu Oct 20, 2011 8:43 am

Well if I asked you to move random(x) feet, what exactly would that mean to you?
The reason I ask is because at this point it means the same as random(a), or random(n), or random(z) to me.
Good chance that it would mean the same in C2.
Image Image
B
164
S
49
G
125
Posts: 7,792
Reputation: 85,038

Post » Thu Oct 20, 2011 10:08 am

@qwiktags: post your capx please.
We can't guess out of the blue what the quirks or glitches are.

Also think to provide the required infos as asked in how to report a bug.
New to Construct ? Where to start



Image Image

Image Image



Please attach a capx to any help request or bug report !
Moderator
B
262
S
93
G
55
Posts: 7,150
Reputation: 67,069

Post » Thu Oct 20, 2011 2:25 pm

Sorry guys. I do apologize for my oversite (it was a wee bit early/late when I made the post)

Here is the quick and dirty version of what is going on
(this works just fine)
global variable = 0
global variable2 = 0
System -> every random(5)+2 seconds --> spawner1...spawn sprite
                                                                       set sprite.Y to random (300)+20
                                                                       set global variable2 = 1
                                                                       do more stuff..


(this part gets glitchy)**
System -> every random(15)+5 sec --> spawner2 spawn sprite2
             -> global variable2=1                 system set global variable to random(3)+1 **(this part does not register)
                                                                set sprite2.Y to random (300)+20 (works fine)
                                                                ( the remaining code in this block works fine)...
                                                                system set global variable2 =0
system -> global variable = 1 --> spwaner3 spawn sprite3
                                                       do stuff
(nothing happens in this block because there is no value generated for global variable which could be 1,2 or 3)

I hope this helps, if not I'll post the capx later on today
B
16
S
2
G
1
Posts: 43
Reputation: 1,473

Post » Thu Oct 20, 2011 2:45 pm

At global variable2 =1 => system set global variable to int(random(1,3)) should do the trick.
random() returns a float. By setting a range and making it an int(eger) , you are sure random will return either 1, 2 or 3.

Next time though, post directly the capx, it will be easier to answer you.Kyatric2011-10-20 14:46:05
New to Construct ? Where to start



Image Image

Image Image



Please attach a capx to any help request or bug report !
Moderator
B
262
S
93
G
55
Posts: 7,150
Reputation: 67,069

Post » Thu Oct 20, 2011 3:25 pm

Thanx...I'll give it a shot

I also tried moving the random(3)+1 line to block 3 and the result was the same (nothing registers)

I'll post the capx anyway later today
B
16
S
2
G
1
Posts: 43
Reputation: 1,473


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 0 guests