none repeating table issue

tippedchairtippedchair Member Posts: 3
edited April 2014 in Working with GS (Mac)

Hey GS community,
I'm a good way through my first game and I'm hung up on a bug that I'm pretty sure is easy to fix... buuuut can't seem to solve.

I have an actor (Hero) that should spawn 6 new actors (Companions) around himself. Now each of the Companions are different actors (ones fire, water, lighting, etc.) and when they are spawned the Companion are supposed to:
FIRST look on a table for their y position which is an offset from the hero
THEN remove that choice from the table
AND FINALLY save the table so the other Companions don't use the same information.

Now what happens in game is that a Hero will spawn all 6 Companions but two (or sometimes more) will be in the exact same spot.

right now my code looks like this:

Companion Actor Attribute
Spot

    **Companion Actor Code**
      Change Attribute
          Change Attribute self.Spot    to     tableCellValue( game.Table 1 ,random(1,tableRowCount( game.Table 1 )),1)

      Remove row
         Table 1
         Action: Remove Row    At Index   self.Spot

      Save Table
         Table 1

      Constrain to Hero
         Constrain attribute: self.Position.Y   to game.HeroPositionY + self.Spot

Table 1 has the offset numbers; example 100, 200, 300.

As you can see from above I've used the code from Tshirtsbooth's video on picking random values from a table without repeating and tatiang was so kind as to help me out to make sure the actors are pulling the right information from the table.

I thought maybe that the system was getting confused by all the actors pulling info and writing/saving to the table at the same time so I tried spacing out the spawning of each companion. That still did not work, and even made it worse in some cases.

Any help would be appreciated.

Comments

  • colandercolander Member Posts: 1,610

    Try putting it in a timer set to "After 0 sec" and check Run to completion. Sometimes there isn't enough time for table actions to run.

  • tippedchairtippedchair Member Posts: 3

    I've set each Companion spawn up as high as 4 seconds apart. I still get overlapping companions.

  • colandercolander Member Posts: 1,610

    Use the timer to remove row and save table. When your rule is executing it happens fast and actions that take some time won't be completed unless you put them in a timer and check run to completion. Which means when it runs next time the row is still there.

  • tippedchairtippedchair Member Posts: 3
    edited April 2014

    lol, the longer i set the times apart, the worse it gets. Thanks for trying @colander. I'm still open to any other ideas you might have.

  • colandercolander Member Posts: 1,610

    It doesn't sound like you are understanding what I am saying. You shouldn't be setting any times apart.

    Put the section of you rule below (Copied from your post above) in a timer (Drag a new timer into your rule) and set the timer to "After 0 seconds" and check "Run to Completion" and it should work.

    Remove row
    Table 1
    Action: Remove Row At Index self.Spot

      Save Table
         Table 1
    
Sign In or Register to comment.