WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-13-2008, 10:01 AM
Jerry Jerry is offline
Member
 
Join Date: Jun 2004
Posts: 105
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)
Reply With Quote
  #2  
Old 03-13-2008, 11:06 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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()
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
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


All times are GMT -7. The time now is 12:20 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC