My answers are theoretical. I haven't tested either or have never used tried them. I'm making some assumptions based on online documentation.
I believe one or both could work though. I'm sure Anne will correct me if I'm wrong.
Firstly, that
["crclrcg1l.webm" , "crclrcg2l.webm"]
is a
You must be registered to see the links
. Just an array of strings.
So I believe, you could store that list in a variable.
Python:
$ my_movie_list = ["crclrcg1l.webm" , "crclrcg2l.webm"]
play movie my_movie_list loop
Next, according to the documentation I linked to for the list, there are various things you can do to a list. In this case, I'm thinking
You must be registered to see the links
.
However, you want random not sorted. But the sort allows for you to define a custom key for sorting your list, using a function.
The example looks like this
(it sorts the list based on the length of the values):
Python:
# A function that returns the length of the value:
def myFunc(e):
return len(e)
cars = ['Ford', 'Mitsubishi', 'BMW', 'VW']
cars.sort(key=myFunc)
So now, I'm thinking that if the
key=
function returned a
You must be registered to see the links
- the list would be sorted into a random order. You might be able to do away with the function completely, since the generation of a random number is probably a function anyway. So maybe this would work?...
Python:
$ my_movie_list = ["crclrcg1l.webm" , "crclrcg2l.webm"]
play movie my_movie_list.sort(key=renpy.random.randint(0,99)) loop
But... you also mention that your player is able to press a button to change angles. That implies you don't want the full list of movies to play in
(random) sequence and instead want a single movie to play on a loop until the player presses the button and then for the game to swap to another random movie.
For that, I'm wondering if you perhaps want
You must be registered to see the links
instead.
Random choice picks a single random value from a list.
I'm thinking something like...
Python:
# play 1 random movie from the list
play movie renpy.random.choice(["crclrcg1l.webm" , "crclrcg2l.webm"]) loop
Which doesn't stop it randomly picking the same movie again.
Finally, there is also something called
You must be registered to see the links
.
note the extra "s". This returns a new list of random values based on an existing list. The new list can be longer than the original list (i.e. you can get 20 random output values based on 3 input values) - and for that reason, I wonder if it would generate duplicates even when trying to randomize a fixed number of values. (guessing... something like [1,2,3] -> [3,3,2] could be possible, I don't know.)
You might want to try it. I think it would look like this...
Python:
# play all movies from the list in random order (I hope).
play movie renpy.random.choices(["crclrcg1l.webm" , "crclrcg2l.webm"]) loop
You could make the whole system cleverer by
You must be registered to see the links
or
You must be registered to see the links
values to the list of available movies to be played, and maybe avoid the same movie being picked twice in a row.
Erm... maybe...
Python:
label play_movies:
$ movie_playlist = []
label repeat_play_movies:
if movie_playlist == []:
$ movie_playlist = ["crclrcg1l.webm" , "crclrcg2l.webm"]
$ picked_movie = renpy.random.choice(movie_playlist)
$ movie_playlist.remove(picked_movie)
play movie picked_movie loop
# I'm imagining a button that jumps back to "repeat_play_movies" to pick another random movie from the remaining playlist
# once the play list is empty, it is reset back to the full list.
As I say, this is all theoretical. I went looking at the documentation for python lists a while ago for something else. While reading stuff, I saw some of the functions. Hopefully, they work how I think they do.
Edit: Just saw Anne's answer... I probably need to add renpy.
in front of anything I've written using random.
. I think RenPy has a way of picking random numbers ahead of time to avoid players save-scumming their way through random events or rolling back and rolling forward to get a different random answer.