Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   New Emotions (https://forums.graalonline.com/forums/showthread.php?t=82254)

Clockwork 10-10-2008 09:04 PM

New Emotions
 
1 Attachment(s)
Script that will replace the old emotions with new ones! :O
Made awhile ago, but decided to release it... (I don't like the old ones x.x; )

But yea, credits to Dusty, chompy and myself. o_O..


PHP Code:

//#CLIENTSIDE

function onCreated() {
  
enablefeatures(allfeatures-0x1000);
  
this.emote_timer 0;
  
setTimer(0.05);
}

function 
GraalControl.onKeyDown(keymodcharkeynumber) {
  if (
keymod == 577){ this.emote "aeko-crtl_a.gif";} else
  if (
keymod == 578){ this.emote "aeko-crtl_b.gif";} else
  if (
keymod == 579){ this.emote "aeko-crtl_c.png";} else
  if (
keymod == 580){ this.emote "aeko-crtl_d.png";} else
  if (
keymod == 581){ this.emote "aeko-crtl_e.gif";} else
  if (
keymod == 582){ this.emote "aeko-crtl_f.png";} else
  if (
keymod == 583){ this.emote "aeko-crtl_g.png";} else
  if (
keymod == 584){ this.emote "aeko-crtl_h.png";} else
  if (
keymod == 585){ this.emote "aeko-crtl_i.gif";} else
  if (
keymod == 586){ this.emote "aeko-crtl_j.gif";} else
  if (
keymod == 587){ this.emote "aeko-crtl_k.png";} else
  if (
keymod == 588){ this.emote "aeko-crtl_l.gif";} else
  if (
keymod == 589){ this.emote "aeko-crtl_m.png";} else
  if (
keymod == 590){ this.emote "aeko-crtl_n.gif";} else
  if (
keymod == 591){ this.emote "aeko-crtl_o.png";} else
  if (
keymod == 592){ this.emote "aeko-crtl_p.png";} else
  if (
keymod == 593){ this.emote "aeko-crtl_q.png";} else
  if (
keymod == 594){ this.emote "aeko-crtl_r.gif";} else
  if (
keymod == 595){ this.emote "aeko-crtl_s.png";} else
  if (
keymod == 596){ this.emote "aeko-crtl_t.png";} else
  if (
keymod == 597){ this.emote "aeko-crtl_u.png";} else
  if (
keymod == 598){ this.emote "aeko-crtl_v.png";} else
  if (
keymod == 599){ this.emote "aeko-crtl_w.png";} else
  if (
keymod == 600){ this.emote "aeko-crtl_x.png";} else
  if (
keymod == 601){ this.emote "aeko-crtl_y.png";} else
  if (
keymod == 602){ this.emote "aeko-crtl_z.gif";} else
  {
this.emote "None";}
  
  if (
this.emote != "None") {
    
this.emote_timer 6;
    
showimg(1this.emoteplayer.1.5player.1.5);
    
changeimgMode(11);
    
changeimgVis(13);
    
changeimgColors(1111.65); 
  }  
}
function 
onTimeout() {
  if (!
this.emote.ends("gif")) {
    if (
this.emote_timer >= 0.1) {
      
this.emote_timer -= 0.05;
    }else if (
this.emote_timer 0.1) {
      
hideimg(1);
    }
  }
  
with(findimg(1)) {
    if (
!= player.1.5 || != player.1.5) {
      
hideimg(1);
    }
  }
  
setTimer(0.05);


I think that's it...
Attached the images in a .zip

Chompy 10-10-2008 09:12 PM

Hmm, I just realized that the Timeout event could of been different, so it don't have to run the loop all the time, but instead only do it when you actually do an emote..

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
enablefeatures(allfeatures-0x1000);
  
this.emote_timer 0;
}

function 
GraalControl.onKeyDown(keymodcharkeynumber) {
  if (
keymod == 577){ this.emote "aeko-crtl_a.gif";} else
  if (
keymod == 578){ this.emote "aeko-crtl_b.gif";} else
  if (
keymod == 579){ this.emote "aeko-crtl_c.png";} else
  if (
keymod == 580){ this.emote "aeko-crtl_d.png";} else
  if (
keymod == 581){ this.emote "aeko-crtl_e.gif";} else
  if (
keymod == 582){ this.emote "aeko-crtl_f.png";} else
  if (
keymod == 583){ this.emote "aeko-crtl_g.png";} else
  if (
keymod == 584){ this.emote "aeko-crtl_h.png";} else
  if (
keymod == 585){ this.emote "aeko-crtl_i.gif";} else
  if (
keymod == 586){ this.emote "aeko-crtl_j.gif";} else
  if (
keymod == 587){ this.emote "aeko-crtl_k.png";} else
  if (
keymod == 588){ this.emote "aeko-crtl_l.gif";} else
  if (
keymod == 589){ this.emote "aeko-crtl_m.png";} else
  if (
keymod == 590){ this.emote "aeko-crtl_n.gif";} else
  if (
keymod == 591){ this.emote "aeko-crtl_o.png";} else
  if (
keymod == 592){ this.emote "aeko-crtl_p.png";} else
  if (
keymod == 593){ this.emote "aeko-crtl_q.png";} else
  if (
keymod == 594){ this.emote "aeko-crtl_r.gif";} else
  if (
keymod == 595){ this.emote "aeko-crtl_s.png";} else
  if (
keymod == 596){ this.emote "aeko-crtl_t.png";} else
  if (
keymod == 597){ this.emote "aeko-crtl_u.png";} else
  if (
keymod == 598){ this.emote "aeko-crtl_v.png";} else
  if (
keymod == 599){ this.emote "aeko-crtl_w.png";} else
  if (
keymod == 600){ this.emote "aeko-crtl_x.png";} else
  if (
keymod == 601){ this.emote "aeko-crtl_y.png";} else
  if (
keymod == 602){ this.emote "aeko-crtl_z.gif";} else
  {
this.emote "None";}
  
  if (
this.emote != "None") {
    
this.emote_timer 6;
    
showimg(1this.emoteplayer.1.5player.1.5);
    
changeimgMode(11);
    
changeimgVis(13);
    
changeimgColors(1111.65);
    
setTimer(0.05);
  }  
}
function 
onTimeout() {
  if (!
this.emote.ends("gif")) {
    if (
this.emote_timer 0) {
      
this.emote_timer -= 0.05;
    }
    if (
this.emote_timer <= 0) {
      
hideimg(1);
    }
  }
  
with(findimg(1)) {
    if (
!= player.1.5 || != player.1.5) {
      
hideimg(1);
      
this.emote_timer 0;
    }
  }
  if (
this.emote_timer 0)
    
setTimer(0.05);


But, nice release Aeko :D
Have to spread some reputation before I can give to you :o

DustyPorViva 10-10-2008 09:16 PM

lol, I get credits for the enablefeatures line?

Anyways, got rid of the nesting and replaced it with an array:
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
this.keymaps = {
    
577,"aeko-crtl_a.gif",
    
578,"aeko-crtl_b.gif",
    
579,"aeko-crtl_c.png",
    
580,"aeko-crtl_d.png",
    
581,"aeko-crtl_e.gif",
    
582,"aeko-crtl_f.png",
    
583,"aeko-crtl_g.png",
    
584,"aeko-crtl_h.png",
    
585,"aeko-crtl_i.gif",
    
586,"aeko-crtl_j.gif",
    
587,"aeko-crtl_k.png",
    
588,"aeko-crtl_l.gif",
    
589,"aeko-crtl_m.png",
    
590,"aeko-crtl_n.gif",
    
591,"aeko-crtl_o.png",
    
592,"aeko-crtl_p.png",
    
593,"aeko-crtl_q.png",
    
594,"aeko-crtl_r.gif",
    
595,"aeko-crtl_s.png",
    
596,"aeko-crtl_t.png",
    
597,"aeko-crtl_u.png",
    
598,"aeko-crtl_v.png",
    
599,"aeko-crtl_w.png",
    
600,"aeko-crtl_x.png",
    
601,"aeko-crtl_y.png",
    
602,"aeko-crtl_z.gif",
  };

  
enablefeatures(allfeatures-0x1000);
  
this.emote_timer 0;
  
setTimer(0.05);
}

function 
GraalControl.onKeyDown(keymodcharkeynumber) {
  
Customize();
  if (
keymod in this.keymapsthis.emote this.keymaps[this.keymaps.index(keymod)+1];
  else 
this.emote "None";
  
  if (
this.emote != "None") {
    
this.emote_timer 6;
    
showimg(1this.emoteplayer.1.5player.1.5);
    
changeimgMode(11);
    
changeimgVis(13);
    
changeimgColors(1111.65); 
  }  
}
function 
onTimeout() {
  if (!
this.emote.ends("gif")) {
    if (
this.emote_timer >= 0.1) {
      
this.emote_timer -= 0.05;
    }else if (
this.emote_timer 0.1) {
      
hideimg(1);
    }
  }
  
with(findimg(1)) {
    if (
!= player.1.5 || != player.1.5) {
      
hideimg(1);
    }
  }
  
setTimer(0.05);


I could have done it with subarrays, which would have looked a lot more organized and sensible, but that would have involved loop checks and all since you can't use .index for checking subarrays. This reminds me of GS1's make-shift subarrays :P

Tolnaftate2004 10-10-2008 10:01 PM

PHP Code:

  temp.keymaps = {
    
"aeko-crtl_a.gif",
    
"aeko-crtl_b.gif",
    
"aeko-crtl_c.png",
    
etc.
  }; 

Then the index you want is keymod-577, 576<keymod<603. Then there's no searching and no cacading else-ifs.
On top of that, you don't need the "aeko-crtl_" in every line, just put it in the showimg.


And since when did the r come before the t in control (ctrl)? :)

DustyPorViva 10-10-2008 10:04 PM

I'm really not following where you're getting at, heh.

Clockwork 10-10-2008 10:05 PM

Quote:

Originally Posted by Tolnaftate2004 (Post 1431457)
And since when did the r come before the t in control (ctrl)? :)

awe, yea... I always say "circle" instead of control..so...>>;

Tolnaftate2004 10-10-2008 10:19 PM

Quote:

Originally Posted by DustyPorViva (Post 1431461)
I'm really not following where you're getting at, heh.

PHP Code:

this.emote = (keymod in |577,602|)?this.keymap[keymod-577]:"None"

1 evaluation, order unity runtime.
vs.
PHP Code:

if (keymod in this.keymapsthis.emote this.keymaps[this.keymaps.index(keymod)+1];
else 
this.emote "None"

1 evaluation, linear runtime. This would take on average more than 13.5 evaluations. (compare below).
vs. (on average 13.5) if/elseif/else statements:
1-27 evaluations, each of order unity runtime.

Quote:

Originally Posted by Clockwork (Post 1431463)
awe, yea... I always say "circle" instead of control..so...>>;

There's no t in circle, silly. :p

DustyPorViva 10-10-2008 10:22 PM

Quote:

Originally Posted by Tolnaftate2004 (Post 1431470)
PHP Code:

this.emote = (keymod in |577,602|)?this.keymap[keymod-577]:"None"

1 evaluation, order unity runtime.

I thought of that, but I wanted to leave the possibility open for emotes that may not fit in the order already there.

Tolnaftate2004 10-10-2008 10:25 PM

Quote:

Originally Posted by DustyPorViva (Post 1431471)
I thought of that, but I wanted to leave the possibility open for emotes that may not fit in the order already there.

You can also have another array that maps keymod -> keymap index (in other words this.keymap[this.keyfunc[keymod]]). Allows for such things and it still doesn't need to search. :)

xXziroXx 10-10-2008 11:52 PM

That's some ****ed up stying in the first script :megaeek:

DarkReaper0 10-11-2008 12:08 AM

I have nothing to really say about the script (There's hundreds of ways to do it).

But I absolutely love the emoticons you provided.

Clockwork 10-11-2008 01:44 AM

lol, thanks I guess ^^;

xfazex 02-26-2009 07:07 AM

This doesn't work for me for some reason, put the images in the emotions folder, and put the NPC script in the level, and nothing. (Using Graal Editor)

[email protected] 02-26-2009 07:13 PM

This is GS2, all of the scripts in the code gallery are GS2. They won't work offline, you'll need a server.

xfazex 02-26-2009 09:08 PM

Yeah I have one, I figured that out. lol


All times are GMT +2. The time now is 01:20 PM.

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