Hello HTU,
I suspect that the reason you're having problems is simply because (I assume) you don't realise you can return any type from a function, including user-defined types such as your 'entity' and 'particle' types.
For instance:
Here, you're creating e.emitter in your function, then returning its pivot field, instead of just returning e.emitter. You should modify this to return the e.emitter you've created, then pass 'e.emitter' to your other functions -- note that the function name has the type appended below, ie .emitter:
Note that the call would have to be made as myemitter.emitter = createemitter (x,y,z), ie. using the .emitter type to receive the result.
Then, for any functions that use the returned value from createemitter...
Old:
New:
Note that the parameter's type is defined as an emitter, ie. you should pass the .emitter type you received from createemitter ().
As you'll see, this removes all the For/Next checks too. You probably won't need the Object/Handle calls either if you do this.
The same goes for your particle type and its associated functions.
I suspect that the reason you're having problems is simply because (I assume) you don't realise you can return any type from a function, including user-defined types such as your 'entity' and 'particle' types.
For instance:
Function createemitter (mx#,my#,mz#,pitch#,yaw#,roll#,rm#=0,rr#=0,fade=True);Create an emitter e.emitter=New emitter e\pt=CreatePivot();emitter entity ; etc Return e\pt End Function
Here, you're creating e.emitter in your function, then returning its pivot field, instead of just returning e.emitter. You should modify this to return the e.emitter you've created, then pass 'e.emitter' to your other functions -- note that the function name has the type appended below, ie .emitter:
Function createemitter<b>.emitter</b> (mx#,my#,mz#,pitch#,yaw#,roll#,rm#=0,rr#=0,fade=True);Create an emitter e.emitter=New emitter e\pt=CreatePivot();emitter entity ; etc Return <b>e</b> ; Not e\pt End Function
Note that the call would have to be made as myemitter.emitter = createemitter (x,y,z), ie. using the .emitter type to receive the result.
Then, for any functions that use the returned value from createemitter...
Old:
Function freeemitter(emitter);removes an emitter For e.emitter=Each emitter If e\pt=emitter FreeEntity e\pt Delete e EndIf Next End Function
New:
Function freeemitter(e.emitter);removes an emitter If e Delete e EndIf End Function
Note that the parameter's type is defined as an emitter, ie. you should pass the .emitter type you received from createemitter ().
As you'll see, this removes all the For/Next checks too. You probably won't need the Object/Handle calls either if you do this.
The same goes for your particle type and its associated functions.