aimodel.getFunctionScript

Get a handle to the script of a function.

Prototype

  1. hResource = aimodel.getFunctionScript ( hAIModel, sName|nIndex )

Description

Get a handle to the script of a function, either by name or by index. Useful to extract further information, like function arguments.


Parameters

hAIModel - valid AIModel handle
sName|nIndex - function name (string) or index 1..nFunctionCount


Return values

hResource - handle to the script


Sample

  1. for iIndex = 1, nFunctionsCount do
  2. local hItem = tItems[ iIndex ]
  3. if ( hItem ) then
  4. local sFunctionName = tSortedFunctions[ iIndex ]
  5. local hFunctionScript = aimodel.getFunctionScript ( hResource, sFunctionName )
  6. local tFunctionArguments = hFunctionScript and script.findFunctionArguments ( hFunctionScript ) or { }
  7. -- etc.

Available since ShiVa 2.0