Dont spawn more than once in one spot?

2»

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Did you select the table (in the expression editor) from the drop-down menu? Or did you type it in yourself?

  • FlyboyTrevy_FlyboyTrevy_ Member, PRO Posts: 148
    edited February 2015

    Every table and rule was selected in the dropdown menus. None of that stuff was typed manually...

    Im going to keep going over it to try and find what could possibly be different about it.

  • FlyboyTrevy_FlyboyTrevy_ Member, PRO Posts: 148
    edited February 2015

    Would there be any way to transfer the actor with all of its information over to my program exactly?

    I've tried moving the actors file over to the other project folder, and nothing showed up in my project...

  • FlyboyTrevy_FlyboyTrevy_ Member, PRO Posts: 148

    Ugh, I dont get this. Everything is EXACTLY the same... doesnt work

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    I can take a look at it if you want. You can compress it and load on a hosting site. Then send me a download link via PM.

  • FlyboyTrevy_FlyboyTrevy_ Member, PRO Posts: 148
    edited February 2015

    Ok, ive stripped away all graphics and actors besides the spawner and the enemies. Still getting the same problem. But here's this so you can take a look at it:

    https://www.dropbox.com/s/rh1fybggafpv6mn/Random WOut Repeats Test.zip?dl=0

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Sorry, but when I open the file in GameSalad (Mac) all the entry fields are striped out. There is nothing in them.

  • FlyboyTrevy_FlyboyTrevy_ Member, PRO Posts: 148

    Heres a re upload with me exporting the project from game salad rather than manually zipping it.

    https://www.dropbox.com/s/yxjfrnqydja9bwg/Random W Out Repeats Test V2.zip?dl=0

    Also, if you mean all the fields in the spawner actor have nothing in them, I'm pretty sure the actor itself doesnt have much in it, but the Spawner (instance) in the actual scene should have everything.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Oops! You are correct. I was looking in the prototype and not in the instance.

    There are two things you need to change.

    First in the table, you need to change column 1 data type to integer. Currently its undefined.

    Second, you need to put "Random(1,4)" using the expression editor. Right now they are typed into the field. (You will need to change all ten of them.)

    Then it should work!

  • FlyboyTrevy_FlyboyTrevy_ Member, PRO Posts: 148

    Oh my god... 40 comments later you have no idea how good it feels to have this one annoying problem out of the way. It works great!

    Had no idea that the random function had to be added through the expression editor due to the fact that its just text. :)

    Thank you RThurman and Tatiang for all the support on this thread. I hope this helps other people with a similar issue.

    Again I cannot say it enough I think it would be a very useful feature to have a more complex spawner added to gamesalad, one that could have multiple different actors that it spawns, with options for alternation, and preventions for the amount of repeats, if any at all. Just a thought.

    Thanks again.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    You are welcome! Glad its going to work for you.

    Just a question though.... are you sure you need to have actors spawn in all four positions before the spawning sequence starts over?

    It would be so much simpler if the requirement was that an actor can spawn in any position except previous one.

  • FlyboyTrevy_FlyboyTrevy_ Member, PRO Posts: 148
    edited February 2015

    Haha, I may have mispoken or come across the wrong way a few times but it was never really my intention that it be required that the actor be spawned at all four locations before restarting again. I just wanted to point out that I had four locations from which I wanted the actors to spawn from, and I wanted to prevent it from having a string of 20 of the same location, because it's happened. And because its a 1 in 4 chance, I knew that there was a chance, even if slim, that someone would get a game with like 100 of the same position

    But at the same time, after playtesting with this new format, I do like the challenge that comes with the enemies being so spread out, but it might just play better if they have the opportunity to return to the last one after another is selected.

    Your thoughts?

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Here is how to get a random number that will never repeat the previous one.

    Timer (every .4 seconds)
        Change Attribute: self.myRndNum To: (self.myRndNum+random(0,2))%4+1
        Spawn Actor:
            Position^: 102+((self.myRndNum-1)*187) 
            Position>: 0
            Relative to: Scene
    

    And thats it. You don't need any shuffling or anything.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited February 2015

    Here is how to get a random number that will never repeat the previous one.

    Well that's ingenious! I was curious about the expression so I wrote out the possible values. Note that set notation (e.g. {0,1,2}) here means "0 or 1 or 2."

    1+{0,1,2} = {1,2,3} mod 4 = {1,2,3} +1 = {2,3,4} (anything except 1)
    2+{0,1,2} = {2,3,4} mod 4 = {2,3,0} +1 = {3,4,1} (anything except 2)
    3+{0,1,2} = {3,4,5} mod 4 = {3,0,1} +1 = {4,1,2} (anything except 3)
    4+{0,1,2} = {4,5,6} mod 4 = {0,1,2} +1 = {1,2,3} (anything except 4)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • FlyboyTrevy_FlyboyTrevy_ Member, PRO Posts: 148

    And how would I modify that spawner to work with the 4 table values, or does that already.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    The above 'code' does not work with tables, but it will give you the required numbers without tables. Its set up to randomly give either 102, or 289, or 476, or 663.

    Try it and see!

  • FlyboyTrevy_FlyboyTrevy_ Member, PRO Posts: 148

    Ok thanks!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    @tatiang said:
    Well that's ingenious!

    It is indeed!
    But credit for this neat little trick goes to @CodeMonkey who showed this way back in 2011/2012.

  • FlyboyTrevy_FlyboyTrevy_ Member, PRO Posts: 148

    @RThurman said:
    Here is how to get a random number that will never repeat the previous one.

    Timer (every .4 seconds)
        Change Attribute: self.myRndNum To: (self.myRndNum+random(0,2))%4+1
        Spawn Actor:
            Position^: 102+((self.myRndNum-1)*187) 
            Position>: 0
            Relative to: Scene
    

    And thats it. You don't need any shuffling or anything.

    Hey RThurman,

    Hate to bring this thread up again, but how would I change this so that it worked with these three values? 132 386 640 instead of four? (each 254 apart if that matters)

    Thanks

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    No problem in bringing up relevant threads. That means that you are still working on it. Which is good!

    Here is a demo.

Sign In or Register to comment.