Random Rumor or Conversation Script?

I am looking for a script that I can use on villager events, where they will say something random drawn from a big pool(s) of dialogue. Preferably it can be divided into categories. For example, these villagers will only draw dialogue from the 'Town A' pool and those villagers from the 'Town B' pool. Or it could be mages will only speak from the 'Mage Dialogues' pool and warriors from 'Warrior Dialogues' pool. etc.

Is there something like this?
If you're using my External Text script, this is easy enough to do. Just set up your dialogue with keys like "Town A 1", "Town A 2", "Town B 1", and so on, and then use a script call like this:

text("Town A #{rand(NUMBER) + 1}")Replace NUMBER with the largest number that you used for the given key. If you start your numbering from 0 instead of 1, you can skip the + 1 in the call.

Edit: Ah, to clarify a bit -- if you start from 0, you'll need NUMBER to be one higher than the largest number that you used. Calling `rand` with an integer maximum will result in a value from 0 to that number, excluding the end point. For example,

rand(5)would produce a number from 0 to 4.

Edit 2: Fixed a typo that placed the + 1 in my script call inside of the parentheses for `rand`.
This looks interesting! I shall look into it.

Original thread: https://forums.rpgmakerweb.com/threads/random-rumor-or-conversation-script.41125/