Author Topic: An attempt to enhance the Announcer  (Read 951 times)

Offline Paranoia

An attempt to enhance the Announcer
« on: June 08, 2013, 09:24:06 AM »
    def Tick(self):
        # check to see if anyone has been "eliminated" by falling off the tabletop
        for each in self.players:
            if plus.getLocation(each)[1] < -6:
                plus.eliminatePlayer(each)
                deathOpt = ("Misc_SinisterLaugh1.wav", "Misc_SinisterLaugh3.wav", "Misc_DontLookDown.wav")
                sounds['death'] = plus.createSound("Sounds/announcers/"+random.choice(deathOpt), False, (0,0,0))
                plus.playSound(sounds['death'])

This script is part of that from Flextop, it causes a Runtime-Error when a bot is eliminated from falling. Any idea why?

Offline Trovaner

  • *
  • Posts: 1222
  • Rep: 32
    • View Profile
    • Awards
Re: An attempt to enhance the Announcer
« Reply #1 on: June 08, 2013, 12:24:26 PM »
The variable "sounds" is not defined in that scope (RA2 doesn't know that you assigned a dictionary named "sounds" because you only have it looking locally and the actual variable is defined locally in another method). Without any sort of testing, I'm thinking that this would work for you:
Code: [Select]
    def Tick(self):
        # check to see if anyone has been "eliminated" by falling off the tabletop
        for each in self.players:
            plus.eliminatePlayer(each)
            deathOpt = ("Misc_SinisterLaugh1.wav", "Misc_SinisterLaugh3.wav", "Misc_DontLookDown.wav")
            deathSound = plus.createSound("Sounds/announcers/"+random.choice(deathOpt), False, (0,0,0))
            plus.playSound(deathSound)