No...Blitz tries to free the string bank on exit and crashes. However, EntityRadiusZ doesn't appear to do anything!
Here you go. This lets you store data directly in Blitz entities. Values are indexed from 0 to infinity. Sweeeeet! Write your own entity structures for physics, entity parameters, triggers/targets. If an entity collides with another entity, you can instantly find out that it is a "door" or a "monster". This should be much faster than cycling through a bunch of type, looking for your entity.
SetEntityInt entity,index,value%
GetEntityInt entity,index,[defaultvalue%]
So you can write functions that return properties with just the entity variable:
EntityVelocityX#( PickedEntity() )
EntityHealth( GetParent(entity) )
Graphics3D 400,300,16,2
entity=CreatePivot()
SetEntityInt entity,0,50
SetEntityFloat entity,1,3.14
SetEntityString entity,7,"HEYA"
Print GetEntityInt(entity,0)
Print GetEntityFloat(entity,1)
Print GetEntityString(entity,7)
WaitKey
End
;==========================================
;==========================================
Const BLITZ_ENTITY_RADIUS_Z=240
Function SetEntityInt(entity%,index%,value%)
parameters=PeekL(entity+BLITZ_ENTITY_RADIUS_Z)
If parameters=0 Or parameters=1065353216
parameters=CreateBank((index+1)*4)
PokeL entity+BLITZ_ENTITY_RADIUS_Z,parameters
EndIf
If (index+1)*4>BankSize(parameters) ResizeBank parameters,(index+1)*4
PokeInt parameters,4*index,value
End Function
Function GetEntityInt%(entity%,index%,defaultvalue%=0)
parameters=PeekL(entity+BLITZ_ENTITY_RADIUS_Z)
If parameters=0 Or parameters=1065353216 Return defaultvalue
If (index+1)*4>BankSize(parameters) Return defaultvalue
Return PeekInt(parameters,index*4)
End Function
Function SetEntityFloat(entity%,index%,value#)
parameters=PeekL(entity+BLITZ_ENTITY_RADIUS_Z)
If parameters=0 Or parameters=1065353216
parameters=CreateBank((index+1)*4)
PokeL entity+BLITZ_ENTITY_RADIUS_Z,parameters
EndIf
If (index+1)*4>BankSize(parameters) ResizeBank parameters,(index+1)*4
PokeFloat parameters,4*index,value
End Function
Function GetEntityFloat#(entity%,index%,defaultvalue#=0)
parameters=PeekL(entity+BLITZ_ENTITY_RADIUS_Z)
If parameters=0 Or parameters=1065353216 Return defaultvalue
If (index+1)*4>BankSize(parameters) Return defaultvalue
Return PeekFloat(parameters,index*4)
End Function
Function SetEntityString(entity%,index%,value$)
parameters=PeekL(entity+BLITZ_ENTITY_RADIUS_Z)
If parameters=0 Or parameters=1065353216
parameters=CreateBank((index+1)*4)
PokeL entity+BLITZ_ENTITY_RADIUS_Z,parameters
EndIf
If (index+1)*4>BankSize(parameters) ResizeBank parameters,(index+1)*4
sbank=PeekInt(parameters,4*index)
If sbank
ResizeBank sbank,Len(value)+1
Else
sbank=CreateBank(Len(value)+1)
PokeInt(parameters,4*index,sbank)
EndIf
PokeString sbank,0,value
End Function
Function GetEntityString$(entity%,index%,defaultvalue$="")
parameters=PeekL(entity+BLITZ_ENTITY_RADIUS_Z)
If parameters=0 Or parameters=1065353216 Return defaultvalue
If (index+1)*4>BankSize(parameters) Return defaultvalue
sbank=PeekInt(parameters,index*4)
If Not sbank Return defaultvalue
Return PeekString(sbank,0)
End Function