Blitz3D+ Command Reference

WorldEditorSessionHierarchyRevision:Long ( session )

Parameters

session - World Editor session handle

Description

Returns the newest observed hierarchy revision of the session's world.

Polling also services the session transport. The hierarchy revision advances when the target world's entity structure changes - entities created, deleted or reparented - so a hierarchy panel can refresh only when structure actually changed, while WorldEditorSessionRevision tracks every live-world mutation.

Handles are context-owned and reject stale or wrong-kind values.

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

Requires Extended mode.

See also: WorldEditorSessionRevision, PollWorldEditorEvent, WorldEditorSessionState.

Example

; OpenWorldEditorSession Example - launch this Extended program from DebugWorld.
Const EVENT_GADGET_ACTION=$401
Const EVENT_WINDOW_CLOSE=$803

Function SessionArgument$()
    command$=CommandLine$():position=Instr(Lower(command),"--session")
    If position=0 Then Return ""
    position=position+9
    While position<=Len(command) And Mid(command,position,1)=" ":position=position+1:Wend
    If Mid(command,position,1)=Chr(34) Then
        finish=Instr(command,Chr(34),position+1)
        Return Mid(command,position+1,finish-position-1)
    EndIf
    Return Mid(command,position)
End Function

descriptor$=SessionArgument()
If descriptor="" Then RuntimeError "This custom editor must be launched by DebugWorld"
session=OpenWorldEditorSession(descriptor)
If session=0 Then RuntimeError WorldEditorSessionError()

window=CreateWindow("Custom World Editor",100,100,800,520,0,15)
canvas=CreateCanvas(0,38,ClientWidth(window),ClientHeight(window)-38,window)
SetGadgetLayout canvas,1,1,1,1
pauseButton=CreateButton("Pause",8,6,90,27,window)
continueButton=CreateButton("Continue",106,6,90,27,window)
projectionButton=CreateButton("Orthographic",204,6,120,27,window)
view=CreateWorldEditorView(session,canvas)
SetWorldEditorViewCamera view,0,3,-8,.2,0,5
projection=1
SetWorldEditorViewProjection view,projection,24,True
running=True:request=0
While running
    event=WaitEvent(16)
    If event=EVENT_WINDOW_CLOSE Then running=False
    If event=EVENT_GADGET_ACTION And EventSource()=projectionButton Then
        projection=3-projection
        SetWorldEditorViewProjection view,projection,24,True
        If projection=1 Then SetGadgetText projectionButton,"Orthographic" Else SetGadgetText projectionButton,"Perspective"
    EndIf
    If event=EVENT_GADGET_ACTION And request=0 Then
        payload=CreateJsonObject()
        If EventSource()=pauseButton Then request=SendWorldEditorRequest(session,"pause",payload)
        If EventSource()=continueButton Then request=SendWorldEditorRequest(session,"continue",payload)
        FreeJson payload
    EndIf
    If request<>0 And WorldEditorRequestState(request)>=WORLD_EDITOR_REQUEST_SUCCEEDED Then
        FreeWorldEditorRequest request:request=0
    EndIf
    state=WorldEditorSessionState(session)
    If state=WORLD_EDITOR_SESSION_CLOSED Or state=WORLD_EDITOR_SESSION_FAILED Then running=False
    RenderWorldEditorView view
Wend
If request<>0 Then CancelWorldEditorRequest request:FreeWorldEditorRequest request
FreeWorldEditorView view
CloseWorldEditorSession session
FreeGadget window
End

Index