Advertisement

How I can realize schema like pointers in C++

Started by November 21, 2009 06:26 PM
0 comments, last by WitchLord 15 years, 3 months ago
I'm using Angel Script. But I meet some trouble. I have SceneNodes that I export to script and for example if i have in scene SceneNode named "Camera" I can execute some methods of SceneNodes in script executing code like Camera.Activate(true). But now I need to something like pointer in my script to call activation of random SceneNode Of course I can write someting like void Activate (int index) { if (index = 0) Camera1.Activate(true); if (index = 1) Camera2.Activate(true); if (index = 2) Camera3.Activate(true); ... } Activate( rnd() ); but such manner not flexable I want realize scheme like that SceneNode*[] nodes; void AutoFill() { Group group = scene.GetGroup("Cameras"); nodes.resize(group.count); for (int i=0; i<group.count; i+) nodes = group.Get(i); } nodes[rnd()].Activate(true); So how i can realize that. I look in direction of reference type, but at first look seems it is no what i seeking
The reference types is exactly what you want. They will allow you to store references to the SceneNode in an array for example.

AngelScript assumes you're using reference counting as the memory management for your reference types, but if you have some other way of doing it you can just register the AddRef/Release behaviours with dummy functions.

If you register the SceneNode as a reference type, the script can look like this:

SceneNode@[] nodes;void AutoFill(){  Group group = scene.GetGroup("Cameras");  nodes.resize(group.count);  for (int i=0; i<group.count; i+) @nodes = @group.Get(i);}nodes[rnd()].Activate(true);


Regards,
Andreas

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