Advertisement

best way to register a property

Started by October 15, 2007 05:51 PM
2 comments, last by WitchLord 17 years, 4 months ago
Hello, I want to register a c++ class as a global property and it should not be allowed to be constructed in the script, but a reference to an object of this class should be allowed to be passed as a parameter of a function. i.e.:

engine->RegisterObjectType("signal_t", 0, asOBJ_REF | asOBJ_NOHANDLE); 
engine->RegisterGlobalProperty("signal_t my_signal", &my_signal);

...

engine->RegisterObjectMethod("some_other_class_t", "void foo(signal_t ∈)", asFUNCTION(foo_generic), asCALL_GENERIC); 
AS code:

some_other_class_t my_class;
my_class.foo(my_signal);
Should I register an assignment behavior for signal_t or do something else?
also, what is the correct way to return boolean in the maximum portability mode?

I've used SetReturnDWord, it works well with AS 2.8.1, but it works no more for me with AS r205...
Advertisement
It looks like SetReturnByte works nice.
Yes, SetReturnByte is the correct method, since the boolean type is only 1 byte. You can also use GetReturnPointer, e.g:

*(bool*)gen->GetReturnPointer() = true;


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