Page 1 of 1

Help with a random save timer

Posted: Thu Jul 04, 2019 2:29 pm
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!

Re: Help with a random save timer

Posted: Fri Jul 05, 2019 4:27 pm
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.

Re: Help with a random save timer

Posted: Fri Jul 05, 2019 10:04 pm
by toast
Hey, thanks a lot Demonnic! I really appreciate this!

Re: Help with a random save timer

Posted: Sat Jul 06, 2019 3:16 pm
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 =)