December 04, 2020, 02:27:13 PM

Author Topic: know the variable name of a specific entity  (Read 590 times)

Offline Santiago

  • Sr. Member
  • ****
  • Posts: 283
  • Blitz3d
    • Indiesoft
know the variable name of a specific entity
« on: March 31, 2020, 11:46:32 PM »
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!

Offline grindalf

  • Full Member
  • ***
  • Posts: 152
Re: know the variable name of a specific entity
« Reply #1 on: April 01, 2020, 12:02:10 AM »
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

Offline Santiago

  • Sr. Member
  • ****
  • Posts: 283
  • Blitz3d
    • Indiesoft
Re: know the variable name of a specific entity
« Reply #2 on: April 01, 2020, 12:35:56 AM »
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

Offline Matty

  • Hero Member
  • *****
  • Posts: 1258
    • MattiesGames
Re: know the variable name of a specific entity
« Reply #3 on: April 01, 2020, 02:57:16 AM »
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.

Offline Santiago

  • Sr. Member
  • ****
  • Posts: 283
  • Blitz3d
    • Indiesoft
Re: know the variable name of a specific entity
« Reply #4 on: April 03, 2020, 03:47:56 AM »
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?

Offline Matty

  • Hero Member
  • *****
  • Posts: 1258
    • MattiesGames
Re: know the variable name of a specific entity
« Reply #5 on: April 03, 2020, 05:10:52 AM »
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

Offline STEVIE G

  • Sr. Member
  • ****
  • Posts: 498
Re: know the variable name of a specific entity
« Reply #6 on: April 03, 2020, 01:34:26 PM »
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

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1081
Re: know the variable name of a specific entity
« Reply #7 on: April 05, 2020, 09:01:54 AM »
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...
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal