LoadWorldDocumentAsync ( document[,flags] )

Parameters

document - world document handle

flags (optional) - WORLD_LOAD_DEFAULT (default), or any of WORLD_LOAD_NO_STREAMING, WORLD_LOAD_BEHAVIOURS_OFF, WORLD_LOAD_KEEP_ENTITIES, WORLD_LOAD_PLACEHOLDERS and WORLD_LOAD_STREAMING added together, as for LoadWorldAsync

Description

Starts an asynchronous runtime-world load from a document snapshot.

The load is an ordinary asynchronous world load taken from an immutable snapshot of the current document, and returns a world handle. Later edits cannot change that in-flight load.

For the full story, see the Debug World Editor guide.


See also: LoadWorldAsync, LoadWorldDocument, WorldDocumentJson.

Example

; LoadWorldDocumentAsync Example
; ------------------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

; The document is the editable source; the async load makes a runtime world
; from an immutable snapshot of it. No camera block: there is nothing to view
; in this empty document - the overlay reports the load stages instead.
document=CreateWorldDocument("preview-example","Preview Example")
If document=0 Then RuntimeError WorldDocumentError()

world=LoadWorldDocumentAsync(document,WORLD_LOAD_NO_STREAMING)

While Not KeyDown(1)

    ; Service the asynchronous load a little every frame
    UpdateAsyncLoads 1.0

    If WorldLoadState(world)=WORLD_LOAD_FAILED Then RuntimeError WorldLoadError(world)

    Cls
    Text 0,0,"Esc: exit"
    Text 0,20,"LoadWorldDocumentAsync started an ordinary async world load"
    Text 0,40,"Load state: "+WorldLoadState(world)+"   Ready: "+WorldReady(world)
    If WorldReady(world) Then Text 0,60,"Later document edits cannot change this loaded world"

    Flip

Wend

FreeWorld world
FreeWorldDocument document

End

Index