There's no command to return the total number of entities, as far as I know. You need to use a global variable as a counter and update it as you create or delete them, if you want to do this.
The best way (in my opinion at least) to identify what an entity is, is to store that information in a Blitz Type structure and use the undocumented command, 'Handle()' along with the 'NameEntity' command to store a pointer to that Type element in the entity's namestring. Use the undocumented command, 'Object()', along with the 'EntityName$()' command to retrieve the Type pointer. The advantage of this is that you can store a lot of additional information in the entity's Type element. If you only need to store a small amount of info then you can store it directly in the entity's namestring, of course.
eg.
Type ENTITY_DATA_STRUCT
Field entity_name$
Field entity_type_id
Field entity_class_id
End Type
Global entity_data.ENTITY_DATA_STRUCT = New ENTITY_DATA_STRUCT
Global entity_handle = CreatePivot () ; Create a bare entity.
; Store Type pointer in entity's namestring.
NameEntity entity_handle, Handle ( entity_data )
; Retrieve Type pointer from entity's namestring. Note that the 'Object' command needs to be followed by the identifier of the Type structure to be output, with a dot as a separator.
entity_data = Object.ENTITY_DATA_STRUCT( EntityName$ ( entity_handle ) )
The best way (in my opinion at least) to identify what an entity is, is to store that information in a Blitz Type structure and use the undocumented command, 'Handle()' along with the 'NameEntity' command to store a pointer to that Type element in the entity's namestring. Use the undocumented command, 'Object()', along with the 'EntityName$()' command to retrieve the Type pointer. The advantage of this is that you can store a lot of additional information in the entity's Type element. If you only need to store a small amount of info then you can store it directly in the entity's namestring, of course.
eg.
Type ENTITY_DATA_STRUCT
Field entity_name$
Field entity_type_id
Field entity_class_id
End Type
Global entity_data.ENTITY_DATA_STRUCT = New ENTITY_DATA_STRUCT
Global entity_handle = CreatePivot () ; Create a bare entity.
; Store Type pointer in entity's namestring.
NameEntity entity_handle, Handle ( entity_data )
; Retrieve Type pointer from entity's namestring. Note that the 'Object' command needs to be followed by the identifier of the Type structure to be output, with a dot as a separator.
entity_data = Object.ENTITY_DATA_STRUCT( EntityName$ ( entity_handle ) )