Tween script values from C++

Started by
2 comments, last by WitchLord 10 years, 7 months ago

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?

Thanks in advance.

Advertisement

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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thx for the rapid answer.

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.

Here are some links :

http://libclaw.sourceforge.net/tweeners.html

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

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

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