Backreferencing entities with type array
Blitz3D Forums/Blitz3D Beginners Area/Backreferencing entities with type array
| ||
I need a place to tuck an index value onto an entity so I can find it in my type array without iterating through the entire array looking for it. ANY example would be helpful. I was going to use entityradius, but have no way to getentityradius. Blast! |
| ||
Oops! Nevermind! I just renamed all my objs to have a fixed 4 digit number at the start when I iterate through everything for loading! But now I can't use findchild if I need it... :( |
| ||
You can use NameEntity and EntityName. The name is a string, but the string can hold a number. |
| ||
I wish I could simply attach other properties. The naming thing isn't working very well. |
| ||
Since you can store an arbitrary Int in the entity's name, it can represent the handle of a type in the following way:Type TCharacter Field mesh% Field items.TItem[99] Field x#, y#, z# End Type ;Create an instance of the type. Local tempChar.TCharacter = New TCharacter tempChar\mesh = LoadAnimMesh( "character_base.b3d" ) tempChar\x = 100.0 tempChar\y = 36.0 tempChar\z = 20.0 tempChar\items[0] = SwordItem.TItem ;Name the mesh with its own type handle (it's an integer value). NameEntity( tempChar\mesh, Str( Handle( tempChar ) ) ) ;Later in your game, retrieve the type instance that the mesh belongs to based on the handle stored in the name of the mesh. Local meshName$ = EntityName( mesh ) Local originalChar.TCharacter = Object.TCharacter( Int( meshName ) ) ;If the conversion was successful, 'originalChar' will point to the instance of the type (otherwise it's Null). If originalChar <> Null Then ;Utilize the TCharacter instance here. [...] EndIf |
| ||
Yeah. It has children I am using. I made it work by naming each child using nested Countchildren and getchild. But we've sacrificed findchild in the process. I'm not crying too much because the scenes have a lot of same named objects- This because it simplified saying what I collided with. During init, I permanently chop anything after a pipe sign- (Addtnl startup config info), and add the id# in front. We chop off the name for announcements of what I touched/hit. |