Advertisement

Question: Debugging script array

Started by February 23, 2012 04:21 PM
0 comments, last by WitchLord 12 years, 9 months ago
I'm trying to inspect items which are stored in a script array. For example, I have "array<Location@> locations". I know it's type and subtype by using GetObjectTypeById() and next GetSubType(). How can I get pointer to the original native CScriptArray object, so I can iterate through the items it contains?

The problem is that m_context->GetAddressOfVar() returns null in this case, so that's why I'm trying to figure out some other way of obtaining that pointer.

Thanks in advance!
GetAddressOfVar() should work on script arrays the same way it does for other types.

If the variable has been declared with 'array<Location@> locations', then m_context->GetAddressOfVar() should return a pointer to the actual CScriptArray object, you just need to cast it. If on the other hand the variable is declared as a handle, then GetAddressOfVar() will return a pointer to the handle to the CScriptArray, and you'll need to dereference the pointer before accessing the CScriptArray object.

That GetAddressOfVar() is returning a null pointer is probably because the variable index, or the stack level argument is wrong. Another possibility is that you're trying to inspect the array before it has actually been instanciating, in which case the function also returns null. You can call IsVarInScope() to determine if the array has already been instanciated or not.

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