ZombieMudAn Information Source about ZombieMud Lyntin sounds
Currently only handles wav files, only for lack to trying anything else. Use: "#playsound cowbell 3" to play cowbell.wav in the sounds directory, three times. """ import sys,time,os from lyntin import exported from lyntin.modules import modutils from pygame import mixer from pygame.mixer import music sounds = {} dir = None def readSounds(newdir): global sounds,dir sounds = {} if not os.path.isdir(newdir): dir = None return dir = newdir for file in os.listdir(dir): if file.endswith(".wav"): sounds[file[:-4]] = file readSounds(exported.myengine.getConfigManager().get("datadir") + "sounds") mixer.init() def playcmd(ses, args, input): global sounds,dir name = args["name"] loops = int(args["loops"]) if not name in sounds: exported.writemessage("No such sound: " + name, ses) music.load(os.path.join(dir, sounds[name])) music.play(loops) commandsdict = {} commandsdict["playsound"] = (play_cmd, "name loops=1") def load(): """ Initializes the module by binding all the commands.""" modutils.loadcommands(commandsdict) def unload(): """ Unbinds the commands (for when we reimport the module).""" modutils.unloadcommands(commandsdict) last updated 2 years ago # |