NameEntity entity,name$
Parameters
|
entity - entity handle name$ - name to give the entity |
Description
|
Sets an entity's name. The name can be read back with EntityName and searched for with FindChild. Names don't have to be unique - FindChild simply returns the first match. Naming entities is a handy debugging aid too: label your important entities when you create them, and anything your code gets back from a pick or collision can identify itself. See also: EntityName, FindChild. |
Example
; NameEntity Example ; ------------------ Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,0,-5 light=CreateLight() RotateEntity light,45,45,0 ; A mystery crate whose name we will change at runtime crate=CreateCube() EntityColor crate,0,200,255 Dim names$(3) names$(1)="health pack" names$(2)="ammo box" names$(3)="gold crate" index=1 ; Give the crate its first name NameEntity crate,names$(index) While Not KeyDown(1) ; Space renames the crate with the next name in the list If KeyHit(57) index=index+1 If index>3 Then index=1 NameEntity crate,names$(index) EndIf 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,"Space: rename the crate Arrow keys: move camera Esc: exit" ; EntityName reads back the name set by NameEntity Text 0,20,"NameEntity crate,"+Chr$(34)+names$(index)+Chr$(34) Text 0,40,"EntityName(crate) = "+EntityName(crate) Flip Wend End
Index