Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   Request: Variable Tweening (https://forums.graalonline.com/forums/showthread.php?t=134260208)

Tigairius 08-15-2010 08:38 AM

Request: Variable Tweening
 
This is something I think could really improve some things on Graal. Most likely one of the most useful things that could be added to GScript2: tweening.

Right now Stefan has added createAnimation() to v6, but I really think it would be much more effective to add tweening instead.

Example of how it would work.

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
with (findimg(200)) {
    
this.image "door.png";
    
this.layer 3;
    
this.30;
    
this.30;
    
this.tween("alpha"0.501);
  }


The door would fade in, taking alpha from 0 to 1 in 0.5 seconds.

More interesting things like player tweening could be usable too.

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
player.tween("x"10player.xplayer.10);


This could move the player to the right by 10 tiles over 10 seconds.

Tweening should also be usable on GuiControl objects, for tweening a window's alpha or other variables.


Thoughts, ideas? Any more to add?
I would really like to see this added in v6. It is similar to createAnimation() but much more powerful and flexible.

Fulg0reSama 08-15-2010 08:41 AM

100% supported.

This would help developers on ALL stations.

Ganiists, GFX, LATs, Scripters easily.

TSAdmin 08-15-2010 08:43 AM

I absolutely support this idea. A simple tweening function would remove all hassle from such needed scripts.

Tigairius 08-15-2010 08:44 AM

A few years back Robin made a pretty interesting tweening class but honestly, it's much more efficient to have it built-in and that way it's not interrupting other scripts that are currently running just to do simple nice aesthetic things like fading.

fowlplay4 08-15-2010 08:54 AM

Something to associate an optional ID with the tween, and onTweenCompleted event would be nice.

cbk1994 08-15-2010 09:09 AM

I support this 100%, but I'd rather see it like so:

PHP Code:

temp.tween myObject.addTween();
tween.value "x";
tween.start 2;
tween.finish 4;
tween.duration 1;

// alternate syntax, same thing
with (myObject.addTween()) {
  
value "x";
  
start 2;
  
finish 4;
  
duration 1;


Then you could easily do things like
PHP Code:

waitfor(tween"onTweenCompleted"60); 

or

PHP Code:

this.catchEvent(tween"onTweenCompleted""onMyEvent"); 


Tigairius 08-15-2010 09:57 AM

Quote:

Originally Posted by cbk1994 (Post 1594188)
I support this 100%, but I'd rather see it like so:

Well, I could see how that would be nice, but it could just be done like this without complicating things:
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
temp.player.tween("x"10player.xplayer.10);
  
this.catchEvent(temp.e"onTweenFinished""onMyTweenIsDone");


The point of this tweening is to make it easy to understand and very effective so that it's easy even for LATs to be able to add nice effects even though they're not a scripter. That's why I'm trying to keep it as simple as possible.

dereklarue 08-15-2010 09:59 AM

This would be amazing to have! I await the day we have it, and hopefully this does NOT get overlooked.

adam 08-15-2010 10:02 AM

Oh support indeed.

It also may be possible to revisit that tween class and perhaps make it not interrupt the script or so. Although a far cry from the quality of building it in.

Deas_Voice 08-15-2010 12:58 PM

where do i sign the support list?

Crow 08-15-2010 01:09 PM

Quote:

Originally Posted by Deas_Voice (Post 1594210)
where do i sign the support list?

You just did.

Soala 08-15-2010 01:20 PM

I support, for sure!

cyan3 08-15-2010 02:22 PM

I support, tweening would be awesome for Graal.

Gothika 08-15-2010 02:27 PM

I'll support this, yeah.

Dnegel 08-15-2010 02:41 PM

I support it!

Deas_Voice 08-15-2010 03:10 PM

Quote:

Originally Posted by Crow (Post 1594211)
You just did.

cool :cool:

Cloven 08-15-2010 03:17 PM

Good idea Tig. *supports*

Loriel 08-15-2010 06:24 PM

Someone build a thing that lets you schedule callbacks instead of just setting the timeout

Then you can just have the tweening thing be a function that does a thing and then adds itself again until it turns out to be already done; also you now have a really cool and generic mechanism

but I kind of forgot whether you guys have proper first class functions so I do not know how elegant that would end up being in implementation


also can you do, like, (@ "this.derp") or only this.(@"derp")

Admins 08-15-2010 07:03 PM

This could be interesting, although the gui animations do more than just changing a value, there is also page-flip, you can set the time offset, several animations can work together, and you set the animation function (linear or sinus curve) and interval. What you want is basicly a combination of the new gui animation and the particle emitter modifiers and make it working for any script variable?

Crow 08-15-2010 07:09 PM

Quote:

Originally Posted by Loriel (Post 1594250)
also can you do, like, (@ "this.derp") or only this.(@"derp")

Only the latter, I believe.

Crow 08-15-2010 07:10 PM

Quote:

Originally Posted by Stefan (Post 1594257)
What you want is basicly a combination of the new gui animation and the particle emitter modifiers and make it working for any script variable?

Would be cool, yea. An unbelievably stupid thing of the particle emitter modifiers is the "range" though; you know, that time range. It's okay-ish for particle emitters, but that's it. Wouldn't need that for the tweening stuff.

cbk1994 08-15-2010 08:28 PM

Quote:

Originally Posted by Stefan (Post 1594257)
This could be interesting, although the gui animations do more than just changing a value, there is also page-flip, you can set the time offset, several animations can work together, and you set the animation function (linear or sinus curve) and interval.

Can you document that somewhere?

Quote:

What you want is basicly a combination of the new gui animation and the particle emitter modifiers and make it working for any script variable?
If I understood you right, that would be perfect.

Tigairius 08-15-2010 08:50 PM

Quote:

Originally Posted by Stefan (Post 1594257)
What you want is basicly a combination of the new gui animation and the particle emitter modifiers and make it working for any script variable?

Yep, pretty much :D

adam 08-15-2010 09:52 PM

Quote:

Originally Posted by Loriel (Post 1594250)
Someone build a thing that lets you schedule callbacks instead of just setting the timeout

Then you can just have the tweening thing be a function that does a thing and then adds itself again until it turns out to be already done; also you now have a really cool and generic mechanism

but I kind of forgot whether you guys have proper first class functions so I do not know how elegant that would end up being in implementation


also can you do, like, (@ "this.derp") or only this.(@"derp")

http://forums.graalonline.com/forums...hp?t=134259917

Is something like this what your thinking? You don't need any timeouts, you create the bar onCreated, and it works and animates and polls it's set variable all on it's own.

Loriel 08-15-2010 11:02 PM

Yeah, pretty much that. I did not know we had scheduleevent, this is pretty cool. So setTimer(x) is just schedulevent(x, "Timeout", null)?

cbk1994 08-16-2010 12:08 AM

Quote:

Originally Posted by Loriel (Post 1594317)
So setTimer(x) is just schedulevent(x, "Timeout", null)?

Yes except that it also cancels any timers already set (and setTimer(0) doesn't schedule the event).

Loriel 08-16-2010 12:56 AM

That is a good point

WhiteDragon 08-16-2010 04:15 AM

PHP Code:

function setTimer(temp.x) {
  if (
temp.<= 0) {
    return;
  }
  
cancelevents("Timeout");
  
scheduleevent(temp.x"Timeout"null);


And probably some other magic.

I never use timeouts because I like to pass state to the function via. scheduleevent instead of relying on this. variables like you need to in timeouts.

cbk1994 08-16-2010 04:18 AM

Quote:

Originally Posted by WhiteDragon (Post 1594394)
PHP Code:

function setTimer(temp.x) {
  if (
temp.<= 0) {
    return;
  }
  
cancelevents("Timeout");
  
scheduleevent(temp.x"Timeout"null);


And probably some other magic.

I never use timeouts because I like to pass state to the function via. scheduleevent instead of relying on this. variables like you need to in timeouts.

Corrected.

PHP Code:

function setTimer(temp.x) { 
  
cancelevents("Timeout"); 
  
  if (
temp.<= 0) { 
    return; 
  } 
  
scheduleevent(temp.x"Timeout"null); 



adam 08-16-2010 04:37 AM

Quote:

Originally Posted by Loriel (Post 1594317)
Yeah, pretty much that. I did not know we had scheduleevent, this is pretty cool. So setTimer(x) is just schedulevent(x, "Timeout", null)?

If you look closely at the script I made, you can schedule any number of timers, named whatever you want. They won't interfere with one another. The one in my script calleds the function onUpdate() every .05 seconds. It could easily be done with any other function I imagine. The function is part of a TStaticVar.

In the same script it's possible to create hundreds of bars (prabably some slowdown X.x) but they all update independently of eachother as separate TStaticVar objects.

Tigairius 08-22-2010 11:48 PM

GScript2 version: http://forums.graalonline.com/forums...hp?t=134260288

Admins 08-23-2010 01:07 AM

Timeouts of DBNPCs also survive server restarts, while scheduleevents don't.

adam 08-25-2010 01:16 AM

http://forums.graalonline.com/forums...ighlight=Tween

How's this one?


All times are GMT +2. The time now is 09:02 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.