|
world - world handle that LoadWorldAsync or LoadWorldDocumentAsync gave index - a place in the list CountWorldBehaviours made, from 0 |
|
Returns the entity whose behaviour is at index in the list that the world's last CountWorldBehaviours made, or 0 when the entity has been freed since. An index outside the list is a runtime error. See also: CountWorldBehaviours, WorldBehaviourID, WorldBehaviourKind. |
; CountWorldBehaviours Example
; ----------------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
; The coins world: coins that spin, bob and are collected, a gate, a sign and a guard
world=LoadWorldAsync("../../../samples/behaviours/coins.world")
While Not WorldReady(world)
If WorldLoadState(world)=WORLD_LOAD_FAILED Then RuntimeError WorldLoadError(world)
Cls
Text 0,0,"Loading the coins world..."
Flip
Wend
SetWorld world
camera=FindWorldEntityByName(world,"Camera")
PositionEntity camera,0,4,-6
RotateEntity camera,25,0,0
coin=FindWorldEntityByName(world,"Coin 1")
hidden=False
While Not KeyDown(1)
; Space hides the first coin, and its behaviours wait while it is hidden
If KeyHit(57) Then
hidden=Not hidden
If hidden Then HideEntity coin Else ShowEntity coin
EndIf
UpdateWorld
RenderWorld
Text 0,0,"Space: hide or show Coin 1 Esc: exit"
; Each behaviour of each object, in the order they were made
y=20
For index=0 To CountWorldBehaviours(world)-1
owner=WorldBehaviourEntity(world,index)
state$="waits"
If BehaviourRunning(owner,WorldBehaviourID(world,index)) Then state$="runs"
Text 0,y,EntityName(owner)+": "+WorldBehaviourID(world,index)+" ("+WorldBehaviourKind(world,index)+") "+state$
y=y+16
Next
Flip
Wend
FreeWorld world
End