using freeentity and clearworld

Blitz3D Forums/Blitz3D Beginners Area/using freeentity and clearworld

seferey(Posted 2006) [#1]
I'm trying to clear everything and would this work

also how can I tell if everything is cleared

Function ClearALL()

;Free the Memory and end the program

ClearWorld sky1,0,sky
ClearWorld terrain,0,Grass
FreeEntity Wall
FreeEntity box
FreeEntity Tree1
FreeEntity Tree2
FreeEntity Tree3
FreeEntity Tree5
FreeEntity Tree6
FreeEntity Lf1
FreeEntity Lf2
FreeEntity Lf3
FreeEntity Lf5
FreeEntity Lf6


End Function


jhocking(Posted 2006) [#2]
There's no need to use FreeEntity after using ClearWorld, nor is there any need for multiple ClearWorlds. In fact, I think that'll throw up errors because you are trying to call commands on entities that no longer exist; have you actually tried running that code? ClearWorld will delete all visual assets from memory. You will still need to handle erasing variables, type instances, sounds, etc.


Bobysait(Posted 2006) [#3]
i'm not sure clearWorld must be used like this.

=> "ClearWorld 1,1,1" will clear every mesh, every tex etc...
=> " ClearWorld Sky1,0,sky" will clear every mesh and every texture, without clearing brushes, but it won't specically clear the Entity "Sky1" .

using ClearWorld Sky1, you will just set a param for clearworld that will be understood by blitz like ClearWorld 1.

If you want to free a specify entity => Freeentity .
if you want to free a specify texture => FreeTexture.

Don't forget that if you free an entity, you'd better specify the variable of your entity =0

FreeEntity MyEntity
MyEntity=0



to be sure, you'll not try to free an entity that have been cleared before.
Then if you try free an entity, check if the Entity Exist !
if Entity<>0 FreeEntity Entity

or use a simple function

; try to free an entity 
Entity=FreeMyEntity(Entity)

function FreeMyEntity%(Entity)
  if Entity<>0  
    Freeentity Entity
  endif
  return 0
end function