Jump to content
  • Advertisement
Sign in to follow this  
virious

Question: Debugging script array

This topic is 2481 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!