Change attribute self.Position.X to random but within specific range of values

Hi Guys. I currently have an object falling from the top of the screen and I want it to be random so the behaviour I've used is Change Attribute: self.Position.X to random(8,560).

But I want the falling object position to be random

  1. but in specific ranges, in this case 8,100 or 100,192 or 192,284 or 284,376 or 376,468 or 468,560
  2. never fall twice in the same range

Is this possible at all?

Thanks!

Comments

  • UtopianGamesUtopianGames Member Posts: 5,692
    edited March 2014

    This should help http://forums.gamesalad.com/discussion/53553/demo-randomize-table-rows

    I've not used it but Tatiang is one of the pros so I presume it works (just did a quick search for you using the search box), you will need 2 columns one for the x position and one for the y position.

    Edit...col1 is min range for random x and col 2 is max range for random x.

    Darren.

  • revoltandreverbrevoltandreverb Member Posts: 159

    Thanks, I'll check that out. I realised I would need tables and tried the following after watching t-shirtbooth's video

    Created a table http://grab.by/vAfw and used this function for my Change Attribute: self.Position.X

    random(tableCellValue( game.drop_table ,tableRowCount( game.drop_table ),1),tableCellValue( game.drop_table ,tableRowCount( game.drop_table ),2))

    But I suspect my problem is the second tableRowCount variable, as it shouldn't be different than the first one, not sure how to get it the same. I'll dive into that link you posted now.

    Cheers!

  • revoltandreverbrevoltandreverb Member Posts: 159

    Just checked out that link, it's way over my head and I bit of an overkill for my simple needs. I'll keep on grafting.

  • UtopianGamesUtopianGames Member Posts: 5,692
    edited March 2014

    If I get time 2morro I will do a quick demo as its 22:10 here in the uk and I'm chilling playing trials with my better half :) but your basically using the table to input the random X positions from min col1 to max col2 (not xy as I previously said sorry) then deleting the table row so it can't be used again.

    Darren.

  • revoltandreverbrevoltandreverb Member Posts: 159
    edited March 2014

    Hey. It's 00:10 here in South Africa :) Thanks! I've simplified my function just to get it working, so at least now it uses the values from the first row:

    random(tableCellValue( game.drop_table ,1,1),tableCellValue( game.drop_table ,1,2))

    I'll start building it out from here.

    When I said it should never use the same values again, I meant, not consecutively, so I don't think the delete row part it correct, unless I'm misunderstanding you.

    So it should always fall between the 6 value pairs specified, but not fall twice in the same value pair consecutively, if that makes sense?

  • UtopianGamesUtopianGames Member Posts: 5,692

    Yes makes sense and is possible if nobody helps by the time I wake up I will have a play in the morning.

    Darren.

  • revoltandreverbrevoltandreverb Member Posts: 159

    Hi Guys. This is what I could manage random(tableCellValue( game.drop_table ,random(1,6),1),tableCellValue( game.drop_table ,random(1,6),2)) but again, the row number is different because i'm using random twice, so it's not taking the values from the same row. Like I said tableRowCount also doesn't work, since I'm using it twice...

    Thanks

  • revoltandreverbrevoltandreverb Member Posts: 159

    My logic tells me my formula should be: use tableRowCount to get grab a random row, then use the random function inside of that row and grab the value of column 1 and 2, but I just don't know the syntax well enough to do that.

    Just to clarify again, when I say it shouldn't use the same value pair consecutively, I don't mean it should not repeat the same min,max value as it did the turn before, I'm saying it should not grab a random min,max value from the same row it did the turn before.

    Thanks!

  • revoltandreverbrevoltandreverb Member Posts: 159

    Darren?

  • revoltandreverbrevoltandreverb Member Posts: 159

    Never mind @DeepBlueApps, @Braydon_SFX sorted me out. thanks anyway!

Sign In or Register to comment.