Advertisement

Variable Parameter documentation needs to be expanded

Started by June 24, 2012 11:53 AM
3 comments, last by WitchLord 12 years, 5 months ago
Several items in the variable parameter documentation need to be addressed, specifically in regards to object handles.

This function is extremely powerful and is the closest we'll be getting to Template global functions for a start, and this is extremely important for Object factories.

For example in my current game I now use the function.

Some functions that need to be expanded upon in the documentation are



asIScriptEngine::GetObjectTypeById(int type)

the type that is passed to a variable parameters function can be used to discern the handle that is passed too it.

e.g.

[source lang="cpp"]void VariableFunction(void *value, int type){
//the name of the handle can be retrieved using
engine->GetObjectTypeById(type)->GetName();
}[/source]

the other part that needs to be addressed is that you can store/edit objects passed via variable parameter


[source lang="cpp"]void VariableFunction(void *value, int type){
//retrieve
asIScriptObject* obj = (asIScriptObject*)*(void**)value;
//store
*(void**)value = obj;
}[/source]
its a shame that such a powerful feature of Angel script goes unnoticed, The way that i'm currently using it is to initialize script entities with an associated c++ class in this way

Test_Ui @test;
CreateEntity(@test,"Menu");
test.DoStuff();


AnotherRandomClass @random;
CreateEntity(@test,"Menu");

.ect

I wish angelscript had a WIKI so that people could handle some of the documentation :D, anyways I thoguht i'd add this as it makes for a very powerful tool when creating factory functions in Angelscript.
Forgot to include that you should use:

if (type & asTYPEID_OBJHANDLE)

to ensure that what is being passed to the function, is actually a handle.
Advertisement
Thanks for the feedback. I'll look into expanding the manual with these points.


There is a public wiki at angelscript.pbworks.com. You're welcome to write articles on the topic of AngelScript there if you wish.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I wasn't aware of that wiki, is it mentioned on the main site?
It is. Under 'Further resources & support', section 'Community' :)

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement