Choose a random value out of four options??

Hello everyone :)

Can I have a rule that chooses a random value from four numbers that are given? Eg. If I have 4,5,2,7 can I make it choose one of those four numbers?

Or is this a complicated thing? Just wanted to make sure i wasn't missing something simple!

Thanks
Elfizm

Comments

  • TesseractEngineTesseractEngine Member Posts: 180
    Put the four numbers into a table, call it say randomNumberList. Four rows, one column. When you want to choose one randomly, assign an attribute, for example diceRoll, a random number from one to four. Then set the attribute, for example Result, you want to be one of the four numbers to tableCellValue.randomNumberList,diceRoll,1).
  • ElfizmElfizm Member Posts: 489
    @TesseractEngine

    Thanks so much :) my way was a bit longer and this is so simple it's embarrassing I didn't think of it.
    Made a demo and it works great

    Elfizm
  • ElfizmElfizm Member Posts: 489
    @TesseractEngine or anyone

    So here is a quick info if a game. I have boxes, heaps if them, but only four can be selected. They are choosen randomly. Once selected they becomes used and can not be opened again but can still be selected.

    So how would I make it choose a random value excluding the ones that are used. So if I select box 2, 5, 6, and 7. It will choose a random one using method suggested.

    But if a new lot of four are selected and it's. 4, 5, 8, 9
    How can I make it only to choose a random on out of 4,8, and 9 even though 5 is selected.

    Hope that makes sense

    Thanks
    Elfizm
  • ElfizmElfizm Member Posts: 489
    Just a quick bump because would be helpful to know if it's possible.

    Many thanks

    Elfizm
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Here's a demo:

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

Sign In or Register to comment.