Hello,
I’m making a randomizer that gives players different gadgets at the beginning of a game, and I’m wondering if I can condense my code (which I’m really bad at). Basically, each gadget has its own variable which represents the chance of getting that gadget, and then it compares the variable to the random integer selected to see if the player gets the gadget. The issue I ran into was comparing a range of potential integers to the random integer, because the chances of getting each gadget is different. For example, the variable “Slingshot” is set to 400, and the variable “Zapper” is set to 300, and the random integer could be anything between 301-400 but I wasn’t sure if my code was working. Anyways, here’s what I have, so any notes would be helpful.
You don’t need to make variables for the gadgets, just put the numbers in manually.
example: Instead of making a variable called Zapper set to 300 and making an if/statement saying if Zapper is less than or equal to Random Chance, you could just ignore making the variable and just put if 300 is less than or equal to Random Chance.
I guess the one without variable. Obviously, keep the Random Chance, you’ll want to compare the same number, it’s the other variables that don’t have to be made.
See, the issue is that since it’s less than or equal to, it triggers lots of them. If the integer is 100, then you would get every single gadget. I need a way to specify a range of values without that range being random. Thanks, though!
No, it DOES work, I can’t get a GIF to show you so I suggest making a new map, writing this code down onto a player triggerable trigger, and see for yourself.
The "If else"s take care of that, we’ll probably decend into a flame war if we keep talking about this, so I’ll just stop and figure out how to make a GIF to show you.