"Entity does not exist"

Blitz3D Forums/Blitz3D Beginners Area/"Entity does not exist"

fdfederation(Posted 2014) [#1]
I've encountered a "Entity does not exist" problem. According to my understanding of the code below, if the entity W\TitleEN does not exist, then the code would be skipped. According to the debugger, the value of W\TitleEN is a positive number, yet I keep getting the "Entity does not exist" error. If GY_Title was missing, the error message would be "Texture does not exist" and occur during LoadTexture command. This entity problem occurs on both, my Windows XP and Windows Vista computers. I'm beginning to believe W\TitleEN has a Heisenberg identity crisis.
If W\TitleEN <> 0 Then EntityTexture(W\TitleEN, GY_Title)



RemiD(Posted 2014) [#2]
Some ideas :
Maybe GY_Title does not exist (has not been created or has been destroyed)
or
Maybe GY_Title exists but is in a different "place where you write code"

It can happen if you create a pivot or a mesh in the main "place where you write code", and then you try to access it in a different "place where you write code" (in a function?) and the pivot or a mesh is not a global so you can't access it...


Floyd(Posted 2014) [#3]
There is no variable type for entities. Simple integer variables are used to store "entity handles".
This makes it easier for beginners to get started, but also creates some traps for the unwary.

Graphics3D 600, 400, 0, 2

c = CreateCube()  ; CreateCube() returns a handle, stored in integer variable c
Print c

FreeEntity c  ; Entity is gone, but integer c  remains.
Print c

; You have to set c=0 manually if you will later use it to test whether cube still exists.

; c is non-zero but any attempt to use  it as an entity is an error.

MoveEntity c, 1,1,1  ; fails



Mikorians(Posted 2014) [#4]
Yeah, that had me going for a small while too.
I find myself using failsafes in my functions like

function smashent(c)
if c=0 then return
moveentity c....
end function