Multi-Resolution Game Development With GameBuilder Studio Check it out!
NEW Version 0.9.7 has arrived! New Blazing Fast Particle Engine & More Game Actions. Check it out
Grabbing A Random Value From A List Data Component
  • If you ever wanted to get a random string or value entry from a List Data container to display a random label on a puzzle piece for example it is really easy. Add a List Data component to an entity, add a list of entries (A, B, C, D, etc...), add a Data component with a property called randomValue, then use a property setter to set the randomValue property to a random value from the List Data component. Use the following expression:

    Self.ListData["item"+randomRange( 0, 6 )]

    The expression above will grab a random entry between the index range of 0 and 6 on the List Data component and you can use it to set the randomValue property on a Data component. This is a concatenation technique used to access an entry on the List Data component.

    **Note: the List Data component is a zero index list so the first entry starts at 0.