Random integer question.
gesimund
Member Posts: 33
Im trying to keep the global attributes down the a minimum and if I can't do this, then im going to need 10 or so global attributes. So, I need help with an alternative if there is one.
Im going to have about 10 different actors. I have a global integer attribute . There will be a button with a rule that says, if pushed generate a random number between 1-10. Then 10 different rules that say, if this number was generated, spawn this actor.
Thats all good, but then the thing that makes it complicated is I only want to spawn that particular actor a single time. If the button is pushed again, I want it to spawn one of the 10 actors that have not yet been spawned. So, is it possible at all to take that number out of the equation and still keep it random?
Im going to have about 10 different actors. I have a global integer attribute . There will be a button with a rule that says, if pushed generate a random number between 1-10. Then 10 different rules that say, if this number was generated, spawn this actor.
Thats all good, but then the thing that makes it complicated is I only want to spawn that particular actor a single time. If the button is pushed again, I want it to spawn one of the 10 actors that have not yet been spawned. So, is it possible at all to take that number out of the equation and still keep it random?
Comments
It's a little tough without things like while loops and arrays, but it can be done.
As far as global attributes, I wouldn't worry about the amount used. Both of my games both load/save over 160 Attributes. Plus there are more that are used and don't get saved. I haven't noticed a problem.
I've only use 3 actors in my example, and as you'll see it's only for when the random number is 1. The same again but for 2 and 3 is needed. In your case, up to 10....quite a lot of attributes when finished I reckon, but as the other guys said, the amount shouldn't be a problem. And even if you finish, whether it'll work as you want or not, or it's the right way to go, I don't know... (disclaimer ;-) )
The new attributes are: Actor1Pos, etc; Actor1Active, etc; Amount of Actors, Random number.
Hope it helps.
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Thanks for all the input from everyone, this pretty much resolves what I wanted to do. I'm still trying to master Game Salad right now so im not very helpful if someone else needs help. But any games you make, I'll make it a priority to get it and give high ratings.