mardi 3 novembre 2020

Lua - Choose a random value from a range (or table) excluding the values of a (or another) table

A range, 1, 2, 3, 4, 5, 6, 7, 8 (it can populate a Lua table if it makes it easier)
table = {1, 4, 3}

The possible random choice should be among 2, 5, 6, 7, 8.

In Python I have used this to get it:

possibleChoices = random.choice([i for i in range(9) if i not in table])

Any ideas how to achieve the same in Lua?




Aucun commentaire:

Enregistrer un commentaire