<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<presentation version="2">
    <scenegraph>
        <node type="scene" xmlid="1" name="Scene" priority="0" timeindependent="true" initialplaystate="1" playmode="0" looptime="10000" backgroundcolor="0 0 0 255">
            <node type="behavior" initialFocusObject="string:{EC3B24F7-FB23-4501-8E82-32A4A4C37E83}" xmlref="2" xmlid="3" priority="1" timeoffset="0" duration="10000" />
            <node type="contract" xmlref="4" xmlid="5" priority="2" timeoffset="0" duration="10300" />
            <node type="behavior" xmlref="6" xmlid="7" priority="3" timeoffset="0" duration="10000" />
            <node type="layer" xmlref="8" xmlid="9" priority="4" timeoffset="0" duration="10000">
                <node type="light" xmlref="10" xmlid="11" priority="1" timeoffset="0" duration="10000" />
                <node type="camera" xmlref="12" xmlid="13" priority="2" timeoffset="0" duration="10000" />
                <node type="model" xmlref="14" xmlid="15" name="Red" priority="3" timeoffset="0" duration="10000" position="-200.962 0 0">
                    <node type="material" xmlref="16" xmlid="17" priority="1" timeoffset="0" duration="10000" diffuse="255 0 0 255" />
                </node>
                <node type="model" xmlref="14" xmlid="18" name="Green" priority="4" timeoffset="0" duration="10000">
                    <node type="material" xmlref="16" xmlid="19" priority="1" timeoffset="0" duration="10000" diffuse="0 255 0 255" />
                </node>
                <node type="model" xmlref="14" xmlid="20" name="Blue" priority="5" timeoffset="0" duration="10000" position="200 0 0">
                    <node type="material" xmlref="16" xmlid="21" priority="1" timeoffset="0" duration="10000" diffuse="0 0 255 255" />
                </node>
            </node>
        </node>
    </scenegraph>
    <library>
        <node type="light" xmlid="10" name="Light" timeindependent="false" pivot="0 0 0" rotation="0 0 0" positionvelocity="0 0 0" scale="1 1 1" rotationvelocity="0 0 0" position="0 0 0" outerconeangle="180" diffuse="255 255 255 255" range="1000" expfade="0" linearfade="0" ambient="0 0 0 255" source="0" brightness="100" specular="255 255 255 255" innerconeangle="90" />
        <node type="camera" xmlid="12" name="Camera" timeindependent="false" pivot="0 0 0" rotation="0 0 0" positionvelocity="0 0 0" scale="1 1 1" rotationvelocity="0 0 0" position="0 0 -600" orthographic="false" clipfar="5000" lookatlock="false" fogtype="2" lookatpoint="0 0 0" fov="60" fogfar="5000" fogenable="false" fogmode="0" fogcolor="0 0 0 0" clipnear="10" fognear="0" />
        <node type="behavior" upEvent="string:onUp" gridNames="string:" aksourcefilepath="file://C:\Program Files\Anark\Anark Studio 3.5.5\Gameface\Samples\Behaviors\Interactive\DVD Focus Nav.bvs" initialFocusObject="string:" mergeSpotsFlag="bool:false" rightEvent="string:onRight" downEvent="string:onDown" leftEvent="string:onLeft" selectEvent="string:onSelect" wrapAroundFlag="bool:true" xmlid="2" uiContract="string:Scene.UIContract" rememberLastFlag="bool:false" name="DVD Focus Nav" bufferref="22" timeindependent="false" />
        <node type="contract" _AKContractClass="string:UIContract" aksourcefilepath="file://C:\Program Files\Anark\Anark Studio 3.6\Gameface\Samples\Behaviors\Interactive\UIContract.bvs" xmlid="4" _AKIsContract="bool:true" name="UIContract" priority="0" bufferref="23" timeindependent="false" />
        <node type="material" xmlid="16" name="Material3577" timeindependent="false" opacity="100" shadetype="1" zbufferwrite="2" diffuse="255 255 255 255" specularpower="100" blendmode="0" specularenable="false" subsetindex="0" emissivepower="0" fillmode="0" ambient="128 128 128 255" specular="64 64 64 255" culling="2" />
        <node type="behavior" aksourcefilepath="file://C:\Program Files\Anark\Anark Studio 3.5.5\Gameface\Samples\Behaviors\Anark Lua Library.bvs" xmlid="6" name="Anark Lua Library" bufferref="24" timeindependent="false" />
        <node type="layer" xmlid="8" name="Layer" opacity="100" x="0" y="0" layerheight="100" transparent="false" layerwidth="100" color="0 0 0 255" pivotx="0" pivoty="0" />
        <node type="model" xmlid="14" name="Rectangle" bufferref="25" timeindependent="false" opacity="100" pivot="0 0 0" rotation="0 0 0" positionvelocity="0 0 0" scale="1 1 1" rotationvelocity="0 0 0" position="0 0 0" />
        <node type="scriptbuffer" name="DVD Focus Nav" xmlid="22" aksourcefilepath="file://C:\Program Files\Anark\Anark Studio 3.5.5\Gameface\Samples\Behaviors\Interactive\DVD Focus Nav.bvs" scripttype="Lua" scriptdata='--[[&#x0D;&#x0A;*********************************************************************&#x0D;&#x0A;*&#x09;Behavior: DVD Focus Nav.bvs&#x0D;&#x0A;*&#x0D;&#x0A;*&#x09;For information on how to use this behavior refer to&#x0D;&#x0A;*&#x09;the Gameface Samples Reference included with Anark Studio.&#x0D;&#x0A;*&#x0D;&#x0A;*&#x09;Tooltips and use for each parameter of this behavior&#x0D;&#x0A;*&#x09;are available in the Inspector Palette of Anark Studio.&#x0D;&#x0A;*&#x0D;&#x0A;*&#x09;Copyright 2005, Anark Corporation.&#x0D;&#x0A;*&#x09;ALL RIGHTS RESERVED&#x0D;&#x0A;*&#x0D;&#x0A;*********************************************************************&#x0D;&#x0A;--]]&#x0D;&#x0A;&#x0D;&#x0A;function self:onInitialize( )&#x0D;&#x0A;&#x09;assert( AKActiveWatcher, &quot;The &apos;&quot; .. self.name .. &quot;&apos; behavior requires the Anark Lua Library behavior to be present.&quot; )&#x0D;&#x0A;&#x09;self.focusTransitions = {}&#x0D;&#x0A;&#x09;self.eventNames       = {}&#x0D;&#x0A;&#x0D;&#x0A;&#x09;self.grid = string.tabCSVToGrid( self.gridNames )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;-- Match names in the grid to row/col assignment&#x0D;&#x0A;&#x09;-- Multiple cells with the same name map to the last-seen spot&#x0D;&#x0A;&#x09;self.rowColByName = {}&#x0D;&#x0A;&#x09;self.numCols = 0&#x0D;&#x0A;&#x09;for rowNum,theRow in ipairs( self.grid ) do&#x0D;&#x0A;&#x09;&#x09;self.numCols = math.max( self.numCols, table.getn( theRow ) )&#x0D;&#x0A;&#x09;&#x09;for colNum, theCell in ipairs( theRow ) do&#x0D;&#x0A;&#x09;&#x09;&#x09;self.rowColByName[ theCell ] = { row=rowNum, col=colNum }&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;self.numRows = table.getn( self.grid )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;self.eventBVS = self:getObjectReference( &apos;uiContract&apos; )&#x0D;&#x0A;&#x09;if self.eventBVS then&#x0D;&#x0A;&#x09;&#x09;self:registerForEvent( self.eventBVS, self.leftEvent,  function() self:handleMoveEvent( self.leftEvent  ) end )&#x09;&#x0D;&#x0A;&#x09;&#x09;self:registerForEvent( self.eventBVS, self.rightEvent, function() self:handleMoveEvent( self.rightEvent ) end )&#x0D;&#x0A;&#x09;&#x09;self:registerForEvent( self.eventBVS, self.upEvent,    function() self:handleMoveEvent( self.upEvent    ) end )&#x0D;&#x0A;&#x09;&#x09;self:registerForEvent( self.eventBVS, self.downEvent,  function() self:handleMoveEvent( self.downEvent  ) end )&#x0D;&#x0A;&#x09;&#x09;self:registerForEvent( self.eventBVS, self.selectEvent, self.handleSelect )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;self.initialFocusObject = self:getObjectReference( &apos;initialFocusObject&apos; )&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;-- TODO: remove once native onActivate is available&#x0D;&#x0A;&#x09;self:watchActive( )&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;self:registerForEvent( self, &apos;onActivate&apos;, self.ensureFocus )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;-- Ensure that an object is focused&#x0D;&#x0A;function self:ensureFocus( )&#x0D;&#x0A;&#x09;if not AKFocusable.focusedItem or not AKFocusable.focusedItem.globalactive then&#x0D;&#x0A;&#x09;&#x09;if self.lastFocusedItem then&#x0D;&#x0A;&#x09;&#x09;&#x09;self.lastFocusedItem:focus( )&#x0D;&#x0A;&#x09;&#x09;elseif self.initialFocusObject and type(self.initialFocusObject.focus) == &apos;function&apos; then&#x0D;&#x0A;&#x09;&#x09;&#x09;self.initialFocusObject:focus( )&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;if self.rememberLastFlag then&#x0D;&#x0A;&#x09;&#x09;&#x09;self.lastFocusedItem = AKFocusable.focusedItem&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;function self:handleMoveEvent( inEvtName )&#x0D;&#x0A;&#x09;-- Should not get to a state where nothing is selected...but just in case&#x0D;&#x0A;&#x09;if not AKFocusable.focusedItem then&#x0D;&#x0A;&#x09;&#x09;if self.initialFocusObject and type(self.initialFocusObject.focus) == &apos;function&apos; then&#x0D;&#x0A;&#x09;&#x09;&#x09;self.initialFocusObject:focus( )&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;return&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;local theFocusedItemName = AKFocusable.focusedItem.name&#x0D;&#x0A;&#x09;local theSpot = self.rowColByName[ theFocusedItemName ]&#x0D;&#x0A;&#x09;assert( theSpot, &quot;DVD Focus Nav does not know about the currently focused item (&quot; .. theFocusedItemName .. &quot;)&quot; )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;-- Figure out the current spot in the grid; use the last saved spot&#x0D;&#x0A;&#x09;-- if it exists and I&apos;m not supposed to &apos;merge&apos; the spots&#x0D;&#x0A;&#x09;local theRowNum = ( self.lastRowNum and not self.mergeSpotsFlag ) and self.lastRowNum or theSpot.row&#x0D;&#x0A;&#x09;local theColNum = ( self.lastColNum and not self.mergeSpotsFlag ) and self.lastColNum or theSpot.col&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;local theNextItem&#x0D;&#x0A;&#x0D;&#x0A;&#x09;-- Loop along the current row/column and find the next item that is focusable&#x0D;&#x0A;&#x09;-- (not the same as the current item, and not disabled)&#x0D;&#x0A;&#x09;-- If we find such an item, then &quot;theNextItem&quot; will be non-nil&#x0D;&#x0A;&#x09;if inEvtName == self.rightEvent then&#x0D;&#x0A;&#x0D;&#x0A;&#x09;&#x09;for n=1,self.numCols do&#x0D;&#x0A;&#x09;&#x09;&#x09;theColNum = theColNum + 1&#x0D;&#x0A;&#x09;&#x09;&#x09;if theColNum &gt; self.numCols then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;if self.wrapAroundFlag then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;&#x09;theColNum = 1&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;&#x09;break&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x0D;&#x0A;&#x09;&#x09;&#x09;-- Use the name to find the item in the global collection&#x0D;&#x0A;&#x09;&#x09;&#x09;theNextItem = AKFocusable.items[ self.grid[ theRowNum ][ theColNum ] ]&#x0D;&#x0A;&#x09;&#x09;&#x09;if theNextItem and theNextItem ~= AKFocusable.focusedItem and theNextItem:isFocusable( ) then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;-- We found it!&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;break&#x0D;&#x0A;&#x09;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;-- Clear out the selection so to indicate that it&apos;s no good&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theNextItem = nil&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;elseif inEvtName == self.leftEvent then&#x0D;&#x0A;&#x09;&#x09;&#x0D;&#x0A;&#x09;&#x09;for n=1,self.numCols do&#x0D;&#x0A;&#x09;&#x09;&#x09;theColNum = theColNum - 1&#x0D;&#x0A;&#x09;&#x09;&#x09;if theColNum &lt; 1 then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;if self.wrapAroundFlag then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;&#x09;theColNum = self.numCols&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;&#x09;break&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x0D;&#x0A;&#x09;&#x09;&#x09;-- Use the name to find the item in the global collection&#x0D;&#x0A;&#x09;&#x09;&#x09;theNextItem = AKFocusable.items[ self.grid[ theRowNum ][ theColNum ] ]&#x0D;&#x0A;&#x09;&#x09;&#x09;if theNextItem and theNextItem ~= AKFocusable.focusedItem and theNextItem:isFocusable( ) then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;-- We found it!&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;break&#x0D;&#x0A;&#x09;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;-- Clear out the selection so to indicate that it&apos;s no good&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theNextItem = nil&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;elseif inEvtName == self.upEvent then&#x0D;&#x0A;&#x0D;&#x0A;&#x09;&#x09;for n=1,self.numRows do&#x0D;&#x0A;&#x09;&#x09;&#x09;theRowNum = theRowNum - 1&#x0D;&#x0A;&#x09;&#x09;&#x09;if theRowNum &lt; 1 then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;if self.wrapAroundFlag then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;&#x09;theRowNum = self.numRows&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;&#x09;break&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x0D;&#x0A;&#x09;&#x09;&#x09;-- Use the name to find the item in the global collection&#x0D;&#x0A;&#x09;&#x09;&#x09;theNextItem = AKFocusable.items[ self.grid[ theRowNum ][ theColNum ] ]&#x0D;&#x0A;&#x09;&#x09;&#x09;if theNextItem and theNextItem ~= AKFocusable.focusedItem and theNextItem:isFocusable( ) then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;-- We found it!&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;break&#x0D;&#x0A;&#x09;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;-- Clear out the selection so to indicate that it&apos;s no good&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theNextItem = nil&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;elseif inEvtName == self.downEvent then&#x0D;&#x0A;&#x0D;&#x0A;&#x09;&#x09;for n=1,self.numRows do&#x0D;&#x0A;&#x09;&#x09;&#x09;theRowNum = theRowNum + 1&#x0D;&#x0A;&#x09;&#x09;&#x09;if theRowNum &gt; self.numRows then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;if self.wrapAroundFlag then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;&#x09;theRowNum = 1&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;&#x09;break&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x0D;&#x0A;&#x09;&#x09;&#x09;-- Use the name to find the item in the global collection&#x0D;&#x0A;&#x09;&#x09;&#x09;theNextItem = AKFocusable.items[ self.grid[ theRowNum ][ theColNum ] ]&#x0D;&#x0A;&#x09;&#x09;&#x09;if theNextItem and theNextItem ~= AKFocusable.focusedItem and theNextItem:isFocusable( ) then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;-- We found it!&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;break&#x0D;&#x0A;&#x09;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;-- Clear out the selection so to indicate that it&apos;s no good&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theNextItem = nil&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;-- Find the object being referred to&#x0D;&#x0A;&#x09;if theNextItem then&#x0D;&#x0A;&#x09;&#x09;theNextItem:focus( )&#x0D;&#x0A;&#x09;&#x09;if self.rememberLastFlag then&#x0D;&#x0A;&#x09;&#x09;&#x09;self.lastFocusedItem = AKFocusable.focusedItem&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;&#x09;-- Save the current spot&#x0D;&#x0A;&#x09;&#x09;self.lastRowNum = theRowNum&#x0D;&#x0A;&#x09;&#x09;self.lastColNum = theColNum&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;-- Use the &apos;select&apos; event from the UIContract to call the select() method&#x0D;&#x0A;-- on the currently-focused item&#x0D;&#x0A;function self:handleSelect( )&#x0D;&#x0A;&#x09;if AKFocusable.focusedItem and type( AKFocusable.focusedItem.select ) == &apos;function&apos; then&#x0D;&#x0A;&#x09;&#x09;AKFocusable.focusedItem:select( )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;' scriptname="DVD Focus Nav" scriptversion="1" />
        <node type="scriptbuffer" name="UIContract" xmlid="23" aksourcefilepath="file://C:\Program Files\Anark\Anark Studio 3.6\Gameface\Samples\Behaviors\Interactive\UIContract.bvs" scripttype="Lua" scriptdata='--[[&#x0D;&#x0A;*********************************************************************&#x0D;&#x0A;*&#x09;Behavior: UIContract.bvs&#x0D;&#x0A;*&#x0D;&#x0A;*&#x09;For information on how to use this behavior refer to&#x0D;&#x0A;*&#x09;the Gameface Samples Reference included with Anark Studio.&#x0D;&#x0A;*&#x0D;&#x0A;*&#x09;Tooltips and use for each parameter of this behavior&#x0D;&#x0A;*&#x09;are available in the Inspector Palette of Anark Studio.&#x0D;&#x0A;*&#x0D;&#x0A;*&#x09;Copyright 2005, Anark Corporation.&#x0D;&#x0A;*&#x09;ALL RIGHTS RESERVED&#x0D;&#x0A;*&#x0D;&#x0A;*********************************************************************&#x0D;&#x0A;--]]&#x0D;&#x0A;&#x0D;&#x0A;function self:onInitialize( )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;-- For easy debugging, a global reference to this behavior&#x0D;&#x0A;&#x09;uicontract = self&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;-- For easy debugging: make global functions to fire the events;&#x0D;&#x0A;&#x09;-- &quot;right()&quot; fires &quot;onRight&quot;, and so on.&#x0D;&#x0A;&#x09;local theEvents = {&apos;onUp&apos;,&apos;onDown&apos;,&apos;onLeft&apos;,&apos;onRight&apos;,&apos;onSelect&apos;,&apos;onBack&apos;}&#x0D;&#x0A;&#x09;for i=1,table.getn( theEvents ) do&#x0D;&#x0A;&#x09;&#x09;local theEventName = theEvents[ i ]&#x0D;&#x0A;&#x09;&#x09;local theFunctionName = string.lower( string.gsub( theEventName, &apos;^on&apos;, &apos;&apos; ) )&#x0D;&#x0A;&#x09;&#x09;_G[ theFunctionName ] = function( )&#x0D;&#x0A;&#x09;&#x09;&#x09;-- &quot;self&quot; is available since this function is a closure&#x0D;&#x0A;&#x09;&#x09;&#x09;self:fireEvent( Event:new( theEventName ) )&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;' customevents="26 27 28 29 30 31" scriptname="UIContract" scriptversion="3" />
        <node type="modelbuffer" name="Rectangle" xmlid="25" modeldata="18 -50.000 -50.000 0.000 0.000 0.000 -1.000 0.000 1.000 -50.000 0.000 0.000 0.000 0.000 -1.000 0.000 0.500 -50.000 50.000 0.000 0.000 0.000 -1.000 0.000 0.000 0.000 -50.000 0.000 0.000 0.000 -1.000 0.500 1.000 0.000 0.000 0.000 0.000 0.000 -1.000 0.500 0.500 0.000 50.000 0.000 0.000 0.000 -1.000 0.500 0.000 50.000 -50.000 0.000 0.000 0.000 -1.000 1.000 1.000 50.000 0.000 0.000 0.000 0.000 -1.000 1.000 0.500 50.000 50.000 0.000 0.000 0.000 -1.000 1.000 0.000 -50.000 -50.000 0.000 0.000 0.000 1.000 0.000 1.000 -50.000 0.000 0.000 0.000 0.000 1.000 0.000 0.500 -50.000 50.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 -50.000 0.000 0.000 0.000 1.000 0.500 1.000 0.000 0.000 0.000 0.000 0.000 1.000 0.500 0.500 0.000 50.000 0.000 0.000 0.000 1.000 0.500 0.000 50.000 -50.000 0.000 0.000 0.000 1.000 1.000 1.000 50.000 0.000 0.000 0.000 0.000 1.000 1.000 0.500 50.000 50.000 0.000 0.000 0.000 1.000 1.000 0.000 1 16 0 1 4 0 4 3 1 2 5 1 5 4 3 4 7 3 7 6 4 5 8 4 8 7 9 13 10 9 12 13 10 14 11 10 13 14 12 16 13 12 15 16 13 17 14 13 16 17 " resolution="2" primitivetype="1" subtype="2" />
        <node type="scriptbuffer" name="Anark Lua Library" xmlid="24" aksourcefilepath="file://C:\Program Files\Anark\Anark Studio 3.5.5\Gameface\Samples\Behaviors\Anark Lua Library.bvs" scripttype="Lua" scriptdata='&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************&#x0D;&#x0A;*&#x09;Behavior: Anark Lua Library.bvs&#x0D;&#x0A;*&#x0D;&#x0A;*&#x09;For information on how to use this behavior refer to&#x0D;&#x0A;*&#x09;the Gameface Samples Reference included with Anark Studio.&#x0D;&#x0A;*&#x0D;&#x0A;*&#x09;Tooltips and use for each parameter of this behavior&#x0D;&#x0A;*&#x09;are available in the Inspector Palette of Anark Studio.&#x0D;&#x0A;*&#x0D;&#x0A;*&#x09;Copyright 2005, Anark Corporation.&#x0D;&#x0A;*&#x09;ALL RIGHTS RESERVED&#x0D;&#x0A;*&#x0D;&#x0A;*********************************************************************&#x0D;&#x0A;--]]&#x0D;&#x0A;&#x0D;&#x0A;scene = scene or Presentation.scene&#x0D;&#x0A;&#x0D;&#x0A;-- A few global temporary objects for re-use by scripts&#x0D;&#x0A;for i=1,5 do&#x0D;&#x0A;&#x09;_G[ &apos;tmpV&apos; .. i ] = Vector:new( )&#x0D;&#x0A;&#x09;_G[ &apos;tmpR&apos; .. i ] = Rotation:new( )&#x0D;&#x0A;&#x09;_G[ &apos;tmpC&apos; .. i ] = Color:new( )&#x0D;&#x0A;&#x09;_G[ &apos;tmpM&apos; .. i ] = Matrix:new( )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** LUA CLASSES v1.5.2 **********************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;]]&#x0D;&#x0A;AKObject = {&#x0D;&#x0A;&#x09;-- This function is used to create the Class object&#x0D;&#x0A;&#x09;-- and also as the new() for each class instance&#x0D;&#x0A;&#x09;new = function( self )&#x0D;&#x0A;&#x09;&#x09;local theInstance = { class=self, prototype = {} }&#x0D;&#x0A;&#x09;&#x09;theInstance.prototype.class = self&#x0D;&#x0A;&#x09;&#x09;setmetatable( theInstance, self.instancemeta )&#x0D;&#x0A;&#x09;&#x09;return theInstance&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;}&#x0D;&#x0A;AKObject.prototype    = {   class = AKObject }&#x0D;&#x0A;AKObject.classmeta    = { __index = AKObject }&#x0D;&#x0A;AKObject.instancemeta = { __index = AKObject.prototype }&#x0D;&#x0A;&#x0D;&#x0A;-- Classes are objects too; they inherit methods from the Object prototype&#x0D;&#x0A;AKClass = AKObject:new( )&#x0D;&#x0A;&#x0D;&#x0A;-- Classes use a special constructor that allows superclasses to be specified&#x0D;&#x0A;-- The superclass defaults to AKObject&#x0D;&#x0A;-- Instances of Class inherit methods from the Superclass&#x0D;&#x0A;-- Class instances inherit from the Superclass&apos;s prototype&#x0D;&#x0A;function AKClass:new( inSuperClass )&#x0D;&#x0A;&#x09;if not inSuperClass then inSuperClass = AKObject end&#x0D;&#x0A;&#x09;local theClass = { class=self, superclass=inSuperClass, prototype = { } }&#x0D;&#x0A;&#x09;theClass.classmeta    = { __index = theClass }&#x0D;&#x0A;&#x09;theClass.instancemeta = { __index = theClass.prototype }&#x0D;&#x0A;&#x09;setmetatable( theClass, inSuperClass.classmeta )&#x0D;&#x0A;&#x09;setmetatable( theClass.prototype, inSuperClass.instancemeta )&#x0D;&#x0A;&#x09;return theClass&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** WINDOWED LIST v1.1.0 ********************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;A table which provides easy access to viewing subsets of items within it.&#x0D;&#x0A;]]&#x0D;&#x0A;AKWindowedList = AKClass:new( )&#x0D;&#x0A;&#x0D;&#x0A;function AKWindowedList.instancemeta:__tostring( )&#x0D;&#x0A;&#x09;local theResult = &quot;&lt;AKWindowedList current=&quot; .. tostring( self[ self._currentIndex ] ) .. &quot; items={ &quot;&#x0D;&#x0A;&#x09;local theLength = table.getn(self)&#x0D;&#x0A;&#x09;for i=1,theLength do&#x0D;&#x0A;&#x09;&#x09;local theValue = self[ i ]&#x0D;&#x0A;&#x09;&#x09;theResult = theResult .. tostring( theValue ) .. ( &quot;, &quot; )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;theResult = theResult .. &quot;} &gt;&quot;&#x0D;&#x0A;&#x09;return theResult&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Create a new circular list with the supplied arguments as values.&#x0D;&#x0A;function AKWindowedList:new( ... )&#x0D;&#x0A;&#x09;local theList = AKObject.new( self )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;for i,v in ipairs( arg ) do theList[ i ] = v end&#x0D;&#x0A;&#x09;local theNumItems = table.getn( arg )&#x0D;&#x0A;&#x09;table.setn( theList, theNumItems )&#x0D;&#x0A;&#x09;theList._currentIndex = ( theNumItems &gt; 0 ) and 1 or 0&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;return theList&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Append all the supplied values to the end of the list&#x0D;&#x0A;function AKWindowedList.prototype:append( ... )&#x0D;&#x0A;&#x09;for _,v in ipairs( arg ) do&#x0D;&#x0A;&#x09;&#x09;table.insert( self, v )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;if self._currentIndex == 0 then self._currentIndex = 1 end&#x0D;&#x0A;&#x09;return self&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Insert all the supplied values immediately after the current value&#x0D;&#x0A;function AKWindowedList.prototype:insert( ... )&#x0D;&#x0A;&#x09;for i,v in ipairs( arg ) do&#x0D;&#x0A;&#x09;&#x09;table.insert( self, self._currentIndex + i, v )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;if self._currentIndex == 0 then self._currentIndex = 1 end&#x0D;&#x0A;&#x09;return self&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Reset the list to hold the supplied values only.&#x0D;&#x0A;-- The first argument is the new current item.&#x0D;&#x0A;function AKWindowedList.prototype:set( ... )&#x0D;&#x0A;&#x09;for i,v in ipairs( arg ) do&#x0D;&#x0A;&#x09;&#x09;self[ i ] = v&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;table.setn( self, table.getn( arg ) )&#x0D;&#x0A;&#x09;self._currentIndex = 1&#x0D;&#x0A;&#x09;return self&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Remove each of the arguments from the list&#x0D;&#x0A;function AKWindowedList.prototype:remove( ... )&#x0D;&#x0A;&#x09;-- Setup a hash for quick lookup&#x0D;&#x0A;&#x09;local theItemsToRemove = {}&#x0D;&#x0A;&#x09;for _,v in ipairs( arg ) do&#x0D;&#x0A;&#x09;&#x09;theItemsToRemove[ v ] = true&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;local theOldLength = table.getn( self )&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;-- Copy down the arguments&#x0D;&#x0A;&#x09;local theListIndex = 0&#x0D;&#x0A;&#x09;for i=1,table.getn( self ) do&#x0D;&#x0A;&#x09;&#x09;local theValue = self[ i ]&#x0D;&#x0A;&#x09;&#x09;if theItemsToRemove[ theValue ] then&#x0D;&#x0A;&#x09;&#x09;&#x09;if self._currentIndex &gt;= i then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;self._currentIndex = self._currentIndex - 1&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x09;theListIndex = theListIndex + 1&#x0D;&#x0A;&#x09;&#x09;&#x09;if theListIndex ~= i then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;self[ theListIndex ] = theValue&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;table.setn( self, theListIndex )&#x0D;&#x0A;&#x09;if self._currentIndex &gt; theListIndex then&#x0D;&#x0A;&#x09;&#x09;self._currentIndex = 1&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;-- Wipe out unnecessary references&#x0D;&#x0A;&#x09;for i=theListIndex+1, theOldLength do&#x0D;&#x0A;&#x09;&#x09;self[ i ] = nil&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;return self&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Returns the current value&#x0D;&#x0A;function AKWindowedList.prototype:current( )&#x0D;&#x0A;&#x09;return self[ self._currentIndex ]&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Set the current value to be the value that is inValuesAhead forward in the list&#x0D;&#x0A;-- Defaults to 1 value ahead (the next value)&#x0D;&#x0A;function AKWindowedList.prototype:advance( inValuesAhead )&#x0D;&#x0A;&#x09;if not inValuesAhead then inValuesAhead = 1 end&#x0D;&#x0A;&#x09;self._currentIndex = math.min( self._currentIndex + inValuesAhead, table.getn( self ) )&#x0D;&#x0A;&#x09;return self&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Set the current value to be the value that is inValuesBehind backward in the list.&#x0D;&#x0A;-- Defaults to 1 value behind (the previous value).&#x0D;&#x0A;function AKWindowedList.prototype:rewind( inValuesBehind )&#x0D;&#x0A;&#x09;if not inValuesBehind then inValuesBehind = 1 end&#x0D;&#x0A;&#x09;return self:advance( -inValuesBehind )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Return a list of inNumValues adjacent to the current value, including the current value.&#x0D;&#x0A;-- If an odd number is supplied, the values will be centered around the current value;&#x0D;&#x0A;-- if an even number is supplied, the value will be in the second half of values.&#x0D;&#x0A;-- As the current value nears the edges of the list, the &apos;window&apos; will be offset&#x0D;&#x0A;-- to always return inNumValues items.&#x0D;&#x0A;-- If an outValues table is supplied, it will be modified (and returned) to hold the values.&#x0D;&#x0A;-- Also returns the items just outside the list as secondary and tertiary values&#x0D;&#x0A;function AKWindowedList.prototype:near( inNumValues, outValues )&#x0D;&#x0A;&#x09;local theValues = outValues or { }&#x0D;&#x0A;&#x09;local theLength = table.getn( self )&#x0D;&#x0A;&#x09;local theMod&#x0D;&#x0A;&#x0D;&#x0A;&#x09;if inNumValues &gt; theLength then&#x0D;&#x0A;&#x09;&#x09;inNumValues = theLength&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;local theStart = self._currentIndex - math.floor( inNumValues / 2 )&#x0D;&#x0A;&#x09;if theStart &lt; 1 then&#x0D;&#x0A;&#x09;&#x09;theStart = 1&#x0D;&#x0A;&#x09;elseif ( theStart + inNumValues ) &gt; theLength then&#x0D;&#x0A;&#x09;&#x09;theStart = theLength - inNumValues + 1&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;for i=0, inNumValues - 1 do&#x0D;&#x0A;&#x09;&#x09;theValues[ i + 1 ] = self[ i + theStart ]&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;-- Clear out old values from the supplied table&#x0D;&#x0A;&#x09;if theValues == outValues then&#x0D;&#x0A;&#x09;&#x09;for i=math.abs(inNumValues)+1, table.getn( theValues ) do&#x0D;&#x0A;&#x09;&#x09;&#x09;theValues[ i ] = nil&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;table.setn( theValues, inNumValues )&#x0D;&#x0A;&#x09;theValues.startIndex = theStart&#x0D;&#x0A;&#x09;return theValues, self[ theStart - 1 ], self[ theStart + inNumValues ]&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Return a list of values that are NOT inNumNearValues adjacent to the current value.&#x0D;&#x0A;-- Will never include the current item, even if inNumNearValues is 0.&#x0D;&#x0A;-- If an outValues table is supplied, it will be modified (and returned) to hold the values.&#x0D;&#x0A;function AKWindowedList.prototype:far( inNumNearValues, outValues )&#x0D;&#x0A;&#x09;local theValues = outValues or { }&#x0D;&#x0A;&#x09;local theLength = table.getn( self )&#x0D;&#x0A;&#x09;local theMod&#x0D;&#x0A;&#x0D;&#x0A;&#x09;if inNumNearValues &lt; 1 then&#x0D;&#x0A;&#x09;&#x09;inNumValues = 1&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;local theStart = self._currentIndex - math.floor( inNumNearValues / 2 )&#x0D;&#x0A;&#x09;if theStart &lt; 1 then&#x0D;&#x0A;&#x09;&#x09;theStart = 1&#x0D;&#x0A;&#x09;elseif ( theStart + inNumNearValues ) &gt; theLength then&#x0D;&#x0A;&#x09;&#x09;theStart = theLength - inNumNearValues + 1&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;local theEnd = theStart + inNumNearValues - 1&#x0D;&#x0A;&#x0D;&#x0A;&#x09;local theValueIndex = 0&#x0D;&#x0A;&#x09;for i,theValue in ipairs( self ) do&#x0D;&#x0A;&#x09;&#x09;if i &lt; theStart or i &gt; theEnd then&#x0D;&#x0A;&#x09;&#x09;&#x09;theValueIndex = theValueIndex + 1&#x0D;&#x0A;&#x09;&#x09;&#x09;theValues[ theValueIndex ] = theValue&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;-- Clear out old values from the supplied table&#x0D;&#x0A;&#x09;if theValues == outValues then&#x0D;&#x0A;&#x09;&#x09;for i=theValueIndex+1, table.getn( theValues ) do&#x0D;&#x0A;&#x09;&#x09;&#x09;theValues[ i ] = nil&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;table.setn( theValues, theValueIndex )&#x0D;&#x0A;&#x09;return theValues&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** CIRCULAR LIST v1.0 **********************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;A windowed list whose items wrap around at the ends.&#x0D;&#x0A;]]&#x0D;&#x0A;AKCircularList = AKClass:new( AKWindowedList )&#x0D;&#x0A;&#x0D;&#x0A;-- Create a new circular list with the supplied arguments as values.&#x0D;&#x0A;function AKCircularList:new( ... )&#x0D;&#x0A;&#x09;local theList = AKWindowedList.new( self, unpack( arg ) )&#x0D;&#x0A;&#x09;return theList&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Set the current value to be the value that is inValuesAhead forward in the list&#x0D;&#x0A;-- Defaults to 1 value ahead (the next value)&#x0D;&#x0A;function AKCircularList.prototype:advance( inValuesAhead )&#x0D;&#x0A;&#x09;if not inValuesAhead then inValuesAhead = 1 end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;local theLength = table.getn( self )&#x0D;&#x0A;&#x09;local theMod = math.mod( self._currentIndex + inValuesAhead - 1, theLength ) + 1&#x0D;&#x0A;&#x09;if theMod &lt; 1 then&#x0D;&#x0A;&#x09;&#x09;theMod = theLength + theMod&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;self._currentIndex = theMod&#x0D;&#x0A;&#x09;return self&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Set the current value to be the value that is inValuesBehind backward in the list.&#x0D;&#x0A;-- Defaults to 1 value behind (the previous value).&#x0D;&#x0A;function AKCircularList.prototype:rewind( inValuesBehind )&#x0D;&#x0A;&#x09;if not inValuesBehind then inValuesBehind = 1 end&#x0D;&#x0A;&#x09;return self:advance( -inValuesBehind )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Return a list of inNumValues adjacent to the current value, including the current value.&#x0D;&#x0A;-- Returns a second value, which is the index of the current item in the returned list.&#x0D;&#x0A;-- If an odd number is supplied, the values will be centered around the current value;&#x0D;&#x0A;-- if an even number is supplied, the value will be in the second half of values.&#x0D;&#x0A;-- If an outValues table is supplied, it will be modified (and returned) to hold the values.&#x0D;&#x0A;function AKCircularList.prototype:near( inNumValues, outValues )&#x0D;&#x0A;&#x09;local theValues = outValues or { }&#x0D;&#x0A;&#x09;local theLength = table.getn( self )&#x0D;&#x0A;&#x09;local theMod&#x0D;&#x0A;&#x0D;&#x0A;&#x09;if inNumValues &gt; theLength then&#x0D;&#x0A;&#x09;&#x09;inNumValues = theLength&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;local theOffset = -math.floor( inNumValues / 2 ) - 1&#x0D;&#x0A;&#x0D;&#x0A;&#x09;for i=0, inNumValues - 1 do&#x0D;&#x0A;&#x09;&#x09;theMod = math.mod( self._currentIndex + i + theOffset, theLength ) + 1&#x0D;&#x0A;&#x09;&#x09;if theMod &lt; 1 then&#x0D;&#x0A;&#x09;&#x09;&#x09;theMod = theLength + theMod&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;theValues[ i + 1 ] = self[ theMod ]&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;-- Clear out old values from the supplied table&#x0D;&#x0A;&#x09;if theValues == outValues then&#x0D;&#x0A;&#x09;&#x09;for i=math.abs(inNumValues)+1, table.getn( theValues ) do&#x0D;&#x0A;&#x09;&#x09;&#x09;theValues[ i ] = nil&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;table.setn( theValues, inNumValues )&#x0D;&#x0A;&#x09;return theValues, -theOffset&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Return a list of values that are NOT inNumNearValues adjacent to the current value.&#x0D;&#x0A;-- Will never include the current item, even if inNumNearValues is 0.&#x0D;&#x0A;-- If an outValues table is supplied, it will be modified (and returned) to hold the values.&#x0D;&#x0A;function AKCircularList.prototype:far( inNumNearValues, outValues )&#x0D;&#x0A;&#x09;local theValues = outValues or { }&#x0D;&#x0A;&#x09;local theLength = table.getn( self )&#x0D;&#x0A;&#x09;local theMod&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;if inNumNearValues &lt; 1 then&#x0D;&#x0A;&#x09;&#x09;inNumNearValues = 1&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;local theNumValues = theLength - inNumNearValues&#x0D;&#x0A;&#x09;local theOffset = math.ceil( inNumNearValues / 2 ) - 1&#x0D;&#x0A;&#x0D;&#x0A;&#x09;for i=0, theNumValues-1 do&#x0D;&#x0A;&#x09;&#x09;theMod = math.mod( self._currentIndex + i + theOffset, theLength ) + 1&#x0D;&#x0A;&#x09;&#x09;if theMod &lt; 1 then&#x0D;&#x0A;&#x09;&#x09;&#x09;theMod = theLength + theMod&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;theValues[ i + 1 ] = self[ theMod ]&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;-- Clear out old values from the supplied table&#x0D;&#x0A;&#x09;if theValues == outValues then&#x0D;&#x0A;&#x09;&#x09;for i=math.abs(theNumValues)+1, table.getn( theValues ) do&#x0D;&#x0A;&#x09;&#x09;&#x09;theValues[ i ] = nil&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;table.setn( theValues, theNumValues )&#x0D;&#x0A;&#x09;return theValues&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Return a list of inNumValues forward from the current value, including the current value&#x0D;&#x0A;-- If an outValues table is supplied, it will be modified (and returned) to hold the values&#x0D;&#x0A;function AKCircularList.prototype:next( inNumValues, outValues )&#x0D;&#x0A;&#x09;local theValues = outValues or { }&#x0D;&#x0A;&#x09;local theLength = table.getn( self )&#x0D;&#x0A;&#x09;local theMod&#x0D;&#x0A;&#x0D;&#x0A;&#x09;if inNumValues &gt; 0 then&#x0D;&#x0A;&#x09;&#x09;for i=0, inNumValues-1 do&#x0D;&#x0A;&#x09;&#x09;&#x09;theMod = math.mod( self._currentIndex + i - 1, theLength ) + 1&#x0D;&#x0A;&#x09;&#x09;&#x09;if theMod &lt; 1 then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theMod = theLength + theMod&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;theValues[ i + 1 ] = self[ theMod ]&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;else&#x0D;&#x0A;&#x09;&#x09;for i=0, -inNumValues-1 do&#x0D;&#x0A;&#x09;&#x09;&#x09;theMod = math.mod( self._currentIndex - i - 1, theLength ) + 1&#x0D;&#x0A;&#x09;&#x09;&#x09;if theMod &lt; 1 then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theMod = theLength + theMod&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;theValues[ i + 1 ] = self[ theMod ]&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;-- Clear out old values from the supplied table&#x0D;&#x0A;&#x09;if theValues == outValues then&#x0D;&#x0A;&#x09;&#x09;for i=math.abs(inNumValues)+1, table.getn( theValues ) do&#x0D;&#x0A;&#x09;&#x09;&#x09;theValues[ i ] = nil&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;table.setn( theValues, inNumValues )&#x0D;&#x0A;&#x09;return theValues&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Return a list of inNumValues behind the current value, including the current value&#x0D;&#x0A;function AKCircularList.prototype:previous( inNumValues, outValues )&#x0D;&#x0A;&#x09;return self:next( -inNumValues, outValues )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** ANIMATOR v1.0 ***************************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;Animate any property of an object to a destination value over time&#x0D;&#x0A;Uses straight linear interpolation - no ease in/out or bezier curve&#x0D;&#x0A;]]&#x0D;&#x0A;AKAnimator = { animations = { } }&#x0D;&#x0A;&#x0D;&#x0A;function Node:animatePropertyTo( inPropertyName, inDestValue, inTime )&#x0D;&#x0A;&#x09;AKAnimator:animate( self, inPropertyName, inDestValue, inTime )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function Node:animatePropertyBy( inPropertyName, inChangeAmount, inTime )&#x0D;&#x0A;&#x09;local theValue = self[ inPropertyName ]&#x0D;&#x0A;&#x09;local theDestValue&#x0D;&#x0A;&#x09;if type( theValue ) == &apos;number&apos; then&#x0D;&#x0A;&#x09;&#x09;theDestValue = theDestValue + inChangeAmount&#x0D;&#x0A;&#x09;else&#x0D;&#x0A;&#x09;&#x09;if theValue.setVector then&#x0D;&#x0A;&#x09;&#x09;&#x09;theDestValue = Vector:new( )&#x0D;&#x0A;&#x09;&#x09;elseif theValue.setRotation then&#x0D;&#x0A;&#x09;&#x09;&#x09;theDestValue = Rotation:new( )&#x0D;&#x0A;&#x09;&#x09;elseif theValue.setColor then&#x0D;&#x0A;&#x09;&#x09;&#x09;theDestValue = Color:new( )&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;theDestValue:setFromSame( theValue )&#x0D;&#x0A;&#x09;&#x09;theDestValue:add( inChangeAmount )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;AKAnimator:animate( self, inPropertyName, theDestValue, inTime )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;-- Linearly animate a property of an object from the current value to a new value over time&#x0D;&#x0A;function AKAnimator:animate( inObject, inPropertyName, inDestValue, inTime )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;if inObject.animations then&#x0D;&#x0A;&#x09;&#x09;-- We can&apos;t leave the old track running; it&apos;d be slower, and&#x0D;&#x0A;&#x09;&#x09;-- might run over this track&#x0D;&#x0A;&#x09;&#x09;local theExistingAnimation = inObject.animations[ inPropertyName ]&#x0D;&#x0A;&#x09;&#x09;if theExistingAnimation then&#x0D;&#x0A;&#x09;&#x09;&#x09;self.animations[ theExistingAnimation ] = nil&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;else&#x0D;&#x0A;&#x09;&#x09;-- Create a hash to store animation tracks per property name&#x0D;&#x0A;&#x09;&#x09;inObject.animations = { }&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;local theAnimInfo = {&#x0D;&#x0A;&#x09;&#x09;object      = inObject,&#x0D;&#x0A;&#x09;&#x09;propName    = inPropertyName,&#x0D;&#x0A;&#x09;&#x09;destValue   = inDestValue,&#x0D;&#x0A;&#x09;&#x09;startTime   = Presentation.runTime,&#x0D;&#x0A;&#x09;&#x09;endTime     = Presentation.runTime + inTime&#x0D;&#x0A;&#x09;}&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;local theValue = inObject[ inPropertyName ]&#x0D;&#x0A;&#x09;assert( theValue )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;if type(theValue) == &apos;number&apos; then&#x0D;&#x0A;&#x09;&#x09;theAnimInfo.changeRate = ( inDestValue - theValue ) / inTime&#x0D;&#x0A;&#x09;&#x09;theAnimInfo.isNumberFlag = true&#x0D;&#x0A;&#x09;&#x09;theAnimInfo.startValue = theValue&#x0D;&#x0A;&#x0D;&#x0A;&#x09;elseif inPropertyName == &apos;position&apos; then&#x0D;&#x0A;&#x09;&#x09;inObject.positionVelocity:setVector( inDestValue )&#x0D;&#x0A;&#x09;&#x09;inObject.positionVelocity:subtract( theValue )&#x0D;&#x0A;&#x09;&#x09;inObject.positionVelocity:scale( 1 / inTime )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;elseif inPropertyName == &apos;rotation&apos; then&#x0D;&#x0A;&#x09;&#x09;inObject.rotationVelocity:setRotation( inDestValue )&#x0D;&#x0A;&#x09;&#x09;inObject.rotationVelocity:subtract( theValue )&#x0D;&#x0A;&#x09;&#x09;inObject.rotationVelocity:scale( math.deg( 1 / inTime ) )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;else&#x0D;&#x0A;&#x09;&#x09;if theValue.setVector then&#x0D;&#x0A;&#x09;&#x09;&#x09;theAnimInfo.changeRate = Vector:new( )&#x0D;&#x0A;&#x09;&#x09;elseif theValue.setRotation then&#x0D;&#x0A;&#x09;&#x09;&#x09;theAnimInfo.changeRate = Rotation:new( )&#x0D;&#x0A;&#x09;&#x09;elseif theValue.setColor then&#x0D;&#x0A;&#x09;&#x09;&#x09;theAnimInfo.changeRate = Color:new( )&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;&#x09;theAnimInfo.changeRate:setFromSame( inDestValue )&#x0D;&#x0A;&#x09;&#x09;theAnimInfo.changeRate:subtract( theValue )&#x0D;&#x0A;&#x09;&#x09;theAnimInfo.changeRate:scale( 1 / inTime )&#x0D;&#x0A;&#x09;&#x09;theAnimInfo.startValue = theValue:copy( )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;self.animations[ theAnimInfo ] = 1&#x0D;&#x0A;&#x09;inObject.animations[ inPropertyName ] = theAnimInfo&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;if not self.runningFlag then&#x0D;&#x0A;&#x09;&#x09;-- Start calling the runAnimations function every frame&#x0D;&#x0A;&#x09;&#x09;Presentation.scene:registerForEvent( -1, &apos;onUpdate&apos;, self.runAnimations )&#x0D;&#x0A;&#x09;&#x09;self.runningFlag = true&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- A single function called onUpdate to handle all registered animations&#x0D;&#x0A;function AKAnimator.runAnimations( )&#x0D;&#x0A;&#x09;local self = AKAnimator&#x0D;&#x0A;&#x09;local theActiveAnimationsFlag = false&#x0D;&#x0A;&#x09;local theTime = Presentation.runTime&#x0D;&#x0A;&#x0D;&#x0A;&#x09;for theAnimInfo,_ in pairs( self.animations ) do&#x0D;&#x0A;&#x09;&#x09;if theTime &gt;= theAnimInfo.endTime then&#x0D;&#x0A;&#x09;&#x09;&#x09;-- This track is finished: set the value absolutely&#x0D;&#x0A;&#x09;&#x09;&#x09;if theAnimInfo.isNumberFlag then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theAnimInfo.object[ theAnimInfo.propName ] = theAnimInfo.destValue&#x0D;&#x0A;&#x09;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;if theAnimInfo.propName == &apos;position&apos; then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;&#x09;theAnimInfo.object.positionVelocity:set( 0, 0, 0 )&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;elseif theAnimInfo.propName == &apos;rotation&apos; then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;&#x09;theAnimInfo.object.rotationVelocity:set( 0, 0, 0 )&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theAnimInfo.object[ theAnimInfo.propName ]:setFromSame( theAnimInfo.destValue )&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x0D;&#x0A;&#x09;&#x09;&#x09;-- Delete the track fully&#x0D;&#x0A;&#x09;&#x09;&#x09;self.animations[ theAnimInfo ] = nil&#x0D;&#x0A;&#x09;&#x09;&#x09;theAnimInfo.object.animations[ theAnimInfo.propName ] = nil&#x0D;&#x0A;&#x0D;&#x0A;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x0D;&#x0A;&#x09;&#x09;&#x09;theActiveAnimationsFlag = true&#x0D;&#x0A;&#x09;&#x09;&#x09;local theElapsedTime = theTime - theAnimInfo.startTime&#x0D;&#x0A;&#x09;&#x09;&#x09;if theAnimInfo.isNumberFlag then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theAnimInfo.object[ theAnimInfo.propName ] = theAnimInfo.startValue + theAnimInfo.changeRate * theElapsedTime&#x0D;&#x0A;&#x09;&#x09;&#x09;elseif theAnimInfo.propName ~= &apos;position&apos; and theAnimInfo.propName ~= &apos;rotation&apos; then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;local theValue = theAnimInfo.object[ theAnimInfo.propName ]&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theValue:setFromSame( theAnimInfo.changeRate )&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theValue:scale( theElapsedTime )&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theValue:add( theAnimInfo.startValue )&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;if not theActiveAnimationsFlag then&#x0D;&#x0A;&#x09;&#x09;-- No need to keep calling this function each frame&#x0D;&#x0A;&#x09;&#x09;Presentation.scene:unregisterForEvent( -1, &apos;onUpdate&apos;, self.runAnimations )&#x0D;&#x0A;&#x09;&#x09;self.runningFlag = false&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Provide same-named features on Vector, Rotation and Color&#x0D;&#x0A;-- so that single code branches can treat all the same&#x0D;&#x0A;Color.setFromSame    = Color.setColor&#x0D;&#x0A;Vector.setFromSame   = Vector.setVector&#x0D;&#x0A;Rotation.setFromSame = Rotation.setRotation&#x0D;&#x0A;&#x0D;&#x0A;function Color:scale( inScaleFactor )&#x0D;&#x0A;&#x09;self.r = self.r * inScaleFactor&#x0D;&#x0A;&#x09;self.g = self.g * inScaleFactor&#x0D;&#x0A;&#x09;self.b = self.b * inScaleFactor&#x0D;&#x0A;&#x09;self.a = self.a * inScaleFactor&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function Color:subtract( inColor )&#x0D;&#x0A;&#x09;self.r = self.r - inColor.r&#x0D;&#x0A;&#x09;self.g = self.g - inColor.g&#x0D;&#x0A;&#x09;self.b = self.b - inColor.b&#x0D;&#x0A;&#x09;self.a = self.a - inColor.a&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function Color:add( inColor )&#x0D;&#x0A;&#x09;self.r = self.r + inColor.r&#x0D;&#x0A;&#x09;self.g = self.g + inColor.g&#x0D;&#x0A;&#x09;self.b = self.b + inColor.b&#x0D;&#x0A;&#x09;self.a = self.a + inColor.a&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** FOCUSABLE v1.6.1 ************************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;Ensures that only one item in the scene may be focused at any time; focusing&#x0D;&#x0A;one item automatically unfocuses the previously-focused item.&#x0D;&#x0A;&#x0D;&#x0A;Adds focus() and unfocus() methods to both the Behavior and the parent object.&#x0D;&#x0A;(Calling a method on one is the same as calling it on the other.)&#x0D;&#x0A;&#x0D;&#x0A;Fires an onFocus event on the Behavior when the object receives focus,&#x0D;&#x0A;and an onUnfocus event on the Behavior when the object loses focus.&#x0D;&#x0A;Fires an onFocusChanged event on the Scene whenever focus changes.&#x0D;&#x0A;&#x0D;&#x0A;Adds focusNext() and focusPrev() to the Behavior, the parent, and&#x0D;&#x0A;the global AKFocusable object. These methods treat all Focusable items as a&#x0D;&#x0A;circular list. The order of items is controlled by a custom &quot;focusIndex&quot; property&#x0D;&#x0A;on the Behavior or its parent object. (Think of tab index.) If this property is&#x0D;&#x0A;not present, the order that the items were made focusable is used.&#x0D;&#x0A;&#x0D;&#x0A;Focus will not be permitted if a Lua &quot;disabledFlag&quot; property is set, or if&#x0D;&#x0A;the parent object is not active. (Such items will also be skipped during&#x0D;&#x0A;calls to the focusNext() or focusPrev() methods.)&#x0D;&#x0A;&#x0D;&#x0A;AKFocusable.focusedItem points to the currently-focused node (not Behavior).&#x0D;&#x0A;Focusable behaviors and nodes have a focusedFlag boolean property.&#x0D;&#x0A;&#x0D;&#x0A;---&#x0D;&#x0A;&#x0D;&#x0A;Adds disable() and enable() methods to both the Behavior and the parent object.&#x0D;&#x0A;(Calling a method on one is the same as calling it on the other.)&#x0D;&#x0A;&#x0D;&#x0A;Fires an onDisable event on the Behavior when the object is disabled,&#x0D;&#x0A;and an onEnable event on the Behavior when the object is re-enabled.&#x0D;&#x0A;&#x0D;&#x0A;Adds a disabledFlag boolean property to the Behavior and the parent.&#x0D;&#x0A;&#x0D;&#x0A;Disabling an object will prevent it from receiving focus;&#x0D;&#x0A;disabling a focused object will unfocus it.&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;]]&#x0D;&#x0A;-- Use self:makeFocusable( ) on an object to make&#x0D;&#x0A;-- it control its own focus, firing events on itself.&#x0D;&#x0A;function Node:makeFocusable( )&#x0D;&#x0A;&#x09;self.focusNext   = AKFocusable.focusNext&#x0D;&#x0A;&#x09;self.focusPrev   = AKFocusable.focusPrev&#x0D;&#x0A;&#x09;self.focus       = AKFocusable.focus&#x0D;&#x0A;&#x09;self.unfocus     = AKFocusable.unfocus&#x0D;&#x0A;&#x09;self.disable     = AKFocusable.disable&#x0D;&#x0A;&#x09;self.enable      = AKFocusable.enable&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;AKFocusable.addItem( self )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;-- Use self:_makeFocusable( ) on a Behavior to make&#x0D;&#x0A;-- it control the focus for its parent object.&#x0D;&#x0A;--TODO: should only be on Behavior, once available&#x0D;&#x0A;function Node:_makeFocusable( inObjToControl )&#x0D;&#x0A;&#x09;--Exchange references, for coupled communication&#x0D;&#x0A;&#x09;inObjToControl._focusableBehavior = self&#x0D;&#x0A;&#x09;self._focus_controlledObject = inObjToControl&#x0D;&#x0A;&#x0D;&#x0A;&#x09;--Add methods to the instances&#x0D;&#x0A;&#x09;self.focusNext   = AKFocusable.focusNext&#x0D;&#x0A;&#x09;self.focusPrev   = AKFocusable.focusPrev&#x0D;&#x0A;&#x09;self.focus       = AKFocusable.focus&#x0D;&#x0A;&#x09;self.unfocus     = AKFocusable.unfocus&#x0D;&#x0A;&#x09;self.disable     = AKFocusable.disable&#x0D;&#x0A;&#x09;self.enable      = AKFocusable.enable&#x0D;&#x0A;&#x09;inObjToControl.focusNext   = AKFocusable.focusNext&#x0D;&#x0A;&#x09;inObjToControl.focusPrev   = AKFocusable.focusPrev&#x0D;&#x0A;&#x09;inObjToControl.focus       = AKFocusable.proxyFocus&#x0D;&#x0A;&#x09;inObjToControl.unfocus     = AKFocusable.proxyUnfocus&#x0D;&#x0A;&#x09;inObjToControl.disable     = AKFocusable.proxyDisable&#x0D;&#x0A;&#x09;inObjToControl.enable      = AKFocusable.proxyEnable&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;self.focusedFlag  = false&#x0D;&#x0A;&#x09;self.disabledFlag = false&#x0D;&#x0A;&#x09;inObjToControl.focusIndex = inObjToControl.focusIndex or self.focusIndex&#x0D;&#x0A;&#x09;AKFocusable.addItem( inObjToControl )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;AKFocusable = {&#x0D;&#x0A;&#x09;focusedItem = nil,&#x0D;&#x0A;&#x09;items = { },&#x0D;&#x0A;&#x09;focusChangedEvent = Event:new( &quot;onFocusChanged&quot; )&#x0D;&#x0A;}&#x0D;&#x0A;&#x0D;&#x0A;function AKFocusable:addItem( )&#x0D;&#x0A;&#x09;--Put a single reference to myself in the focusable list&#x0D;&#x0A;&#x09;local theFocusableItems = AKFocusable.items&#x0D;&#x0A;&#x09;if self.name then&#x0D;&#x0A;&#x09;&#x09;theFocusableItems[ self.name ] = self&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;table.addToSet( theFocusableItems, self )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;--Sort items by focusIndex&#x0D;&#x0A;&#x09;self.focusIndex = self.focusIndex or ( 100000 + table.getn( theFocusableItems ) )&#x0D;&#x0A;&#x09;table.sort( theFocusableItems, AKFocusable.sortByFocusIndex )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;self.focusedFlag  = false&#x0D;&#x0A;&#x09;self.disabledFlag = false&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKFocusable:focusNext( )&#x0D;&#x0A;&#x09;if AKFocusable.focusedItem then&#x0D;&#x0A;&#x09;&#x09;local theNextItem = table.nextInCircle( AKFocusable.items, AKFocusable.focusedItem, Node.isFocusable )&#x0D;&#x0A;&#x09;&#x09;if theNextItem then&#x0D;&#x0A;&#x09;&#x09;&#x09;theNextItem:focus( )&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;elseif AKFocusable.items[ 1 ] then&#x0D;&#x0A;&#x09;&#x09;AKFocusable.items[ 1 ]:focus( )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;return AKFocusable.focusedItem&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKFocusable:focusPrev( )&#x0D;&#x0A;&#x09;if AKFocusable.focusedItem then&#x0D;&#x0A;&#x09;&#x09;local thePrevItem = table.prevInCircle( AKFocusable.items, AKFocusable.focusedItem, Node.isFocusable )&#x0D;&#x0A;&#x09;&#x09;if thePrevItem then &#x0D;&#x0A;&#x09;&#x09;&#x09;thePrevItem:focus( )&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;elseif AKFocusable.items[ 1 ] then&#x0D;&#x0A;&#x09;&#x09;AKFocusable.items[ 1 ]:focus( )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;return AKFocusable.focusedItem&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function Node:isFocusable( )&#x0D;&#x0A;&#x09;if type( self.focus ) == &apos;function&apos; and self.globalactive and not self.disabledFlag then&#x0D;&#x0A;&#x09;&#x09;return true &#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKFocusable.sortByFocusIndex( a, b )&#x0D;&#x0A;&#x09;return a.focusIndex &lt; b.focusIndex&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKFocusable:focus( )&#x0D;&#x0A;&#x09;if not self.focusedFlag and not self.disabledFlag then&#x0D;&#x0A;&#x09;&#x09;if AKFocusable.focusedItem then&#x0D;&#x0A;&#x09;&#x09;&#x09;AKFocusable.focusedItem:unfocus( )&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;self:fireQueuedEvent( Event:new( &quot;onFocus&quot; ) )&#x0D;&#x0A;&#x09;&#x09;self.focusedFlag = true&#x0D;&#x0A;&#x09;&#x09;if self._focus_controlledObject then&#x0D;&#x0A;&#x09;&#x09;&#x09;self._focus_controlledObject.focusedFlag = true&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;AKFocusable.focusedItem = self._focus_controlledObject or self&#x0D;&#x0A;&#x09;&#x09;Presentation.scene:fireEvent( AKFocusable.focusChangedEvent )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKFocusable:unfocus( )&#x0D;&#x0A;&#x09;if self.focusedFlag then&#x0D;&#x0A;&#x09;&#x09;self:fireQueuedEvent( Event:new( &quot;onUnfocus&quot; ) )&#x0D;&#x0A;&#x09;&#x09;self.focusedFlag = false&#x0D;&#x0A;&#x09;&#x09;if self._focus_controlledObject then&#x0D;&#x0A;&#x09;&#x09;&#x09;self._focus_controlledObject.focusedFlag = false&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;AKFocusable.focusedItem = nil&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKFocusable:disable( )&#x0D;&#x0A;&#x09;-- Explicitly check for true to allow initial disabling&#x0D;&#x0A;&#x09;if self.disabledFlag ~= true then&#x0D;&#x0A;&#x09;&#x09;self:fireQueuedEvent( Event:new( &quot;onDisable&quot; ) )&#x0D;&#x0A;&#x09;&#x09;self.disabledFlag = true&#x0D;&#x0A;&#x09;&#x09;if self._focus_controlledObject then&#x0D;&#x0A;&#x09;&#x09;&#x09;self._focus_controlledObject.disabledFlag = true&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;if self.focusedFlag then&#x0D;&#x0A;&#x09;&#x09;&#x09;-- Do not invoke the unfocus() method, because that will fire an onUnfocus event&#x0D;&#x0A;&#x09;&#x09;&#x09;-- which can mess up slide logic for complex states&#x0D;&#x0A;&#x09;&#x09;&#x09;self.focusedFlag = false&#x0D;&#x0A;&#x09;&#x09;&#x09;if self._focus_controlledObject then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;self._focus_controlledObject.focusedFlag = false&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;AKFocusable.focusedItem = nil&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKFocusable:enable( )&#x0D;&#x0A;&#x09;if self.disabledFlag then&#x0D;&#x0A;&#x09;&#x09;self:fireQueuedEvent( Event:new( &quot;onEnable&quot; ) )&#x0D;&#x0A;&#x09;&#x09;self.disabledFlag = false&#x0D;&#x0A;&#x09;&#x09;if self._focus_controlledObject then&#x0D;&#x0A;&#x09;&#x09;&#x09;self._focus_controlledObject.disabledFlag = false&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKFocusable:proxyFocus( )&#x0D;&#x0A;&#x09;self._focusableBehavior:focus( )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKFocusable:proxyUnfocus( )&#x0D;&#x0A;&#x09;self._focusableBehavior:unfocus( )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKFocusable:proxyDisable( )&#x0D;&#x0A;&#x09;self._focusableBehavior:disable( )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKFocusable:proxyEnable( )&#x0D;&#x0A;&#x09;self._focusableBehavior:enable( )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;-- Treat the table as an array; ensure that the value is present&#x0D;&#x0A;-- in the table, adding it if necessary. No tests are performed&#x0D;&#x0A;-- to ensure that the given value is not alread present in the&#x0D;&#x0A;-- table more than once.&#x0D;&#x0A;-- Returns false if the value was already present in the table,&#x0D;&#x0A;-- true otherwise.&#x0D;&#x0A;function table.addToSet( self, value )&#x0D;&#x0A;&#x09;for i,v in ipairs( self ) do&#x0D;&#x0A;&#x09;&#x09;if v == value then&#x0D;&#x0A;&#x09;&#x09;&#x09;return false&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;table.insert( self, value )&#x0D;&#x0A;&#x09;return true&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;-- Treat the table as a circular list; find the next item in the list&#x0D;&#x0A;-- after the given index (or value) that yields a return value of &#x0D;&#x0A;-- true when passed to the supplied function.&#x0D;&#x0A;-- Does not work for values that are numbers.&#x0D;&#x0A;function table.nextInCircle( self, inIndexOrValue, inSelectFunction )&#x0D;&#x0A;&#x09;local theIndex = inIndexOrValue&#x0D;&#x0A;&#x0D;&#x0A;&#x09;-- If a value was supplied, find the value&#x0D;&#x0A;&#x09;if type( theIndex ) ~= &apos;number&apos; then&#x0D;&#x0A;&#x09;&#x09;for i,v in ipairs( self ) do&#x0D;&#x0A;&#x09;&#x09;&#x09;if v==theIndex then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theIndex = i&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;break&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;assert( self[ theIndex ], &quot;Could not find item &apos;&quot; .. tostring( inIndexOrValue ) .. &quot;&apos; in &quot; .. tostring( self ) )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;local theLength = table.getn( self )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;if not inSelectFunction then&#x0D;&#x0A;&#x09;&#x09;-- Return the next item in the list&#x0D;&#x0A;&#x09;&#x09;if theIndex == theLength then&#x0D;&#x0A;&#x09;&#x09;&#x09;return self[ 1 ]&#x0D;&#x0A;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x09;return self[ theIndex + 1 ]&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;else&#x0D;&#x0A;&#x09;&#x09;-- Prevent infinite looping&#x0D;&#x0A;&#x09;&#x09;for n=1,theLength do&#x0D;&#x0A;&#x09;&#x09;&#x09;theIndex = theIndex + 1&#x0D;&#x0A;&#x09;&#x09;&#x09;if theIndex &gt; theLength then theIndex = 1 end&#x0D;&#x0A;&#x09;&#x09;&#x09;local theValue = self[ theIndex ]&#x0D;&#x0A;&#x09;&#x09;&#x09;if inSelectFunction( theValue, inIndex ) then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;return theValue&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;return nil&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function table.prevInCircle( self, inIndexOrValue, inSelectFunction )&#x0D;&#x0A;&#x09;local theIndex = inIndexOrValue&#x0D;&#x0A;&#x0D;&#x0A;&#x09;-- If a value was supplied, find the value&#x0D;&#x0A;&#x09;if type( theIndex ) ~= &apos;number&apos; then&#x0D;&#x0A;&#x09;&#x09;for i,v in ipairs( self ) do&#x0D;&#x0A;&#x09;&#x09;&#x09;if v==theIndex then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theIndex = i&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;break&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;assert( self[ theIndex ], &quot;Could not find item &apos;&quot; .. tostring( inIndexOrValue ) .. &quot;&apos; in &quot; .. tostring( self ) )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;local theLength = table.getn( self )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;if not inSelectFunction then&#x0D;&#x0A;&#x09;&#x09;-- Return the next item in the list&#x0D;&#x0A;&#x09;&#x09;if theIndex == 1 then&#x0D;&#x0A;&#x09;&#x09;&#x09;return self[ theLength ]&#x0D;&#x0A;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x09;return self[ theIndex - 1 ]&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;else&#x0D;&#x0A;&#x09;&#x09;-- Prevent infinite looping&#x0D;&#x0A;&#x09;&#x09;for n=1,theLength do&#x0D;&#x0A;&#x09;&#x09;&#x09;theIndex = theIndex - 1&#x0D;&#x0A;&#x09;&#x09;&#x09;if theIndex &lt; 1 then theIndex = theLength end&#x0D;&#x0A;&#x09;&#x09;&#x09;local theValue = self[ theIndex ]&#x0D;&#x0A;&#x09;&#x09;&#x09;if inSelectFunction( theValue, inIndex ) then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;return theValue&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;return nil&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** SELECTABLE v1.4 *************************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;Toggles an item between being selected or not. (Like a checkbox.)&#x0D;&#x0A;&#x0D;&#x0A;Adds select() and deselect() methods to both the Behavior and the parent object.&#x0D;&#x0A;(Calling a method on one is the same as calling it on the other.)&#x0D;&#x0A;&#x0D;&#x0A;Fires an onSelect event on the Behavior when the object is selected,&#x0D;&#x0A;and an onDeselect event on the Behavior when the object is deselected.&#x0D;&#x0A;&#x0D;&#x0A;Selection will not be permitted if a Lua &quot;lockedFlag&quot; property is set, or if&#x0D;&#x0A;the parent object is not active.&#x0D;&#x0A;&#x0D;&#x0A;Adds a selectedFlag boolean property to the Behavior and the parent.&#x0D;&#x0A;&#x0D;&#x0A;---&#x0D;&#x0A;&#x0D;&#x0A;Adds lock() and unlock() methods to both the Behavior and the parent object.&#x0D;&#x0A;(Calling a method on one is the same as calling it on the other.)&#x0D;&#x0A;&#x0D;&#x0A;Fires an onLock event on the Behavior when the object is locked,&#x0D;&#x0A;and an onUnlock event on the Behavior when the object is no longer locked.&#x0D;&#x0A;&#x0D;&#x0A;Adds a lockedFlag boolean property to the Behavior and the parent.&#x0D;&#x0A;&#x0D;&#x0A;Locking an object will prevent it from changing its selection state.&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;]]&#x0D;&#x0A;AKSelectable = { }&#x0D;&#x0A;&#x0D;&#x0A;-- Use self:makeSelectable( ) on an object to make&#x0D;&#x0A;-- it control its own selection, firing events on itself.&#x0D;&#x0A;function Node:makeSelectable( inObjToControl )&#x0D;&#x0A;&#x09;self.select   = AKSelectable.select&#x0D;&#x0A;&#x09;self.deselect = AKSelectable.deselect&#x0D;&#x0A;&#x09;self.lock     = AKSelectable.lock&#x0D;&#x0A;&#x09;self.unlock   = AKSelectable.unlock&#x0D;&#x0A;&#x09;inObjToControl.select    = AKSelectable.proxySelect&#x0D;&#x0A;&#x09;inObjToControl.deselect  = AKSelectable.proxyDeselect&#x0D;&#x0A;&#x09;inObjToControl.lock      = AKSelectable.proxyLock&#x0D;&#x0A;&#x09;inObjToControl.unlock    = AKSelectable.proxyUnlock&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Use self:_makeSelectable( ) on a behavior to make&#x0D;&#x0A;-- it control selection for a parent object, firing events on itself.&#x0D;&#x0A;function Node:_makeSelectable( inObjToControl )&#x0D;&#x0A;&#x09;--Exchange references, for coupled communication&#x0D;&#x0A;&#x09;inObjToControl._selectableBehavior = self&#x0D;&#x0A;&#x09;self._select_controlledObject = inObjToControl&#x0D;&#x0A;&#x0D;&#x0A;&#x09;--Add methods&#x0D;&#x0A;&#x09;self.select   = AKSelectable.select&#x0D;&#x0A;&#x09;self.deselect = AKSelectable.deselect&#x0D;&#x0A;&#x09;self.lock     = AKSelectable.lock&#x0D;&#x0A;&#x09;self.unlock   = AKSelectable.unlock&#x0D;&#x0A;&#x09;inObjToControl.select    = AKSelectable.proxySelect&#x0D;&#x0A;&#x09;inObjToControl.deselect  = AKSelectable.proxyDeselect&#x0D;&#x0A;&#x09;inObjToControl.lock      = AKSelectable.proxyLock&#x0D;&#x0A;&#x09;inObjToControl.unlock    = AKSelectable.proxyUnlock&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKSelectable:select( )&#x0D;&#x0A;&#x09;-- Allow selection even if already selected,&#x0D;&#x0A;&#x09;-- for multiple &apos;presses&apos; of the same button&#x0D;&#x0A;&#x09;if not self.lockedFlag then&#x0D;&#x0A;&#x09;&#x09;self:fireEvent( Event:new( &quot;onSelect&quot; ) )&#x0D;&#x0A;&#x09;&#x09;self.selectedFlag = true&#x0D;&#x0A;&#x09;&#x09;if self._select_controlledObject then&#x0D;&#x0A;&#x09;&#x09;&#x09;self._select_controlledObject.selectedFlag = true&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKSelectable:deselect( )&#x0D;&#x0A;&#x09;if self.selectedFlag and not self.lockedFlag then&#x0D;&#x0A;&#x09;&#x09;self:fireEvent( Event:new( &quot;onDeselect&quot; ) )&#x0D;&#x0A;&#x09;&#x09;self.selectedFlag = false&#x0D;&#x0A;&#x09;&#x09;if self._select_controlledObject then&#x0D;&#x0A;&#x09;&#x09;&#x09;self._select_controlledObject.selectedFlag = false&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKSelectable:lock( )&#x0D;&#x0A;&#x09;if not self.lockedFlag then&#x0D;&#x0A;&#x09;&#x09;self:fireEvent( Event:new( &quot;onLock&quot; ) )&#x0D;&#x0A;&#x09;&#x09;self.lockedFlag = true&#x0D;&#x0A;&#x09;&#x09;if self._select_controlledObject then&#x0D;&#x0A;&#x09;&#x09;&#x09;self._select_controlledObject.lockedFlag = true&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKSelectable:unlock( )&#x0D;&#x0A;&#x09;-- Explicitly check for false to allow initial unlocking&#x0D;&#x0A;&#x09;if self.lockedFlag ~= false then&#x0D;&#x0A;&#x09;&#x09;self:fireEvent( Event:new( &quot;onUnlock&quot; ) )&#x0D;&#x0A;&#x09;&#x09;self.lockedFlag = false&#x0D;&#x0A;&#x09;&#x09;if self._select_controlledObject then&#x0D;&#x0A;&#x09;&#x09;&#x09;self._select_controlledObject.lockedFlag = false&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKSelectable:proxySelect( )&#x0D;&#x0A;&#x09;self._selectableBehavior:select( )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKSelectable:proxyDeselect( )&#x0D;&#x0A;&#x09;self._selectableBehavior:deselect( )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKSelectable:proxyLock( )&#x0D;&#x0A;&#x09;self._selectableBehavior:lock( )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKSelectable:proxyUnlock( )&#x0D;&#x0A;&#x09;self._selectableBehavior:unlock( )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** Object Reference Lookup v1.1 ************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;]]&#x0D;&#x0A;&#x0D;&#x0A;-- Resolve a root-level DOM path like &quot;Scene.Layer.Group.Button&quot;&#x0D;&#x0A;-- or relative path like &quot;this.parent.SiblingName&quot;&#x0D;&#x0A;function Node:getObjectByPath( inPath )&#x0D;&#x0A;&#x09;--ak.output( &quot;Finding object using &apos;&quot; .. inPath .. &quot;&apos;, starting on &quot; .. self:tostring() )&#x0D;&#x0A;&#x09;if not self._objRefHash then self._objRefHash = {} end&#x0D;&#x0A;&#x09;local theNode = self._objRefHash[ inPath ]&#x0D;&#x0A;&#x09;if not theNode then&#x0D;&#x0A;&#x09;&#x09;theNode = self&#x0D;&#x0A;&#x09;&#x09;local theHackedPath = string.gsub( inPath, &apos;\\.&apos;, &apos;zzzDOTzzz&apos; )&#x0D;&#x0A;&#x09;&#x09;for theName in string.gfind( theHackedPath, &apos;[^.]+&apos; ) do&#x0D;&#x0A;&#x09;&#x09;&#x09;theName = string.gsub( theName, &apos;zzzDOTzzz&apos;, &apos;.&apos; )&#x0D;&#x0A;&#x09;&#x09;&#x09;--ak.output( &quot;... looking for &quot; .. theName .. &quot; on &quot; .. theNode:tostring() )&#x0D;&#x0A;&#x09;&#x09;&#x09;if ( theName == &apos;Scene&apos; or theName == &apos;scene&apos; ) and theNode == self then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theNode = Presentation.scene&#x0D;&#x0A;&#x09;&#x09;&#x09;elseif theName == &apos;parent&apos; then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theNode = theNode.parent&#x0D;&#x0A;&#x09;&#x09;&#x09;elseif theName ~= &apos;this&apos; then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theNode = theNode:getChildWithValue( &apos;name&apos;, theName ) or theNode[ theName ]&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;if not theNode then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;return nil&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;self._objRefHash[ inPath ] = theNode&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;return theNode&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Resolve a path objref property&#x0D;&#x0A;function Node:getObjectReference( inObjRefPropertyName )&#x0D;&#x0A;&#x09;local thePath = self[ inObjRefPropertyName ]&#x0D;&#x0A;&#x09;if not thePath then return end&#x0D;&#x0A;&#x09;return self:getObjectByPath( thePath )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Returns two values, an object reference and property name&#x0D;&#x0A;if not Node.getPropertyReference then&#x0D;&#x0A;&#x09;function Node:getPropertyReference( inObjRefPropertyName, inStartAtObj )&#x0D;&#x0A;&#x09;&#x09;if not inStartAtObj then inStartAtObj = self end&#x0D;&#x0A;&#x09;&#x09;local thePath = self[ inObjRefPropertyName ]&#x0D;&#x0A;&#x09;&#x09;if not thePath then return end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;&#x09;local theObj, theProp = inStartAtObj, thePath&#x0D;&#x0A;&#x09;&#x09;string.gsub( thePath, &apos;^(.+)%.([^.]+)$&apos;, function(s1,s2)&#x0D;&#x0A;&#x09;&#x09;&#x09;theObj = inStartAtObj:getObjectByPath( s1 )&#x0D;&#x0A;&#x09;&#x09;&#x09;theProp = s2&#x0D;&#x0A;&#x09;&#x09;end )&#x0D;&#x0A;&#x09;&#x09;if theObj then&#x0D;&#x0A;&#x09;&#x09;&#x09;return theObj, theProp&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;-- Ensure that the picked object is of a specific type&#x0D;&#x0A;function Node:getObjectReferenceWithType( inObjRefPropertyName, inType )&#x0D;&#x0A;&#x09;local theObject = self:getObjectReference( inObjRefPropertyName )&#x0D;&#x0A;&#x09;if theObject and theObject.type == inType then&#x0D;&#x0A;&#x09;&#x09;return theObject&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** EVENT QUEUE v1.0 ************************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;Events fired through the queue will be limited to fire one per frame.&#x0D;&#x0A;]]&#x0D;&#x0A;function Node:fireQueuedEvent( inEvent )&#x0D;&#x0A;&#x09;if not self._eventqueue then&#x0D;&#x0A;&#x09;&#x09;self._eventqueue = { }&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;table.insert( self._eventqueue, inEvent )&#x0D;&#x0A;&#x09;self:registerForEvent( -1, &apos;onUpdate&apos;, self._eventqueue_checkQueue )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function Node:_eventqueue_checkQueue( )&#x0D;&#x0A;&#x09;local theEvent = table.remove( self._eventqueue, 1 )&#x0D;&#x0A;&#x09;if theEvent then&#x0D;&#x0A;&#x09;&#x09;self:fireEvent( theEvent )&#x0D;&#x0A;&#x09;else&#x0D;&#x0A;&#x09;&#x09;self:unregisterForEvent( -1, &apos;onUpdate&apos;, self._eventqueue_checkQueue )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** DIMENSIONED ITEMS v1.1 ******************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;Items tracked have &apos;dimensions&apos; and &apos;centerOffset&apos; properties added and&#x0D;&#x0A;kept updated.&#x0D;&#x0A;&#x0D;&#x0A;Use either of the following to cause a node&apos;s dimensions to be tracked:&#x0D;&#x0A;   AKDimensionTracker:trackDimensions( theNode )&#x0D;&#x0A;   or&#x0D;&#x0A;   theNode:trackDimensions( )&#x0D;&#x0A;   &#x0D;&#x0A;To prevent the above from needlessly recalculating the size of a static node:&#x0D;&#x0A;   AKDimensionTracker:useDimensions( theNode, 10, 20, 30 )&#x0D;&#x0A;   or&#x0D;&#x0A;   theNode:useDimensions( 10, 20, 30 )&#x0D;&#x0A;&#x0D;&#x0A;Whenever the dimensions change, a &apos;dimensionChange&apos; property is set.&#x0D;&#x0A;Use the following to run code only when a node&apos;s dimensions change.&#x0D;&#x0A;   self:registerForChange( dimensionedNode, &apos;dimensionChange&apos;, self.callback )&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;Whenever the dimensions change, a &apos;centerOffsetChange&apos; property is set.&#x0D;&#x0A;Use the following to run code only when a node&apos;s center offset changes.&#x0D;&#x0A;   self:registerForChange( dimensionedNode, &apos;centerOffsetChange&apos;, self.callback )&#x0D;&#x0A;]]&#x0D;&#x0A;&#x0D;&#x0A;AKDimensionTracker = { items = { }, tmpMin = tmpV1, tmpMax = tmpV2, tmpOffset = tmpV3 }&#x0D;&#x0A;&#x0D;&#x0A;function Node:useDimensions( ... )&#x0D;&#x0A;&#x09;AKDimensionTracker:useDimensions( self, unpack( arg ) )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function Node:trackDimensions( )&#x0D;&#x0A;&#x09;AKDimensionTracker:trackDimensions( self )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function Node:stopTrackingDimensions( )&#x0D;&#x0A;&#x09;AKDimensionTracker:stopTrackingDimensions( self )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKDimensionTracker:useDimensions( inNode, inWidth, inHeight, inDepth )&#x0D;&#x0A;&#x09;if not inNode.dimensions then&#x0D;&#x0A;&#x09;&#x09;inNode.dimensions   = Vector:new( )&#x0D;&#x0A;&#x09;&#x09;inNode.centerOffset = Vector:new( )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;inNode.dimensions:set( inWidth or 0, inHeight or 0, inDepth or 0 )&#x0D;&#x0A;&#x09;inNode.centerOffset:set( ( inWidth or 0 ) / 2, ( inHeight or 0 ) / 2, ( inDepth or 0 ) / 2 )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;-- Prevent this item from ever dynamically updating again&#x0D;&#x0A;&#x09;inNode.staticDimensionsFlag = true&#x0D;&#x0A;&#x09;self:stopTrackingDimensions( inNode )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKDimensionTracker:trackDimensions( inNode )&#x0D;&#x0A;&#x09;if inNode.staticDimensionsFlag then&#x0D;&#x0A;&#x09;&#x09;return&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;if not inNode.dimensions then&#x0D;&#x0A;&#x09;&#x09;inNode.dimensions   = Vector:new( )&#x0D;&#x0A;&#x09;&#x09;inNode.centerOffset = Vector:new( )&#x0D;&#x0A;&#x09;&#x09;&#x0D;&#x0A;&#x09;&#x09;-- Initialize the values with the current dimensions&#x0D;&#x0A;&#x09;&#x09;inNode:calcBBox( self.tmpMin, inNode.dimensions )&#x0D;&#x0A;&#x09;&#x09;inNode.dimensions:subtract( self.tmpMin )&#x0D;&#x0A;&#x09;&#x09;inNode.centerOffset:setVector( inNode.position )&#x0D;&#x0A;&#x09;&#x09;inNode.centerOffset:subtract( self.tmpMin )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;self.items[ inNode ] = 1&#x0D;&#x0A;&#x0D;&#x0A;&#x09;-- Single onUpdate rather than per-node for speed&#x0D;&#x0A;&#x09;if not self.runningFlag then&#x0D;&#x0A;&#x09;&#x09;self.runningFlag = true&#x0D;&#x0A;&#x09;&#x09;Presentation.scene:registerForEvent( -1, &apos;onUpdate&apos;, self.updateDimensions )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKDimensionTracker:stopTrackingDimensions( inNode )&#x0D;&#x0A;&#x09;if self.items[ inNode ] then&#x0D;&#x0A;&#x09;&#x09;self.items[ inNode ] = nil&#x0D;&#x0A;&#x0D;&#x0A;&#x09;&#x09;-- Stop calling the function every frame if no nodes are being tracked&#x0D;&#x0A;&#x09;&#x09;if self.runningFlag and not next( self.items ) then&#x0D;&#x0A;&#x09;&#x09;&#x09;self.runningFlag = false&#x0D;&#x0A;&#x09;&#x09;&#x09;Presentation.scene:unregisterForEvent( -1, &apos;onUpdate&apos;, self.updateDimensions )&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKDimensionTracker.updateDimensions( )&#x0D;&#x0A;&#x09;self = AKDimensionTracker&#x0D;&#x0A;&#x0D;&#x0A;&#x09;for theNode,_ in pairs( self.items ) do&#x0D;&#x0A;&#x09;&#x09;if theNode.globalactive then&#x0D;&#x0A;&#x09;&#x09;&#x09;theNode:calcBBox( self.tmpMin, self.tmpMax )&#x0D;&#x0A;&#x09;&#x09;&#x09;self.tmpOffset:setVector( theNode.position )&#x0D;&#x0A;&#x09;&#x09;&#x09;self.tmpOffset:subtract( self.tmpMin )&#x0D;&#x0A;&#x09;&#x09;&#x09;if self.tmpOffset ~= theNode.centerOffset then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theNode.centerOffset:setVector( self.tmpOffset )&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theNode.centerOffsetChange = 1&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;self.tmpMax:subtract( self.tmpMin )&#x0D;&#x0A;&#x09;&#x09;&#x09;if self.tmpMax ~= theNode.dimensions then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theNode.dimensions:setVector( self.tmpMax )&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theNode.dimensionChange = 1&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** Go To Slide v1.1 ************************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;Cause a Component/Scene to go to a slide based on number.&#x0D;&#x0A;If the node is not a component or scene, the owning component/scene is used.&#x0D;&#x0A;]]&#x0D;&#x0A;function Node:goToSlide( inSlideNumber )&#x0D;&#x0A;&#x09;-- Find the owning component/scene&#x0D;&#x0A;&#x09;while not self.timeindependent or self.type == &apos;layer&apos; do&#x0D;&#x0A;&#x09;&#x09;-- TODO: remove layer type check once bug #423 is fixed&#x0D;&#x0A;&#x09;&#x09;-- (layers incorrectly show up as timeindependent)&#x0D;&#x0A;&#x09;&#x09;self = self.parent&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;-- reset to the master slide first, to use common values&#x0D;&#x0A;&#x09;local theResetEvent = Event:new( &apos;set&apos; )&#x0D;&#x0A;&#x09;theResetEvent.param1 = &apos;slide&apos;&#x0D;&#x0A;&#x09;theResetEvent:setAsType( &apos;param2&apos;, 0, &apos;long&apos; )&#x0D;&#x0A;&#x09;self:fireEvent( theResetEvent )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;-- create a new event each time in case multiple slide changes&#x0D;&#x0A;&#x09;-- occur in the same frame (ensure distinct slide numbers)&#x0D;&#x0A;&#x09;local theSlideEvent = Event:new( &apos;set&apos; )&#x0D;&#x0A;&#x09;theSlideEvent.param1 = &apos;slide&apos;&#x0D;&#x0A;&#x09;theSlideEvent:setAsType( &apos;param2&apos;, inSlideNumber, &apos;long&apos; )&#x0D;&#x0A;&#x09;self:fireEvent( theSlideEvent )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** Tab CSV to 2D Array v1.0 ****************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;Turns a grid of tab- and newline-delimited data into an array of row arrays.&#x0D;&#x0A;Pass in a table to be modified (and returned) or a new one will be created.&#x0D;&#x0A;]]&#x0D;&#x0A;function string:tabCSVToGrid( inGridTable )&#x0D;&#x0A;&#x09;if not inGridTable then&#x0D;&#x0A;&#x09;&#x09;inGridTable = {}&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;for theLineText in string.gfind( self, &apos;[^\r\n]+&apos; ) do&#x0D;&#x0A;&#x09;&#x09;local theRow = {}&#x0D;&#x0A;&#x09;&#x09;table.insert( inGridTable, theRow )&#x0D;&#x0A;&#x0D;&#x0A;&#x09;&#x09;for theCell in string.gfind( theLineText, &apos;([^\t]*)\t&apos; ) do&#x0D;&#x0A;&#x09;&#x09;&#x09;theAddedCellsFlag = true&#x0D;&#x0A;&#x09;&#x09;&#x09;table.insert( theRow, theCell )&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;&#x09;-- Add the last cell in the row, which the above pattern above missed&#x0D;&#x0A;&#x09;&#x09;table.insert( theRow, string.sub( theLineText, string.find( theLineText, &quot;[^\t]*$&quot; ) ) )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;return inGridTable&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** string.split() v1.0 *********************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;Splits a string based on a separator string or pattern;&#x0D;&#x0A;returns an array of pieces of the string.&#x0D;&#x0A;]]&#x0D;&#x0A;function string:split( inSplitPattern )&#x0D;&#x0A;&#x09;local theResults = { }&#x0D;&#x0A;&#x09;local theStart = 1&#x0D;&#x0A;&#x09;local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )&#x0D;&#x0A;&#x09;while theSplitStart do&#x0D;&#x0A;&#x09;&#x09;table.insert( theResults, string.sub( self, theStart, theSplitStart-1 ) )&#x0D;&#x0A;&#x09;&#x09;theStart = theSplitEnd + 1&#x0D;&#x0A;&#x09;&#x09;theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;table.insert( theResults, string.sub( self, theStart ) )&#x0D;&#x0A;&#x09;return theResults&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** Clone Node v1.2 *************************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;Create a copy of the node, attached to the same parent as the original.&#x0D;&#x0A;The copy inherits (class graph) from the original, making it a light copy.&#x0D;&#x0A;&#x0D;&#x0A;If inDeepFlag is true, creates copies of the descendant hierarchy as well.&#x0D;&#x0A;]]&#x0D;&#x0A;function Node:clone( inDeepFlag, inParent )&#x0D;&#x0A;&#x09;local theCopy = ak.createElement( self.type )&#x0D;&#x0A;&#x09;akscenegraph.attach( inParent or self.parent, theCopy )&#x0D;&#x0A;&#x09;akclassgraph.attach( self, theCopy )&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;-- Touch the transform values to ensure this object has its own&#x0D;&#x0A;&#x09;if theCopy.position then&#x0D;&#x0A;&#x09;&#x09;theCopy.position:setVector( self.position )&#x0D;&#x0A;&#x09;&#x09;theCopy.rotation:setRotation( self.rotation )&#x0D;&#x0A;&#x09;&#x09;theCopy.scale:setVector( self.scale )&#x0D;&#x0A;&#x09;&#x09;theCopy.pivot:setVector( self.pivot )&#x0D;&#x0A;&#x09;&#x09;theCopy.positionVelocity:setVector( self.positionVelocity   )&#x0D;&#x0A;&#x09;&#x09;theCopy.rotationVelocity:setRotation( self.rotationVelocity )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;if inDeepFlag then&#x0D;&#x0A;&#x09;&#x09;local theChild&#x0D;&#x0A;&#x09;&#x09;for i,theType in ipairs( self:getChildValuesFor( &apos;type&apos;, { } ) ) do&#x0D;&#x0A;&#x09;&#x09;&#x09;theChild = self:getChildByIndex( i )&#x0D;&#x0A;&#x09;&#x09;&#x09;-- Some children (like logic elements) aren&apos;t nodes&#x0D;&#x0A;&#x09;&#x09;&#x09;if theChild.clone then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theChild:clone( true, theCopy )&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;return theCopy&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** onActivate Spoof v1.0.1 *****************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;Causes a node to fire an &apos;onActivate&apos; event when it becomes active after having&#x0D;&#x0A;been inactive for at least one frame.&#x0D;&#x0A;]]&#x0D;&#x0A;AKActiveWatcher = { lastActiveFrame={}, evt=Event:new( &apos;onActivate&apos; ), frameCount=0 }&#x0D;&#x0A;&#x0D;&#x0A;function AKActiveWatcher:watchNode( inNode )&#x0D;&#x0A;&#x09;self.lastActiveFrame[ inNode ] = -1&#x0D;&#x0A;&#x09;&#x0D;&#x0A;&#x09;if not self.runningFlag then&#x0D;&#x0A;&#x09;&#x09;self.runningFlag = true&#x0D;&#x0A;&#x09;&#x09;Presentation.scene:registerForEvent( -1, &apos;onUpdate&apos;, self.checkAll )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKActiveWatcher:stopWatchingNode( inNode )&#x0D;&#x0A;&#x09;self.lastActiveFrame[ inNode ] = nil&#x0D;&#x0A;&#x0D;&#x0A;&#x09;if self.runningFlag and not next( self.lastActiveFrame ) then&#x0D;&#x0A;&#x09;&#x09;self.runningFlag = false&#x0D;&#x0A;&#x09;&#x09;Presentation.scene:unregisterForEvent( -1, &apos;onUpdate&apos;, self.checkAll )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function AKActiveWatcher.checkAll( )&#x0D;&#x0A;&#x09;self = AKActiveWatcher&#x0D;&#x0A;&#x09;local theLastFrame = self.frameCount&#x0D;&#x0A;&#x09;self.frameCount = self.frameCount + 1&#x0D;&#x0A;&#x09;for theNode, theFrame in pairs( self.lastActiveFrame ) do&#x0D;&#x0A;&#x09;&#x09;if theNode.globalactive then&#x0D;&#x0A;&#x09;&#x09;&#x09;if theFrame &lt; theLastFrame then&#x0D;&#x0A;&#x09;&#x09;&#x09;&#x09;theNode:fireEvent( self.evt )&#x0D;&#x0A;&#x09;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;&#x09;self.lastActiveFrame[ theNode ] = self.frameCount&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function Node:watchActive( )&#x0D;&#x0A;&#x09;AKActiveWatcher:watchNode( self )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function Node:stopWatchingActive( )&#x0D;&#x0A;&#x09;AKActiveWatcher:stopWatchingNode( self )&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;*** MISC FUNCTIONS **************************************************************&#x0D;&#x0A;*********************************************************************************&#x0D;&#x0A;]]&#x0D;&#x0A;&#x0D;&#x0A;-- Returns true if an odd number of truth values are passed, false otherwise&#x0D;&#x0A;function nxor( ... )&#x0D;&#x0A;&#x09;local theSum = 0&#x0D;&#x0A;&#x09;for _,theValue in ipairs( arg ) do&#x0D;&#x0A;&#x09;&#x09;theSum = theSum + (theValue and 1 or 0)&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;return math.mod( theSum, 2 ) == 1&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;function table:append( ... )&#x0D;&#x0A;&#x09;local s = table.getn( self )&#x0D;&#x0A;&#x09;for i,v in ipairs( arg ) do&#x0D;&#x0A;&#x09;&#x09;if type(v) == &apos;table&apos; then&#x0D;&#x0A;&#x09;&#x09;&#x09;table.append( self, unpack(v) )&#x0D;&#x0A;&#x09;&#x09;else&#x0D;&#x0A;&#x09;&#x09;&#x09;table.insert( self, v )&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x09;return self&#x0D;&#x0A;end&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;&#x09;-- Echo all output to a file on disk&#x0D;&#x0A;&#x09;ak._out = ak.output&#x0D;&#x0A;&#x09;function ak.output( ... )&#x0D;&#x0A;&#x09;&#x09;ak._out( unpack( arg ) )&#x0D;&#x0A;&#x09;&#x09;if not g_errIO then g_errIO = io.open( &quot;c:\QBoutput.txt&quot;, &quot;w+&quot; ) end&#x0D;&#x0A;&#x09;&#x09;for _,v in ipairs( arg ) do&#x0D;&#x0A;&#x09;&#x09;&#x09;g_errIO:write( tostring( v ), &apos;\t&apos; )&#x0D;&#x0A;&#x09;&#x09;end&#x0D;&#x0A;&#x09;&#x09;g_errIO:write( &apos;\r\n&apos; )&#x0D;&#x0A;&#x09;&#x09;g_errIO:flush( )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;--]]&#x0D;&#x0A;&#x0D;&#x0A;--[[&#x0D;&#x0A;&#x09;function Vector:tostring( )&#x0D;&#x0A;&#x09;&#x09;return string.format( &quot;&lt;%8.3f, %8.3f, %8.3f&gt;&quot;, self.x, self.y, self.z )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;&#x0D;&#x0A;&#x09;function Text:tostring( )&#x0D;&#x0A;&#x09;&#x09;return string.format( &quot;&lt;Text &apos;%s&apos; (%d)&gt;&quot;, self.textString, self.id )&#x0D;&#x0A;&#x09;end&#x0D;&#x0A;--]]&#x0D;&#x0A;&#x0D;&#x0A;' scriptname="Anark Lua Library" scriptversion="1" />
    </library>
    <logic>
        <expression>
            <trigger name="reset" xmlref="1" />
            <result name="set" xmlref="1" param1="slide" param2="long:0" />
            <result name="set" xmlref="1" param1="slide" param2="long:1" />
        </expression>
        <expression>
            <trigger name="set" xmlref="1" param1="slide" param2="long:0" />
            <result name="set" xmlref="3" param1="active" param2="bool:false" />
            <result name="set" xmlref="5" param1="duration" param2="long:10300" />
            <result name="set" xmlref="20" param1="active" param2="bool:false" />
            <result name="set" xmlref="18" param1="active" param2="bool:false" />
            <result name="set" xmlref="15" param1="active" param2="bool:false" />
            <result name="set" xmlref="1" param1="initialplaystate" param2="long:0" />
            <result name="set" xmlref="1" param1="playmode" param2="long:1" />
            <result name="set" xmlref="1" param1="looptime" param2="long:10300" />
        </expression>
        <expression>
            <trigger name="set" xmlref="1" param1="slide" param2="long:1" />
            <result name="set" xmlref="3" param1="active" param2="bool:true" />
            <result name="set" xmlref="5" param1="duration" param2="long:10000" />
            <result name="set" xmlref="20" param1="active" param2="bool:true" />
            <result name="set" xmlref="18" param1="active" param2="bool:true" />
            <result name="set" xmlref="15" param1="active" param2="bool:true" />
            <result name="set" xmlref="1" param1="initialplaystate" param2="long:1" />
            <result name="set" xmlref="1" param1="playmode" param2="long:0" />
            <result name="set" xmlref="1" param1="looptime" param2="long:10000" />
        </expression>
    </logic>
    <events>
        <event xmlid="26" name="onUp" formalname="" category="Navigation" helpstring="A logical event to move &apos;up&apos;." />
        <event xmlid="27" name="onDown" formalname="" category="Navigation" helpstring="A logical event to move &apos;down&apos;." />
        <event xmlid="28" name="onLeft" formalname="" category="Navigation" helpstring="A logical event to move &apos;left&apos;." />
        <event xmlid="29" name="onRight" formalname="" category="Navigation" helpstring="A logical event to move &apos;right&apos;." />
        <event xmlid="30" name="onSelect" formalname="" category="Actions" helpstring="A logical event to select something." />
        <event xmlid="31" name="onBack" formalname="" category="Actions" helpstring="A logical event to go back." />
    </events>
</presentation>
