Advertisement

using pointer access

Started by January 01, 2005 12:38 AM
3 comments, last by WitchLord 20 years, 1 month ago
i have the following function in angelscript. cannot pass the address of an object over to the function, the compiler keep complaining about accessing error. how to do it correctly? void main() { Point3 p; p.x = 123; p.y = 456; p.z = 789; SC_Main_Point (&p); //cannot work!! } void SC_Main_Point (Point3 *po) { Console ("#####################"); ConsoleF (po->x); ConsoleF (po->y); ConsoleF (po->z); }
Angelscript does not have that complete of pointer support. I'm fairly certain there is no address-of operator.
Advertisement
AngelScript don't allow the manipulation of pointers, nor taking the address of variables, due to security reasons.

You can however pass parameters by reference, so doing the following would work:

void main(){Point3 p;p.x = 123;p.y = 456;p.z = 789;SC_Main_Point (p); // The point is passed by reference}void SC_Main_Point (Point3 &po){Console ("#####################"); ConsoleF (po.x);ConsoleF (po.y);ConsoleF (po.z); }

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

that works gracefully!!

btw, how to compare whether a pointer is null in angelscript ?


i tried to no valid:

float *p;

if (p == NULL) //does not work
{

}
NULL doesn't exist in AS 1.10.1, but you should be able to use 0.

if( p == 0 )   ...


In AS 2.0.0 pointers don't exist as they do in C++, but there you have handles, which are basically smart pointers. With these you can compare with 'null' to verify if they are set 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