Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-04-2012, 02:54 AM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
function similar to move()

Hey all, i'm wondering if there's a function that behaves similar to move(), but it's used for guicontrol images. I want to move an image from point a to point b.

Thanks, Alpho.
Reply With Quote
  #2  
Old 07-04-2012, 03:07 AM
DeCeaseD DeCeaseD is offline
Registered User
Join Date: Jan 2008
Posts: 247
DeCeaseD will become famous soon enough
Quote:
Originally Posted by Alpho View Post
Hey all, i'm wondering if there's a function that behaves similar to move(), but it's used for guicontrol images. I want to move an image from point a to point b.

Thanks, Alpho.
Couldn't you just alter the x/y of the GUIcontrol in a timeout loop? Or am I misunderstanding what you're trying to achieve?
Reply With Quote
  #3  
Old 07-04-2012, 03:13 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
As far as I know Stefan did add something like this in the more recent v6 releases. I don't know where to search though.
Reply With Quote
  #4  
Old 07-04-2012, 03:15 AM
DeCeaseD DeCeaseD is offline
Registered User
Join Date: Jan 2008
Posts: 247
DeCeaseD will become famous soon enough
Quote:
Originally Posted by DustyPorViva View Post
As far as I know Stefan did add something like this in the more recent v6 releases. I don't know where to search though.
It's something to do with GuiControl.createAnimation().. not exactly sure what the parameters are though. Or at least I think? lol
Reply With Quote
  #5  
Old 07-04-2012, 04:05 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by DeCeaseD View Post
It's something to do with GuiControl.createAnimation().. not exactly sure what the parameters are though. Or at least I think? lol
See:

Quote:
Originally Posted by cbk1994 View Post
For the animations,

PHP Code:
temp.animation this.createAnimation();
temp.animation.duration 1;
temp.animation.transition "moveoutleft"
Mostly for iPhone stuff, but it also works on v6 clients. It lets you easily fade in/out or move in/out GUI objects.
As far as I know, it's not possible to tween the position to arbitrary values. Look at something like this instead.
__________________
Reply With Quote
  #6  
Old 07-04-2012, 08:23 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
or you could edit the (much simpler) variable tweening that I suggested a while back. Join your GUI object to the class, and use tween on "x" or "y" instead of "alpha".
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #7  
Old 07-04-2012, 08:11 PM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
Thank you everybody for the input! In the end, I went with Tigairius's variable tweening.

Quote:
Originally Posted by Tigairius View Post
or you could edit the (much simpler) variable tweening that I suggested a while back. Join your GUI object to the class, and use tween on "x" or "y" instead of "alpha".
Tig, I got your example to work perfectly when I put the class clientsided. Though I can't get it to work with my gui controls. Any ideas?
Reply With Quote
  #8  
Old 07-04-2012, 09:31 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Alpho View Post
Thank you everybody for the input! In the end, I went with Tigairius's variable tweening.



Tig, I got your example to work perfectly when I put the class clientsided. Though I can't get it to work with my gui controls. Any ideas?
Sure, just post the portion of the script that you're trying to get to work and we'll get it working.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #9  
Old 07-04-2012, 09:43 PM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
PHP Code:
  with (HBUI_Point0) {
    
join("plugin_tween");
    
tween("x"1xx+50);
  } 
That's called upon clicking a gui button.

HBUI_Point0 is a GuiShowImgCtrl.
Reply With Quote
  #10  
Old 07-04-2012, 10:06 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
I don't think you need to join it to the specific object(in this case the control), but just to the script itself.
Reply With Quote
  #11  
Old 07-04-2012, 10:07 PM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
Quote:
Originally Posted by DustyPorViva View Post
I don't think you need to join it to the specific object(in this case the control), but just to the script itself.
Even just joining the script it's self to the class won't work for me. Thanks though.
Reply With Quote
  #12  
Old 07-04-2012, 10:11 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Alpho View Post
PHP Code:
  with (HBUI_Point0) {
    
join("plugin_tween");
    
tween("x"1xx+50);
  } 
That's called upon clicking a gui button.

HBUI_Point0 is a GuiShowImgCtrl.
Something like this should work:
PHP Code:
new GuiShowImgCtrl("HBUI_Point0") {
  
profile GuiDefaultProfile;
  
image "block.png";
  
height 32;
  
width 32;
  
300;
  
300;
  
this.join("plugin_tween");
}
...
HBUI_Point0.tween("x"1HBUI_Point0.xHBUI_Point0.50); 
The only thing is that you'll have to edit the class so that tween() is a public function so that it can be accessed by the object. Here it is:
PHP Code:
//#CLIENTSIDE
public function tween(valuetimeoldvalnewval) {
  
temp.dist newval oldval;
  
temp.step temp.dist time 0.05;
  
this.( @ value) = oldval;
  
this.trigger("TweenValue"valuetemp.stepnewval);
}

function 
onTweenValue(valuestepnewval) {
  
cancelEvents("TweenValue");
  if (
this.(@ value) == newval) return this.trigger("TweenFinished"value);
  
this.( @ value) += step;
  
scheduleEvent(0.05"TweenValue"valuestepnewval);

__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #13  
Old 07-04-2012, 10:11 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by DustyPorViva View Post
I don't think you need to join it to the specific object(in this case the control), but just to the script itself.
With Tig's, yeah, you do. Not the best way to do it in my opinion, clientside class joining on Graal is very touchy. Plus it can introduce issues with the class not being available immediately.
__________________
Reply With Quote
  #14  
Old 07-04-2012, 10:16 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by cbk1994 View Post
With Tig's, yeah, you do. Not the best way to do it in my opinion, clientside class joining on Graal is very touchy. Plus it can introduce issues with the class not being available immediately.
It works fine, and the class is available immediately. The only time I have problems is when I join a class to an object that's already been created, but in my example, it's being joined upon creation.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #15  
Old 07-04-2012, 10:21 PM
Alpho Alpho is offline
Registered User
Alpho's Avatar
Join Date: Dec 2011
Location: California, USA
Posts: 80
Alpho will become famous soon enough
Works perfectly Tig, Thank you so much.
Reply With Quote
  #16  
Old 07-04-2012, 11:03 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Tigairius View Post
It works fine, and the class is available immediately. The only time I have problems is when I join a class to an object that's already been created, but in my example, it's being joined upon creation.
Joining classes on clientside requires a round-trip to the server; it's not immediately available, although you can use it immediately (in v6). For example:

Class "test":
PHP Code:
//#CLIENTSIDE
public function test() {
  return 
"it works!";

Weapon "test":
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
temp.start timevar2;
  
  
temp.obj = new TStaticVar();
  
temp.obj.join("test");
  echo(
"result: " temp.obj.test());
  
  echo(
"total time: " @ (timevar2 temp.start));

On a low-latency network, the delay is generally tolerable:
Quote:
result: it works!
total time: 0.108752069
On an (artificially) high-latency network, however, it becomes a real problem:

Quote:
result: it works!
total time: 0.901618003
This can be very problematic depending on the situation: the best case is that nothing happens for a second, the worst is that the player's left with a half-drawn interface on the screen while the class is fetched.

And even worse, on v5:

Quote:
result: 0
total time: 0.000670057
v5 doesn't even wait for the class -- and 32% of Era is still using v5 right now.

An easy fix is to join the class serverside before joining it to any objects clientside:

PHP Code:
function onCreated() {
  
this.join("test");
}

//#CLIENTSIDE
function onCreated() {
  
temp.start timevar2;
  
  
temp.obj = new TStaticVar();
  
temp.obj.join("test");
  echo(
"result: " temp.obj.test());
  
  echo(
"total time: " @ (timevar2 temp.start));

Now your clientside class works on v5 and v6, and without waiting for the network .
__________________
Reply With Quote
  #17  
Old 07-04-2012, 11:11 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
I share Chris' experience with loading classes on clientside, and even had to write a work around for it:

PHP Code:
//#CLIENTSIDE
function onCreated()
{
//echo("Classes:" SPC player.joinedclasses);
//return;
  
temp.classList = {
    
"functions_buffs",
    
"functions_items",
    
"functions_messages",
    
"functions_misc",
    
"functions_stats",
    
"functions_skills",
    
"gui_initializer",
    
"gui_basics",
    
"gui_buff",
    
"gui_item",
    
"gui_skill",
    
"gui_spell",
    
"player_system",
    
//"quest_npc"
  
};
  
  for (
temp.classNametemp.classList) {
    
// Load the class to the player
    
if (!player.isInClass(temp.className))
      
player.join(temp.className);
    
    
// Maybe the class is loaded already?
    
if (isClassLoaded(temp.className))
      continue;
    
    
loadClass(temp.className);
    
    while (!
isClassLoaded(temp.className))
      
sleep(0.05);
  }
  
  
triggerServer("gui"this.name"initialized");

Causes a 1-5 second delay in our "login level" depending on your latency when you first login during the session, but it's worth not getting any errors because of classes not having loaded yet.
__________________
Follow my work on social media post-Graal:Updated august 2025.

Last edited by xXziroXx; 07-05-2012 at 07:02 PM..
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:23 AM.


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