Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Tween script values from C++


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Meyer   Members   -  Reputation: 120

Like
0Likes
Like

Posted 25 September 2013 - 02:08 AM

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.



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3290

Like
0Likes
Like

Posted 25 September 2013 - 08:01 AM

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

#3 Meyer   Members   -  Reputation: 120

Like
0Likes
Like

Posted 25 September 2013 - 08:29 AM

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



#4 Andreas Jonsson   Moderators   -  Reputation: 3290

Like
0Likes
Like

Posted 25 September 2013 - 08:48 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS