[Solved] "Random" Bug

Bugs will be moved here once resolved.

Post » Fri Sep 30, 2011 7:35 pm

Hello there, before we begin:


Windows 7 Ultimate
32-bit Operating System
Intel(R) Celeron(R) CPU E1400 2.00 GHz
2.00 GB RAM (Memory)
Display: NVIDEA GeForce GT 430


I added a variable to a sprite (my enemy in the game) called "BulletChoice" and it starts off at 0. in the events I added an event that says:

* If enemy.BulletChoice = 0 Then:
* - Set enemy.BulletChoice To ("Random(1, 2)")

The combinations I've tried:
Random(1, 2)
Random(3)
Random(0, 2)
Random(0, 3)
Random(1, 3)
Random(1, 2)
Random(2)

I'm tyying to get the value to choose 1 or 2 (later there will be more) but It doesn't choose any of those numbers it seems, I really don't know what happens there? :Sdcrew2011-09-30 21:14:46
B
17
S
4
G
5
Posts: 226
Reputation: 4,042

Post » Fri Sep 30, 2011 8:39 pm

You may want to try int(random(1,2)) which results will be either 1 or 2.
Without the int(), your result is probably a float.

If this is still not what you want/doesn't work as intended, can you post a capx showing the problem ?

Also in the first line you write ("Random(1,2)"), did you write it like that in C2 too ?
The ("") might indicate a string, which is not the correct variable type apparently and is not necessary.Kyatric2011-09-30 20:41:32
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Fri Sep 30, 2011 9:14 pm

[QUOTE=Kyatric] You may want to try int(random(1,2)) which results will be either 1 or 2.
Without the int(), your result is probably a float.

If this is still not what you want/doesn't work as intended, can you post a capx showing the problem ?

Also in the first line you write ("Random(1,2)"), did you write it like that in C2 too ?
The ("") might indicate a string, which is not the correct variable type apparently and is not necessary.[/QUOTE]

That worked like a charm, Thanks very much for that Kyatric!
B
17
S
4
G
5
Posts: 226
Reputation: 4,042


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 6 guests