0 Favourites

Trouble with chosen random numbers

  • I am creating a air plane cargo and delivery game with exploration to find more airports.

    You start with 3 airports , if you are at airport 1 it will give you passengers and cargo for airport 2 and 3 --choose(2,3) nice and easy

    if you are at runway 2 you can only get passengers and cargo for airports 1 and 3 -- Choose(1,3)

    now while exploring you may find another airport to add to list this could be runway 4 or 5 or 6 or 7 and so on

    as you can see i cant just add a ,4 to the choose command as it may be airport 6 i find first so i need to add the 6 if i find runway 6

    for about 6 airports i could probably do all combinations of the choose to sort this but i am going to have about 30 airports

    so i need to add say runway 15 only if i find it

    So is there a way that i can alter my choose line to add a number to a ready made choose line

    Choose(2,3) as ma at runway 1 i fly off and find runway 7 and when i do make the choose line choose(2,3,7) then i find runway 5 choose(2,3,7,5)

    i hope this is easy to understand. HELP WOULD BE MOST APPRECIATED

  • I've done this before with arrays, when a runway becomes available you push the number to an array. I set the variable to always choose something that is available inside the array so set the number to array.at(random(0, array.width)) will pick a random value that exists, such as 0,1 0,2 0,3 0,4 in the array.

    So at the start you push 2 and 3 to the array. These would be at 0,1 and 0,2. When you come across 7 you push that to the array so 0,3 is 7 and the array looks like this (2,3,7). Then using array.at(random(0,array.width)) it will set the variable to a random number in the array, either 2, 3 or 7. Hopefully it's easy to understand the approach I was taking.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • I sussed this out before reading this by reading on google and trying things and funny enough it is nearly exactly what you are saying plinkie so thank you anyway as you would have helped a lot il check the drop box thing as well as any info is good info THANKS ALL

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
random bugs and suggestions
90 4,517
Tom's avatar
Tom Construct Team Founder
Unread hot topic
0 Favourites
Rep is very random...
73 17,907
allavett's avatar
allavett
Unread hot topic
0 Favourites
Trouble with pseudo Z axis
34 2,736
Arcticus's avatar
Arcticus