Gmod Fight Scene Idea Generator: Help with randomization.

For questions about using Classic.

Post » Sun Aug 08, 2010 3:17 am

I am creating a Generator that can randomly generate two people that exist on the source engine, and have their names display on the screen so people can make fights in Gmod with the two characters and upload them to Youtube.

I have it set so it randomly generates a number, 1 through 5, using "random(1.5)". However, the generation button doesn't work. It stays at "Unset".

Here's a cap file: [url:125tmxhs]http://www.2shared.com/file/PJzsaUfG/GFSIG.html[/url:125tmxhs]

Help will be credited in the release once I finish it. :)

(Dont worry, I am also using this to make games... XD)
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Sun Aug 08, 2010 3:40 am

"random(1.5)" does not generate a random number between 1 and 5. Use "random(5) + 1" instead.

Random(5) will get a number between 0-4 (inclusive) which is why you must add + 1 to the end.
B
7
S
2
G
4
Posts: 164
Reputation: 2,418

Post » Sun Aug 08, 2010 3:51 am

What he said, and since you were giving random() a floating-point number ( . = decimal point here, to be clear), it was generating one of those from 0 up to (not including)1.5, therefore making it impossible to match anything but the name for 1, which would still be a long-shot. Feed it an integer, and it acts as Citnarf said.

Also, you could replace all of those events for the different names with something like this:

+ System: Is global variable 'person1_number' Greater than 0
-> person1: Set text to {"Breen","Alyx","Barney","Freeman","Lammar"} @ global('person1_number')

That expression returns the array value at the index provided, which is the global there.

You can do a similar thing with the system expression GetToken and a string, as well. There is more info on that here: http://sourceforge.net/apps/mediawiki/c ... xpressions.

Both of those use 1-based indices instead of 0-based.

Anyway, I'm not looking for any credit for that. :shock:
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Sun Aug 08, 2010 5:29 am

Thanks guys! Got it working right.

The only reason a Decimal was used is because construct added it automatically...

I will keep this information in Future Reference Notes on my hard drive. :)
B
26
S
7
G
5
Posts: 202
Reputation: 5,235


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests