setaudio node


The setaudio node changes the state of an audio node.

The primary function is to start, pause or restart an audio node.

For more information see the XML reference entry for setaudio.

Constructor audio_node , state , [id] )

The audio_node parameter indicates the audio node to change the state of.

The state parameter indicates the the name of the state to change to. The accepted values are setaudio.START, setaudio.PAUSE and setaudio.RESTART.

The parameter id is optional. If specified the node will be given this id.

Example C.62. Use of setaudio constructor

	<script type="text/x-lua">
		myaudio = scene:getById("myaudio")
		mysetaudio =, setaudio.START)

	<audio id="myaudio" filename="mymusic.ogg"/>



Functions common to action nodes


Resets this action such that it will occur again (from the beginning).

node:setNoTimes( val )

Sets the number of times this action should occur. Pass the value -1 to repeat indefinitely.

Example C.63. Use of setNoTimes

	<script type="text/x-lua">
		mytransition = scene:getById("mytransition")
	<transition id="mytransition"
				start="0 0 0" end="1 1 1" 
				length="1000 />

	<object id="myplane" type="primitives://plane.aro"/>

Functions common to nodes

col graphnode:getColor()

Returns a table of 4 values - red, green, blue and alpha (transparency) between 0.0 and 1.0.

Example C.64. Use of getColor

	<script type="text/x-lua">
		myplane = scene:getById("myplane")
		cols = myplace:getColor()
		red = cols[1]
		green = cols[2]
		blue = cols[3]
		alpha = cols[4]
	<object id="myplane" type="primitives://plane.aro" color="0.5 1 1 0.75"/>

boolean graphnode:isVisible()

Returns true if the node is set to visible, or false otherwise.

graphnode:setColor( col )

Sets the color of the node. Pass a 4-element table with entries { red, green, blue, alpha }. Values are expressed between 0.0 and 1.0.

Example C.65. Use of setColor

	<script type="text/x-lua">
		myplane = scene:getById("myplane")
		--         r    g   b    a
		newcol = { 0.1, 1, 0.5, 0.25 } 
	<object id="myplane" type="primitives://plane.aro"/>

graphnode:setVisible( true or false )

Sets the visibility of the node. Invisible nodes are not displayed and do not respond to events e.g. onhover, onclickdown etc.