Hi
I have the following
typedef struct
{
float posX;
float posY;
} _2dPoint;
typedef struct
{
_2dPoint pos;
float somethingelse;
float anotherThing;
} _wayPoint;
extern _wayPoint *waypoints;
waypoints = malloc(enough space to hold all the data)
Q: How do I pass the waypoints pointer to a script, so that within the script I can access:
waypoints.pos.posX
Thanks very much.
Passing pointer to struct
Started by Gibbon_99, Mar 30 2004 03:28 PM
1 reply to this topic
Ad:
#2 Moderators - Reputation: 2311
Posted 31 March 2004 - 12:36 AM
AngelScript doesn''t yet support the [] operator so I suggest you do the following:
Register this function as follows:
This will allow you to make the following statements in AngelScript:
__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library
_wayPoint *WayPoint(int index)
{
if( index < 0 || index >= maxWayPoints )
{
GetActiveContext()->SetException("Out of bounds");
return 0;
}
return waypoints[index];
}
Register this function as follows:
engine->RegisterGlobalFunction("waypoint &WayPoint(int index)", asFUNCTION(WayPoint), asCALL_CDECL);
This will allow you to make the following statements in AngelScript:
int n = 10;
waypoint wp;
wp = WayPoint(n);
wp.pos.posX = WayPoint(n+1).pos.posX;
wp.pos.posY = WayPoint(n+2).pos.posY;
WayPoint(n) = wp;
__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library






