how to copy types?
Blitz3D Forums/Blitz3D Programming/how to copy types?
| ||
is it possible to copy a type with a simply command? like: newtype.mytype= copy thistype.mytype |
| ||
no - have to create a new one and copy across by hand, field by field. You can create a reference to the existing one with newtype.mytype=thistype. |
| ||
Do you specifically need a copy? If not, you can create a pointer to the same type using the following command:player.myplayer = New player; p1.myplayer = player; |
| ||
Yeah, it would be nice to be able to copy the contents of a type instance into another one, but AFAIK it's not currently possible. |
| ||
As Falken stated, you have to do it manually. I found a need to copy or mimic types so often, I included a type copy function in my TypeWriter][ Code Wizard. Examples of code produced by the Code Wizard can be found here. |
| ||
If you need to do this a lot of times or for a large number of types etc. I suppose a function could be created to make it a little more automated/easier |