![]() |
#1
|
|||
|
|||
audio object string
The following script contains a function which attempts to play
an audio file which is passed as an argument. Before calling the function I want to construct the name of the audio object by concatenating character strings, but it doesn't work. Can you tell me the correct way to do this? Code:
from viz import * go() sound1 = add('boing!.wav') def playit(snd): snd.play() num = 1 s = 'sound'+str(num) playit(s) |
#2
|
|||
|
|||
Are you trying to look up a Python object by its name? The following will look up the name in the current global variable scope and play the sound if it exists:
Code:
def playit(snd): soundObject = globals().get(snd,None) if soundObject is not None: soundObject.play() |
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
retrieve Object names | Geoffrey | Vizard | 11 | 12-11-2009 04:26 AM |
Child Object Rotation | paulgoldberg | Vizard | 5 | 09-05-2006 11:33 AM |
when collision mode is on, can i "turn it off" for an individual object? | Vdoug | Vizard | 1 | 09-22-2005 12:14 PM |
rotate to object | jargon | Vizard | 1 | 08-08-2005 12:20 PM |
Getting the String of a Text3d Object | vjosh | Vizard | 1 | 01-03-2005 11:37 PM |