WorldAssetID$ ( asset )
Parameters
| asset - an asset handle returned by FindWorldAsset |
Description
|
Returns the stable authored ID of a world asset. This is the exact ID string declared for the asset in its .world file - the same one you passed to FindWorldAsset to get the handle. It is the round trip that lets generic code carry asset handles around and still print, log, or save something human-readable: a preload progress list can show "ship-paint 40%" without keeping its own name table. IDs are stable across loads and across machines because they live in the authored source, so they are safe keys for save files and configuration. For the full story, see the Async World Loading guide. Requires Extended mode. See also: FindWorldAsset, WorldAssetKind, WorldAssetReady, WorldEntityID. |
Example
; WorldAssetID Example ; -------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-5 light=CreateLight() RotateEntity light,45,45,0 ; Load the asset manifest world in the background manifest=LoadWorldAsync("../../../samples/worlds/asset-preload.world") While Not WorldReady(manifest) If WorldLoadState(manifest)=WORLD_LOAD_FAILED Then RuntimeError WorldLoadError(manifest) Cls Text 0,0,"Loading the asset manifest..." Flip Wend ; Resolve three of the manifest's assets to opaque handles model_asset=FindWorldAsset(manifest,"display-model") texture_asset=FindWorldAsset(manifest,"display-texture") sound_asset=FindWorldAsset(manifest,"ready-sound") ; WorldAssetID$ recovers the stable authored ID from a handle model_id$=WorldAssetID(model_asset) texture_id$=WorldAssetID(texture_asset) sound_id$=WorldAssetID(sound_asset) ; A spinning crate wearing the texture asset keeps the scene alive tex=WorldAssetTexture(texture_asset) crate=CreateCube() PositionEntity crate,0,1,0 EntityTexture crate,tex While Not KeyDown(1) TurnEntity crate,0,1,0 ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Arrow keys: move camera Esc: exit" Text 0,20,"WorldAssetID$("+model_asset+") = '"+model_id+"'" Text 0,40,"WorldAssetID$("+texture_asset+") = '"+texture_id+"'" Text 0,60,"WorldAssetID$("+sound_asset+") = '"+sound_id+"'" Flip Wend FreeTexture tex FreeWorld manifest End
Index