Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Pointers (parameter references)
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#1
Pointers (parameter references)

... Anyone know if we can use them? I read in the AngelScript manual that it supports C++ style Pointers in scripts but only if the application specifically allows it. Came across this as I was using a function to modify an array passed to the function thinking it would implicitly be passed by reference, which it doesn't seem to be (as the array in the calling function was not modified once the function had run), but before I explore possible other solutions it'd be great to know if it could simply be set as a pointer
11-19-2012, 06:57 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Pointers (parameter references)

I think the closest thing to what you are referring to is the use of the in and out keywords. By using out, you can have a function change the value of the variable passed in.

Tutorials: From Noob to Pro
11-19-2012, 07:47 PM
Website Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#3
RE: Pointers (parameter references)

Indeed! The following is a working example, for anyone else that may be interested. This is the best way to get a function to return multiple values without using 'SetLocalVar...', if you find you need it. Thanks again for the help, YC

PHP Code: (Select All)
void OnStart()
{
    
string strTest "Has not been changed";
    
Test_Var_Pointer(strTest);
    
AddDebugMessage(strTestfalse);
}

void Test_Var_Pointer(string &out strInput)
{
   
strInput "Changed!"

(This post was last modified: 11-19-2012, 09:45 PM by Adrianis.)
11-19-2012, 09:31 PM
Find




Users browsing this thread: 2 Guest(s)