well, at any level, resizing of an array commonly involves complete reallocation as theres little garantee that anything after the array is free to be appended. So having a second array dimmed to one, and then making a function to dim b to the size of a, dim a to the new size and copy the values back wouldnt be any bother..except it'd have to be done for every desired array..and be slow..So woulod only really be usefull when say having a pause already due to loading an area or something.
Generally, i suppose the eg.enemy you would want would be discovered during a loop for each enemy eg:
for this.ene blabla
If closeToPlayer(...)
If playerAttacking(...)
;here, this is obviously the type yod want.
EndIf
EndIf
next
But if you wanted at this moment to pick some out from the list, or on creation set some so that you could add soemthing else onto what happens to them/treat thm differently, rather than having variables, or storing them with arrays and storing off which indices you wanted to access, you would sometimes be better off having a seperate list of types, which each have one of those types a s a field, and allow you to iterate through a constriction on those types rather than through all of the types as blitz forces. eg:
However with new hurt_enemy_types being made and freed alot, that can be both messy and mess about with memory. But for some situations it can be usefull to be able to only check a particular condition once, and process the results on a constricted group of the types later (withought having to check any values on that group). If you only wanted one type out of the loo after detection...Just having another type :
local closest.my_type
For ...
if something
if IsCloserThanOthersSoFar(...)
closest=this;
endif
endif
Next
Handle() allows you to store a value relating to a types address into an integer. Object() allows you to get it back again, eg:
Type me_type
field name$
end type
local me.me_type=new me_type
me\name$="aab"
local handleToMe% = Handle( me )
. . .
local someone.me_type = Object.me_type ( handleToMe )
print someone\name$ ;prints "aab"
; i *think* lol
I think its almost useless. Types are already an address-type of thing(referenced through functions..can be null), and much safer. Even if two types are exactly the same, blitz internal storage methods (which allows the for each thing) means they cannot be intechanged through handle() and object() You can make a library though, and only return handles so that your users dont have to worry about the types name when passuing it within their code etc: In other words it would be like saying "we dont want this types values to be changed other than through our own functions"...Not that it forces such a thing, but it makes it obvious that thats the intent.
|