First, create a list containing all the locations where you want to spawn mobs. We'll temporarily call this list 'SpawnLocations'. At this point, you should have a list with a few (or more) locations. To get a random location from that list, we first need to find the list's length. You can use the `Set Variable: Get List Length` code block for this. In the chest, enter a variable (we'll call it 'ListLength' for this explanation), and then input the 'SpawnLocations' variable as well.
Now, we’ll actually get a random location from that list. To do this, place a `Set Variable: Get List Value` code block. In the first slot, enter a variable. Name it...
First, create a list containing all the locations where you want to spawn mobs. We'll temporarily call this list 'SpawnLocations'. At this point, you should have a list with a few (or more) locations. To get a random location from that list, we first need to find the list's length. You can use the `Set Variable: Get List Length` code block for this. In the chest, enter a variable (we'll call it 'ListLength' for this explanation), and then input the 'SpawnLocations' variable as well.
Now, we’ll actually get a random location from that list. To do this, place a `Set Variable: Get List Value` code block. In the first slot, enter a variable. Name it anything you want (for this explanation, I'll call it 'LocationOutput'). This variable will store the randomly selected location. In the next slot, input the 'SpawnLocations' variable. Then, in the following slot, add a number. However, this can't be just any number. If it were a set number, the location wouldn't be random. Instead, we’ll use this command to get a specific number value: /num %random(1,%var(ListLength))
By running this command you'll get a number which you must put in the third slot of the `Set Variable: Get List Value`. If you want to know more about how this works, click the following spoiler:
If you use %random() instead of a set number, it will generate a random number within the range specified inside the brackets. For example, %random(1,5) will return a random number between 1 and 5. This helps you avoid adding an extra code block. Since we want to get a random number between 1 and the length of the 'SpawnLocations' list, you can use %var(ListLength) to represent that length. However, if you prefer using a code block for this, it’s called `Set Variable: Set To Random Number`.
After all this you can spawn a mob, and instead of inserting a set location you can insert the 'LocationOutput' variable.
All this should ensure you get a random location from a list of predefined locations, if you have any further questions please reply!