Help with a random save timer

Post Reply
toast
Posts: 3
Joined: Thu Jan 24, 2013 9:24 pm

Help with a random save timer

Post by toast »

Hey there guys, I love mudlet and these forums have helped me learn a lot more than I expected.

However (you knew there would be one), I need a little help with a random save timer. I play/idle on a MUD where I play a bard and write up my own songs and perform them in inns. How can I make a 10 minute save timer that would perform from a list of songs I've written randomly? I don't want to perform the same song in a row, so I'd like to have it do something like:

perform 1
perform 2
perform 3
perform 4
perform 5

but choose them randomly. Is this possible?

Thanks for any help!

User avatar
demonnic
Posts: 650
Joined: Sat Dec 05, 2009 3:19 pm

Re: Help with a random save timer

Post by demonnic »

Code: [show] | [select all] lua
mySongs = {
  "There once was a lad from Redania",
  "Hey diddle diddle, the cow ate my fiddle and this song no longer makes sense",
  "Once upon a midnight dreary while I pondered hale and hearty",
  "Something else because why not?"
}
songToPlay = mySongs[math.random(#mySongs)]
send(songToPlay)
This won't necessarily ensure that you never play the same one twice in a row, but it will give you a random entry out of the mySongs table to sing every time that code is run. To add more songs, just add them to the table, nothing else should need to be adjusted.

toast
Posts: 3
Joined: Thu Jan 24, 2013 9:24 pm

Re: Help with a random save timer

Post by toast »

Hey, thanks a lot Demonnic! I really appreciate this!

User avatar
demonnic
Posts: 650
Joined: Sat Dec 05, 2009 3:19 pm

Re: Help with a random save timer

Post by demonnic »

Happy to help! If you have any more questions, feel free to respond here. Or you can join us on Discord, you'll generally get a faster answer that way =)

Post Reply