Graal Forums

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

furry_mougle 09-22-2011 03:04 AM

Typewriter
 
Feel free to critique, not sure if it's "code" gallery material (probably not, but might be interesting to have up regardless) . I haven't seen a typewriter script up yet though. Pretty much the same thing on UN (not leeched though).

PHP Code:

//#CLIENTSIDE
function onKeyPressed(code) {
  if (
keydown(8) || temp.code == && this.on){
   
setTimer(0.05); // checking if pressed && looping
  
} else {
   
setTimer(0);
  }
}

function 
onTimeout() {
  if (
ChatBar.visible && this.on) { // if chatbar visible && on
   
temp.text ChatBar.text// define var
    
if (temp.text != null) {
     
player.chat temp.text// send player.chat directly, looping
    
}
  
setTimer(0.05);
  }
}

function 
onWeaponFired(){ 
  if (!
this.on){  
    
this.on true;
    
player.chat "Typewriter on!"// aesthetics 
  
}else if(this.on){
    
this.on false;
    
player.chat "Typewriter off!";
  }


EDIT: Oops, was looping for no real good reason.

PHP Code:

//#CLIENTSIDE
function ChatBar.onTextChanged(temp.text) {
  if (
this.on) {
    
player.chat temp.text;
  }
}

function 
onWeaponFired(){ 
  
this.on = ! this.on;
  
player.chat "Typewriter " @ (this.on "on" "off") @ "!";



oralgnome 09-22-2011 03:06 AM

<insert trolling post here>

cbk1994 09-22-2011 03:32 AM

Why not just do this?

PHP Code:

//#CLIENTSIDE
function ChatBar.onTextChanged(temp.text) {
  if (
this.on) {
    
player.chat temp.text;
  }
}

function 
onWeaponFired(){ 
  
this.on = ! this.on;
  
player.chat "Typewriter " @ (this.on "on" "off") @ "!";



fowlplay4 09-22-2011 03:36 AM

Weird that onTextChanged works for GuiTextEditCtrl's and not GuiMLTextEditCtrl's.

@cbk: Typo in ChatBar.

oralgnome 09-22-2011 04:15 AM

Quote:

Originally Posted by cbk1994 (Post 1668803)
Why not just do this?

PHP Code:

//#CLIENTSIDE
function ChatBar.onTextChanged(temp.text) {
  if (
this.on) {
    
player.chat temp.text;
  }
}

function 
onWeaponFired(){ 
  
this.on = ! this.on;
  
player.chat "Typewriter " @ (this.on "on" "off") @ "!";



EDIT: In other words, there's more than one way to bake a cake.

fowlplay4 09-22-2011 04:48 AM

Quote:

Originally Posted by oralgnome (Post 1668811)
EDIT: In other words, there's more than one way to bake a cake.

It's the better way to bake this specific cake.

oralgnome 09-22-2011 05:41 AM

Quote:

Originally Posted by fowlplay4 (Post 1668812)
It's the better way to bake this specific cake.

How so, it does the same thing - right?

DustyPorViva 09-22-2011 05:47 AM

Quote:

Originally Posted by oralgnome (Post 1668819)
How so, it does the same thing - right?

Just because the end product is the same doesn't mean it's just as good. If you can't compare the OP script to Chris' and tell why one is better than the other than you need to rethink your position as a scripter.

gaben 09-22-2011 05:59 AM

Quote:

Originally Posted by DustyPorViva (Post 1668820)
Just because the end product is the same doesn't mean it's just as good. If you can't compare the OP script to Chris' and tell why one is better than the other than you need to rethink your position as a scripter.

He never said it was 'just as good', he just doesn't see why it would be perceived as better at face value. I'm sure that's a safe assumption - and you have no right to determine what their position as a 'scripter' is. (Sorry, but it's true!)

Regardless of all this /e/drama, this.bool = !this.bool is a unique way of performing toggling and I can see how one would perceive it as somewhat 'better'. Though, in the end, the one that ends up playing second fiddle is the one that attempts to distinguish oneself' in the face of others.

fowlplay4 09-22-2011 06:07 AM

Quote:

Originally Posted by oralgnome (Post 1668819)
How so, it does the same thing - right?

It uses a single event to detect change in text rather than a hack to detect it which simplifies the code significantly and is much easier to read and understand.

Quote:

Originally Posted by gaben (Post 1668822)
Regardless, this.bool = !this.bool is a unique way of performing toggling and I can see how one would perceive it as somewhat 'better'. Though, in the end, the one that ends up playing second fiddle is the one that attempts to distinguish oneself' in the face of others.

That is irrelevant in my reasoning as to why I think it's 'better'. I would have considered writing the "toggle" like this since it's easier for new scripters to understand:

PHP Code:

//#CLIENTSIDE
function onWeaponFired() {
  if (
this.on) {
    
this.on false;
    
player.chat "Typewriter off!";
  } else {
    
this.on true;
    
player.chat "Typewriter on!";
  }



oralgnome 09-22-2011 06:12 AM

I do realize it is generally more efficient, and I admit, I hadn't even thought of the this.bool toggling; (my excuse is that I wrote it in 35 seconds).

Erupting flamewars only makes you look like overgrown manchildren (especially over syntax lol).

Dragon551 09-22-2011 06:16 AM

Quote:

Originally Posted by oralgnome (Post 1668825)
I do realize it is generally more efficient, and I admit, I hadn't even thought of the this.bool toggling; (my excuse is that I wrote it in 35 seconds).

Erupting flamewars only makes you look like overgrown manchildren.

Quick question, totally irreleveant, but what's with the 3 accounts? O.o

oralgnome 09-22-2011 06:16 AM

Quote:

Originally Posted by Dragon551 (Post 1668827)
Quick question, totally irreleveant, but what's with the 3 accounts? O.o

http://t1.gstatic.com/images?q=tbn:A...ZSUiB_zuSpfVOg

fowlplay4 09-22-2011 06:20 AM

"Trolling" in a forum with many scripters who's primary intention is to help, yet we are the overgrown man-children. Hmm.

oralgnome 09-22-2011 06:22 AM

Quote:

Originally Posted by fowlplay4 (Post 1668829)
"Trolling" in a forum with many scripters who's primary intention is to help, yet we are the overgrown man-children. Hmm.

Who said I was trolling?

Anyway, time go to crawl back into the crevice in which I came. You can only do so much to help others in this life. Ultimately, death will conquer us all.


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

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