; FindWorldAsset 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 ; (the path is relative to this example's directory) 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 ; FindWorldAsset resolves a stable authored ID to an asset handle; ; an ID that is not in the manifest returns 0 texture_asset=FindWorldAsset(manifest,"display-texture") missing_asset=FindWorldAsset(manifest,"no-such-id") ; Put the found asset to work: texture a spinning crate 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,"FindWorldAsset(manifest,'display-texture') = "+texture_asset Text 0,40,"FindWorldAsset(manifest,'no-such-id') = "+missing_asset+" (absent IDs return 0)" Flip Wend FreeTexture tex FreeWorld manifest End