Frictional Games Forum (read-only)
[SCRIPT] Pointers (parameter references) - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Pointers (parameter references) (/thread-19281.html)



Pointers (parameter references) - Adrianis - 11-19-2012

... 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


RE: Pointers (parameter references) - Your Computer - 11-19-2012

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.


RE: Pointers (parameter references) - Adrianis - 11-19-2012

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:
void OnStart()
{
    
string strTest "Has not been changed";
    
Test_Var_Pointer(strTest);
    
AddDebugMessage(strTestfalse);
}

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