Basics to use custom type
Blitz3D Forums/Blitz3D Tutorials/Basics to use custom type
| ||
Maybe this will help somebody to better understand how to use custom "type" : |
| ||
can you post that into the codearchive (if not did alarydy?)) might be a usefull ressource.... |
| ||
This actually makes it more clear than ever seen in an explanation. Thanks. |
| ||
Glad this can help. There is some thing missing : how to use nameentity() to store the typename and the instancehandle in the entity name, then after a collision or a linepick, how to retrieve the entity name with entityname(), then how to extract the typename and the instancehandle from the entity name, then know in which list (custom type list) to search to find the wanted instance. ( with Object.TypeName(InstanceHandle) ) See : http://www.blitzbasic.com/codearcs/codearcs.php?code=3095 |
| ||
Checked a couple of other simple examples of the very poorly documented commands 'Handle' and 'Object' to fully get my head wrapped around the complete Type usage. Now I don't have an issue with the 'Handle' command, it's the 'Object' one that is a bit fuzzy to me: Example#1: That all makes perfect sense just as a line like this: e.entity = Object entity(EntityName(PickedEntity)) But also seen it as in a format as such: Example#2: What is now having me puzzled/confused is the diference in usage in above examples like: w.weapon = Object weapon(w_handle) a_custom_type.MY_TYPE = Object.MY_TYPE( integer_variable% ) The later format 'Object.typename' I also found in the un-official version of the "b3ddocspatch199 help"(quoted below): Object.typename(objecthandle) Parameters typename - the custom type the Object function should return objecthandle - an integer handle produced by the Handle function Description The Object function takes the integer handle of an object and if it exists returns an actual reference to the object given it is of the Type specified. See also: Type, Handle. Example ; Object Type MYTYPE Field myint End Type Dim HandleArray(4) For count=1 To 3 temp.MYTYPE=New MYTYPE HandleArray(count)=Handle(temp) Print "HandleArray("+count+")="+HandleArray(count) Next Delete Object.MYTYPE(HandleArray(2)) Print "Deleted 2nd MYTYPE" temp.MYTYPE=New MYTYPE HandleArray(4)=Handle(temp) For count=1 To 4 temp.MYTYPE=Object.MYTYPE(HandleArray(count)) Print "temp="+Handle(temp) Next WaitKey() End Index Click here to view the latest version of this page online << Of course doesn't exist :-( Call me silly(I am suffering from a burnout so please bare with me), but why does the 'Object' command appear to exist in 2 formats? 1) Object 2) Object.Type |
| ||
@Rick>>Sorry i haven't seen your post until now... Handle(instance) is to retrieve the handle/id of the instance but what is confusing is that the handle/id corresponds to a count cumulating the number of created instances of all custom types (of all different lists) so if you use different custom types (different lists), you can't be sure what will be the value of the handle/id of the next instance (you could but it is useless, you don't need to know that). Object.TypeName(InstanceHandle) is to go directly to the instance having this handle/id. Especially useful after a collision/linepick when you want to update the collidable/pickable. I don't really understand the usefulness to store the instance of a custom type in an array, if you can waste memory, use several arrays to store the values/references of your things. If you can't waste memory, use a custom type to store the values/references of your things. The advantage of a custom type list is that you can have a list of a variable size and that you don't have to reorder the list... That's how i see it... |
| ||
Thanks for getting back at this. I'll look into this further(when up to it). |