Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-22-2011, 03:04 AM
furry_mougle furry_mougle is offline
big heart
furry_mougle's Avatar
Join Date: Aug 2011
Posts: 42
furry_mougle is an unknown quantity at this point
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") @ "!";

__________________
Quote:
Originally Posted by ffcmike View Post
But make sure to change beer.png to Orange Juice.
pay bills to play graal

Last edited by furry_mougle; 09-22-2011 at 01:49 PM..
Reply With Quote
  #2  
Old 09-22-2011, 03:06 AM
oralgnome oralgnome is offline
doesnt afraid of anything
oralgnome's Avatar
Join Date: Sep 2011
Posts: 34
oralgnome is an unknown quantity at this point
<insert trolling post here>
__________________
Quote:
Originally Posted by CaySedaiSim View Post
Is there a GS2 for retards book..?

Last edited by oralgnome; 09-22-2011 at 01:32 PM..
Reply With Quote
  #3  
Old 09-22-2011, 03:32 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
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") @ "!";

__________________

Last edited by cbk1994; 09-22-2011 at 03:52 AM..
Reply With Quote
  #4  
Old 09-22-2011, 03:36 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Weird that onTextChanged works for GuiTextEditCtrl's and not GuiMLTextEditCtrl's.

@cbk: Typo in ChatBar.
__________________
Quote:
Reply With Quote
  #5  
Old 09-22-2011, 04:15 AM
oralgnome oralgnome is offline
doesnt afraid of anything
oralgnome's Avatar
Join Date: Sep 2011
Posts: 34
oralgnome is an unknown quantity at this point
Quote:
Originally Posted by cbk1994 View Post
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.
__________________
Quote:
Originally Posted by CaySedaiSim View Post
Is there a GS2 for retards book..?

Last edited by oralgnome; 09-22-2011 at 04:36 AM..
Reply With Quote
  #6  
Old 09-22-2011, 04:48 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by oralgnome View Post
EDIT: In other words, there's more than one way to bake a cake.
It's the better way to bake this specific cake.
__________________
Quote:
Reply With Quote
  #7  
Old 09-22-2011, 05:41 AM
oralgnome oralgnome is offline
doesnt afraid of anything
oralgnome's Avatar
Join Date: Sep 2011
Posts: 34
oralgnome is an unknown quantity at this point
Quote:
Originally Posted by fowlplay4 View Post
It's the better way to bake this specific cake.
How so, it does the same thing - right?
__________________
Quote:
Originally Posted by CaySedaiSim View Post
Is there a GS2 for retards book..?
Reply With Quote
  #8  
Old 09-22-2011, 05:47 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
Quote:
Originally Posted by oralgnome View Post
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.
Reply With Quote
  #9  
Old 09-22-2011, 05:59 AM
gaben gaben is offline
uhh no
gaben's Avatar
Join Date: Aug 2011
Posts: 47
gaben is an unknown quantity at this point
Quote:
Originally Posted by DustyPorViva View Post
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.
__________________
Quote:
Originally Posted by iBeatz View Post
Who came up with this Cheat Engine? The more I read about, the more ingenious the whole thing sounds.
Quote:
Originally Posted by Unixmad
This forums is going worst each day.
Quote:
Originally Posted by ff7chocoboknight View Post
You sure are taking your time leaving, furry.
Quote:
Originally Posted by [email protected] View Post
are u old enough 2 even play Graal little girl???
Reply With Quote
  #10  
Old 09-22-2011, 06:07 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by oralgnome View Post
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 View Post
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!";
  }

__________________
Quote:
Reply With Quote
  #11  
Old 09-22-2011, 06:12 AM
oralgnome oralgnome is offline
doesnt afraid of anything
oralgnome's Avatar
Join Date: Sep 2011
Posts: 34
oralgnome is an unknown quantity at this point
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).
__________________
Quote:
Originally Posted by CaySedaiSim View Post
Is there a GS2 for retards book..?
Reply With Quote
  #12  
Old 09-22-2011, 06:16 AM
Dragon551 Dragon551 is offline
Alfonso :3
Dragon551's Avatar
Join Date: Mar 2006
Location: In a pocket.
Posts: 712
Dragon551 is a splendid one to beholdDragon551 is a splendid one to beholdDragon551 is a splendid one to beholdDragon551 is a splendid one to beholdDragon551 is a splendid one to behold
Send a message via AIM to Dragon551 Send a message via MSN to Dragon551
Quote:
Originally Posted by oralgnome View Post
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
__________________
-Alfonso (AGT)


---------------------
---------------------
#AGT
Reply With Quote
  #13  
Old 09-22-2011, 06:16 AM
oralgnome oralgnome is offline
doesnt afraid of anything
oralgnome's Avatar
Join Date: Sep 2011
Posts: 34
oralgnome is an unknown quantity at this point
Quote:
Originally Posted by Dragon551 View Post
Quick question, totally irreleveant, but what's with the 3 accounts? O.o
__________________
Quote:
Originally Posted by CaySedaiSim View Post
Is there a GS2 for retards book..?

Last edited by oralgnome; 09-22-2011 at 06:18 AM.. Reason: This thread has officially gone to ****.
Reply With Quote
  #14  
Old 09-22-2011, 06:20 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
"Trolling" in a forum with many scripters who's primary intention is to help, yet we are the overgrown man-children. Hmm.
__________________
Quote:
Reply With Quote
  #15  
Old 09-22-2011, 06:22 AM
oralgnome oralgnome is offline
doesnt afraid of anything
oralgnome's Avatar
Join Date: Sep 2011
Posts: 34
oralgnome is an unknown quantity at this point
Quote:
Originally Posted by fowlplay4 View Post
"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.
__________________
Quote:
Originally Posted by CaySedaiSim View Post
Is there a GS2 for retards book..?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 11:51 PM.


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