know the variable name of a specific entity

Started by Santiago, March 31, 2020, 23:46:32

Previous topic - Next topic

Santiago

Hi. there is a way to find an know what VARIABLE or TYPE name have a specific ID?

i need this to improve the Debug. sometimes you have a fail, you see that in the debug, but you don't know what entity generate the problem..


example.

ball = createsphere()
moveentity ball,x,y,z
no problem!



ball = createsphere()
moveentity ball,x,y,z
freeentity ball

if ball <> 0 then
  moveentity ball,x,y,z      <<< this is a problem, because freeentity dont allways reset the variable ID
end if


that happend too when you freeentity an entity, the childs dissapear, but sometimes you don't know because you have many realationships.


what i need, is something, when the entity dosent exist, i have the ID, i dont have the entity, but i want to know what's the name of varible who have that entity ID.

and if you have a list of variables, you can have more control about the resouses you are using...


this can be do?, there is a way to know that?

Sorry my english....
saludos!

GrindalfGames

I always do
FreeEntity Ball:Ball=0

But it of course won't help with children and I don't know of any other way to check

Santiago

yes, i do that function but not work.



Function free(entidad)


;Elimina la entidad y quita el valor a la integral
;kill the entity and reset the variable

If entidad<> 0 Then
;DebugLog "tratando de eliminar : " + entidad
FreeEntity entidad
entidad = 0             < this fail... my variable entidad no exist because i free or something like that.

End If


End Function

Matty

Slow way....

If every entity that is created is assigned a parent at creation of a 'universe pivot' at the top level you can search recursively every child of the universe pivot.  If the number is not found you have found an entity which has been freed but you still have the number.

Santiago

ok, is a good idea!, i can make a function to try it! :)

Thanks.


that's is like a tree of parents, i think what happen if i create something without parent to universal pivot...

i have so much entitys, sprites, smokes, fires, explotion, but i need to have order and fix that.

anyway. there is no way to know the variable name of an ID value?

Matty

No.

If you do this:

mycube = createcube()

the function returns a number stored as an integer in 'mycube'.

If you 'lose' the number somehow...eg say you did something like this:

mycube = rand(1,100)

afterwards then there is then no way of finding the number ever again....

Likewise....if you do this;

mycube = createcube()

and say mycube then equals '23949282' for example....

it's just a number....

There's no master entity list in blitz to search for that number in an entity.....

Because...it could be an entity, a camera, a light, a pivot anything at all....and there's no way to do what you say

STEVIE G

Quote from: Santiago on April 01, 2020, 00:35:56
yes, i do that function but not work.



Function free(entidad)


;Elimina la entidad y quita el valor a la integral
;kill the entity and reset the variable

If entidad<> 0 Then
;DebugLog "tratando de eliminar : " + entidad
FreeEntity entidad
entidad = 0             < this fail... my variable entidad no exist because i free or something like that.

End If


End Function


The variable entidad only exists locally inside this function.  free( MyEntity) in this case will not set MyEntity to 0.

Do as grindalf has said ...

freeentity entidad : entidad = 0

RemiD

yes i would also do :
free entity : entity = 0

however if you use lists (customtype or dim) and if you reorganize the list each time an entity is destroyed, you would never trigger such an error...