Copyentity with types ?
Blitz3D Forums/Blitz3D Beginners Area/Copyentity with types ?
| ||
If I have a type, and an array of a type, and I want to copy an item from the array of the type, to another array position in a different array of the same type though, can I do this, and bring all the fields etc with it ? ex. player(ID_player) = copyentity(lvlgrid(countz%,countx%)) to copy everything the field variables, mesh handles etc.. or do I have to manually copy each field in a loop ? |
| ||
Hmmm, try to explain in plain english what is inside what, and what you want to copy to what. |
| ||
okay say I have a type type something field mesh field locx field locy end type Then I make an array of these types. dim myarray.something(10) dim player.something(5) Then say I wanted to copy myarray.something(4) -> player.something(3) Meaning I want all the fields that have been initialized earlier, say I had a function taht went through myarray and init'd all the variables for each array element. and I wanted to copy the whole array element position 4, all the fields and their values etc.. to player array element 3. so that player array element 3 contains all the fields and values from myarray(4). So what I want to know is, can I use player(3) = copyentity(myarray(4)) Will this work like I want it to, copying all fields etc.. ? If not, I guess I will just have to manually copy the fields, I was just trying to make a shortcut, by copying the whole entity fields and all, then only changing the fields that need to be changed, to make the code shorter. |
| ||
A type instance isn't an entity so using copyentity doesn't work. If you want a completely new/separate type instance to be created when copying, you're going to have to do it all manually, like: player(3) = New something player(3)\mesh = myarray(4)\mesh player(3)\locx = myarray(4)\locx player(3)\locy = myarray(4)\locy All a bit messy but if you pack it away into your own copy_type() function, you only have to look at it once. ;) Or, if you simply want to make player(3) reference the same type instance as myarray(4), you can of course just do: player(3) = myarray(4) |