game.addResource

Adds resources (HUDs, additional AIModels, etc.) to the game's resources tab.

Prototype

  1. bOk = game.addResource ( hGame, hFile|(kResourceType, sResourceName) )

Description

The function takes either a combination of resourceType and resourceName, or alternatively a file handle whose type and proper resource name will be determined by ShiVa.
Please check the resource constants for more info.


Parameters

hGame - valid Game handle
hFile - valid file handle OR...
(kResourceType, sResourceName) - pair of predefined type like resource.kTypeXML constant AND resource name string


Return values

bOk - true on success


Sample

  1. function onPropertyViewSectionResourcesProcessDrop ( hView, hGame, hComponent, nPointX, nPointY, tFiles )
  2.  
  3. -- Accept drop if at least one file is matching
  4. local sComponentID = gui.getComponentIdentifier ( hComponent )
  5. local bAtLeastOneFileProcessed = false
  6.  
  7. for i = 1, #tFiles do
  8. -- trick here: positive file types are resources :)
  9. if ( ( sComponentID == "section.resources.tree" ) and ( project.getFileType ( tFiles[i] ) > 0 ) ) then
  10. game.addResource ( hGame, project.getFileType ( tFiles[i] ), project.getFileName ( tFiles[i] ) )
  11. bAtLeastOneFileProcessed = true
  12. end
  13. end
  14. return bAtLeastOneFileProcessed
  15. end

Available since ShiVa 2.0