SyntaxBomb - Indie Coders

Languages & Coding => Blitz2D, BlitzPlus, Blitz3D => Topic started by: Santiago on March 31, 2020, 23:46:32

Title: know the variable name of a specific entity
Post by: Santiago on March 31, 2020, 23:46:32
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!
Title: Re: know the variable name of a specific entity
Post by: grindalf on April 01, 2020, 00:02:10
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
Title: Re: know the variable name of a specific entity
Post by: Santiago on April 01, 2020, 00:35:56
yes, i do that function but not work.


Code: [Select]
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
Title: Re: know the variable name of a specific entity
Post by: Matty on April 01, 2020, 02:57:16
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.
Title: Re: know the variable name of a specific entity
Post by: Santiago on April 03, 2020, 03:47:56
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?
Title: Re: know the variable name of a specific entity
Post by: Matty on April 03, 2020, 05:10:52
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
Title: Re: know the variable name of a specific entity
Post by: STEVIE G on April 03, 2020, 13:34:26
yes, i do that function but not work.


Code: [Select]
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
Title: Re: know the variable name of a specific entity
Post by: RemiD on April 05, 2020, 09:01:54
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...
SimplePortal 2.3.6 © 2008-2014, SimplePortal