Followers 0

# Tween script values from C++

## 3 posts in this topic

Hi,

I would like to tween script values (or script properties) via a C++ tween module.

But I don't know how to do this.

In c++ it's quite easy, I just keep an int* or a float* and update values through these pointers but with angelscript float and int are value types and if I understand the documentation, I can't get any pointer to value types (and then I cannot modify them from my c++ code)

It seems I might use the flag asEP_ALLOW_UNSAFE_REFERENCES  but I prefer a safier solution if possible.

Do you have any idea  how to do this?

0

##### Share on other sites

I'm not familiar with the term 'tween'. What does it mean?

Use of asEP_ALLOW_UNSAFE_REFERENCES will allow you to pass primitives to functions with &inout (i.e. a reference to the actual variable so it can be both read and modified by the function). Despite being unsafe, it is no more unsafe than passing primitives by reference or pointer to a function in C++. If you don't care about sandboxing the script environment and trust your script writers to have at least a little bit of good sense when writing the scripts, then you should be perfectly fine with asEP_ALLOW_UNSAFE_REFERENCES.

Without asEP_ALLOW_UNSAFE_REFERENCES you will have to pass the primitive values in two args, one for input and another for output, e.g.:

void foo(int inValue, int &out outValue)
{
outValue = inValue * 2;
}


The &out in AngelScript translates to either a & or * in C++, but know that the value referred to in the argument will be uninitialized as it is meant for output only.

0

##### Share on other sites

I'm currently trying to work with a reference class containing the float that will be updated by my c++ code, and it seems to work.

Concerning your question , I'm french so I'm not sure about the exact meaning of "tween" ;-) but for me it's an interpolation. And I consider a "tweener" as an interpolation system with special effects.

http://itween.pixelplacement.com/index.php

0

##### Share on other sites

Thanks for the links to the tween classes. I understand the term now :)

0

## Create an account

Register a new account