EntityName$ ( entity )

Parameters

entity - entity handle

Description

Returns the name of an entity.

An entity's name may be set in a modelling program (it is loaded along with the model), or set manually using NameEntity. Names are how you tell the parts of a loaded model apart - find a specific part with FindChild, or print names while walking a hierarchy with GetChild to see how a model is put together.

An entity that has never been named returns an empty string.

See also: NameEntity, FindChild, GetChild.

Example

; EntityName Example
; ------------------

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

camera=CreateCamera()
PositionEntity camera,0,0,-6

light=CreateLight()
RotateEntity light,45,45,0

; Three pickup crates, each given a name with NameEntity
Dim crates(3)

For i=1 To 3
    crate=CreateCube()
    ScaleEntity crate,0.5,0.5,0.5
    PositionEntity crate,(i-2)*2.5,0,0
    crates(i)=crate
Next

NameEntity crates(1),"health pack"
NameEntity crates(2),"ammo box"
NameEntity crates(3),"gold crate"

selected=1

While Not KeyDown(1)

    ; Space selects the next crate
    If KeyHit(57)
        selected=selected+1
        If selected>3 Then selected=1
    EndIf

    ; Spin all the crates and highlight the selected one
    For i=1 To 3
        TurnEntity crates(i),0,1,0
        EntityColor crates(i),150,150,150
    Next
    EntityColor crates(selected),0,255,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,"Space: select next crate   Arrow keys: move camera   Esc: exit"
    ; EntityName returns the name given to the entity by NameEntity
    Text 0,20,"EntityName(selected crate) = "+EntityName(crates(selected))

    Flip

Wend

End

Index