Skip to main content
gamedev.net
🔒 Locked

using pointer access

Started by iram Jan 1, 2005 at 12:38 AM 3 replies 1.5k views
Original Post
iram
iram
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); }
Deyja
Deyja
Angelscript does not have that complete of pointer support. I'm fairly certain there is no address-of operator.
WitchLord
WitchLord
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 - <a href="http://www.angelcode.com/tower" rel
iram
iram
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
{

}
WitchLord
WitchLord
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 - <a href="http://www.angelcode.com/tower" rel

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.