Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-03-2008, 01:45 AM
TheStan TheStan is offline
Stan?
Join Date: May 2008
Location: U.S.
Posts: 100
TheStan is on a distinguished road
Send a message via AIM to TheStan Send a message via MSN to TheStan
Custom Keys

PHP Code:
//#CLIENTSIDE
function onCreated() {
  if (!
client.keyupdate) {
    
setkeys();
  }
}
function 
onPlayerChats() {
  
temp.toks null;
  
  
toks player.chat.tokenize();
  if (
toks[0].starts("/")) {
    if (
toks[0].substring(1).length() == 1) {
      if (
toks[1].length() == 1) {
        
setNewKey(toks[0].substring(1), toks[1]);
      }
    }
    else {
      if (
toks[0].substring(1) == "fixkeys") {
        
fixKeys();
      }
    }
  }
}
public function 
setkeys() {
  
temp.key null;
  
temp.out null;
  
  
temp.keys = {
    {
"a""a"},
    {
"b""b"},
    {
"c""c"},
    {
"d""d"},
    {
"e""e"},
    {
"f""f"},
    {
"g""g"},
    {
"h""h"},
    {
"i""i"},
    {
"j""j"},
    {
"k""k"},
    {
"l""l"},
    {
"m""m"},
    {
"n""n"},
    {
"o""o"},
    {
"p""p"},
    {
"q""q"},
    {
"r""r"},
    {
"s""s"},
    {
"t""t"},
    {
"u""u"},
    {
"v""v"},
    {
"w""w"},
    {
"x""x"},
    {
"y""y"},
    {
"z""z"}
  };
  for (
keykeys) {
    
out @= (key[0] @ key[1]);
  }
  
client.keys out;
  
client.keyupdate true;
}
public function 
getSetKey(skey) {
  
temp.key null;
  
  for (
keyclient.keys) {
    if (
key[0] == skey) {
      return 
key[1];
    }
  }
}
public function 
setNewKey(oldkeynewkey) {
  
temp.key null;

  for (
keyclient.keys) {
    if (
key[0] == oldkey) {
      
key[1] = newkey;
    }
    if (
key[0] == newkey) {
      
key[1] = oldkey;
    }
  }
}
public function 
fixKeys() {
  
temp.key null;
  
  for (
keyclient.keys) {
    if (
key[0] == null) {
      
client.keys.delete(this.keys.index(key));
    }
    
key[0] = lowercase(key[0]);
    
key[1] = lowercase(key[0]);
  }
  if (
client.keys.size() != 26) {
    
setkeys();
  }
}
function 
onKeyPressed(codekey) {
  switch(
key) {
    case 
getSetKey("q"): // inventory
      /* Toggle inventory here, for example
        Inventory.toggle();
        
        Inventory having toggle()
        as a public function */
    
break;
  }

Not too long ago someone made a thread about having a static list of keys to be replaced etc., if for example you wanted custom keys. I believe the person who made the thread was Rufus.

I tried to replicate that with this, except this is more for player-to-player configuration if each individual player wanted to have his or her own custom keys.

Example being, if you wanted s to do the q functions etc. Pretty much, this is for player comfortability. If it doesn't work properly let me know so I can do some fixing etc.
Reply With Quote
  #2  
Old 08-03-2008, 01:53 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


I prefer Vesporia's system.
__________________
Reply With Quote
  #3  
Old 08-03-2008, 01:55 AM
TheStan TheStan is offline
Stan?
Join Date: May 2008
Location: U.S.
Posts: 100
TheStan is on a distinguished road
Send a message via AIM to TheStan Send a message via MSN to TheStan
Quote:
Originally Posted by cbk1994 View Post


I prefer Vesporia's system.
I didn't make a complete configuration system. :P I probably will later etc., but I just wanted to make player custom keys Chris! D:
Reply With Quote
  #4  
Old 08-03-2008, 02:00 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 TheStan View Post
I didn't make a complete configuration system. :P I probably will later etc., but I just wanted to make player custom keys Chris! D:
I'll go ahead and mention I don't like your code at all; it is over complicating things, plus you can't really assign individual keys to each action.

I guess it isn't so much your code, which is okay if you like that styling ... I just don't like the way you did it. Players aren't going to want to assign 'D' to 'F', they want to assign 'Fire Weapon' to 'F' (though, who would change that one )
__________________
Reply With Quote
  #5  
Old 08-03-2008, 02:09 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
The script is to show how to assign keys to something, not to provide a pre-made, all-inclusive macro system. A little bit of editing, and you can do what Vesporia does.

Also, his styling is impeccable.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #6  
Old 08-03-2008, 02:13 AM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by cbk1994 View Post
I'll go ahead and mention I don't like your code at all; it is over complicating things, plus you can't really assign individual keys to each action.

I guess it isn't so much your code, which is okay if you like that styling ... I just don't like the way you did it. Players aren't going to want to assign 'D' to 'F', they want to assign 'Fire Weapon' to 'F' (though, who would change that one )
Why are you so negative? It's a simple script, to suppose to be any advanced at this state. Sure, Stan might redo it later or something.

Also, when did the Code Gallery become a place where code submitted are analyzed...
__________________
Reply With Quote
  #7  
Old 08-03-2008, 02:17 AM
TheStan TheStan is offline
Stan?
Join Date: May 2008
Location: U.S.
Posts: 100
TheStan is on a distinguished road
Send a message via AIM to TheStan Send a message via MSN to TheStan
Quote:
Originally Posted by LoneAngelIbesu View Post
The script is to show how to assign keys to something, not to provide a pre-made, all-inclusive macro system. A little bit of editing, and you can do what Vesporia does.

Also, his styling is impeccable.
Thank you Dylan, even though you don't remember me.

Quote:
Originally Posted by Chompy View Post
Why are you so negative? It's a simple script, to suppose to be any advanced at this state. Sure, Stan might redo it later or something.

Also, when did the Code Gallery become a place where code submitted are analyzed...
Ah, thanks Chomp.
Reply With Quote
  #8  
Old 08-03-2008, 02:27 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 Chompy View Post
Why are you so negative? It's a simple script, to suppose to be any advanced at this state. Sure, Stan might redo it later or something.
I'm not being negative; sorry if it came off that way.

I told him why I don't like the code, and gave him an example of what he could improve.

Quote:
Also, when did the Code Gallery become a place where code submitted are analyzed...
There's nothing wrong with saying "I don't like this, I recommend something like this".
__________________
Reply With Quote
  #9  
Old 08-03-2008, 02:53 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Rule of thumb: if you're suggesting how they could make their code better, then make sure you aren't suggesting to make something completely different. Unless they ask you to, of course.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #10  
Old 08-03-2008, 03:08 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Doesn't Graal already have a way to modify keys?...
Reply With Quote
  #11  
Old 08-03-2008, 03:12 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 excaliber7388 View Post
Doesn't Graal already have a way to modify keys?...
Sorta, it's pretty limited.
__________________
Reply With Quote
  #12  
Old 08-04-2008, 08:41 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by cbk1994 View Post
I'll go ahead and mention I don't like your code at all; it is over complicating things, plus you can't really assign individual keys to each action.

I guess it isn't so much your code, which is okay if you like that styling ... I just don't like the way you did it. Players aren't going to want to assign 'D' to 'F', they want to assign 'Fire Weapon' to 'F' (though, who would change that one )
The difference is he actually put out code for others to look at, and you didn't. Keep your negativity out of the NPC section. His script can assign D to F. It is irrelevant if players want to do it or not.

PS: His styling is awesome
__________________
Reply With Quote
  #13  
Old 08-04-2008, 08:46 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
Quote:
Originally Posted by cbk1994 View Post
I guess it isn't so much your code, which is okay if you like that styling
Styling seems fine to me... it's pretty standard(editor uses that format), and the way I do it. What's so bad about it? I've seen much worse around these forums.
Reply With Quote
  #14  
Old 08-04-2008, 08:49 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
It's because it's not 80% white space.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #15  
Old 08-04-2008, 11:01 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 Kristi View Post
The difference is he actually put out code for others to look at, and you didn't. Keep your negativity out of the NPC section. His script can assign D to F. It is irrelevant if players want to do it or not.
The way I script things for Vesporia, they would not work copy 'n pasted onto other servers.

What I was talking about is you are changing your keys around, not changing what keys do what. Though perhaps that's what he was aiming for?
Quote:
PS: His styling is awesome
I disagree.
Quote:
Originally Posted by DustyPorViva View Post
Styling seems fine to me... it's pretty standard(editor uses that format), and the way I do it. What's so bad about it? I've seen much worse around these forums.
It's fine to you, so the actual code is okay, like I said. I style my code differently, and I hate that style.
Quote:
Originally Posted by LoneAngelIbesu View Post
It's because it's not 80[percent] white space.
I prefer code that isn't so crowded, yes.
__________________
Reply With Quote
  #16  
Old 08-04-2008, 11:12 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
Quote:
Originally Posted by cbk1994 View Post
The way I script things for Vesporia, they would not work copy 'n pasted onto other servers.
Brag more, will ya? I'm not even sure that's a good thing.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #17  
Old 08-04-2008, 11:17 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 xXziroXx View Post
Brag more, will ya? I'm not even sure that's a good thing.
I'm not bragging; I'm telling him why I don't release most stuff I make for Vesporia. It's not really a "good" thing, but it's not a bad thing either, since I wouldn't release it anyway.
__________________
Reply With Quote
  #18  
Old 08-07-2008, 05:31 PM
TheStan TheStan is offline
Stan?
Join Date: May 2008
Location: U.S.
Posts: 100
TheStan is on a distinguished road
Send a message via AIM to TheStan Send a message via MSN to TheStan
Quote:
Originally Posted by Kristi View Post
The difference is he actually put out code for others to look at, and you didn't. Keep your negativity out of the NPC section. His script can assign D to F. It is irrelevant if players want to do it or not.

PS: His styling is awesome
Thanks. Learned from one of the best! <3
Reply With Quote
  #19  
Old 08-07-2008, 05:37 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
Well, I'm with HR and Stan on this one - the styling is flawless.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #20  
Old 08-07-2008, 05:44 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by xXziroXx View Post
Brag more, will ya? I'm not even sure that's a good thing.
It's not exactly a bad thing, either. A lot of my Rudora code would probably not work on other servers without copying over other classes or snippets of code. I have a lot of custom functions - that does not make it bad.
Reply With Quote
  #21  
Old 08-07-2008, 05:44 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 xXziroXx View Post
Well, I'm with HR and Stan on this one - the styling is flawless.
If you say so.

I've actually been changing my styling slightly recently
__________________
Reply With Quote
  #22  
Old 08-07-2008, 05:45 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
Quote:
Originally Posted by Skyld View Post
It's not exactly a bad thing, either. A lot of my Rudora code would probably not work on other servers without copying over other classes or snippets of code. I have a lot of custom functions - that does not make it bad.
True, but you're not going around bragging about it.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #23  
Old 08-07-2008, 09:49 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by cbk1994 View Post
I prefer code that isn't so crowded, yes.
More whitespace means more scrolling to read large amounts of data. I prefer to be able to see everything I want without having to scroll 5 million pages down.
__________________
Do it with a DON!
Reply With Quote
  #24  
Old 08-07-2008, 09:59 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 xXziroXx View Post
True, but you're not going around bragging about it.
I wasn't bragging, I was saying why I don't release it.
Quote:
Originally Posted by zokemon View Post
More whitespace means more scrolling to read large amounts of data. I prefer to be able to see everything I want without having to scroll 5 million pages down.
I prefer code that's easier to read. Some find other code easier to read. I don't know why we're debating this.
__________________
Reply With Quote
  #25  
Old 08-07-2008, 10: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
Quote:
Originally Posted by cbk1994 View Post
I wasn't bragging, I was saying why I don't release it.
Whatever you say, that's how it came out though, and I've gotten the same feeling from several of your other posts.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #26  
Old 08-07-2008, 10:35 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by cbk1994 View Post
I prefer code that's easier to read. Some find other code easier to read. I don't know why we're debating this.
Because you started it when you put down stan's style is why. How soon we forget.
__________________
Reply With Quote
  #27  
Old 08-07-2008, 11:00 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 xXziroXx View Post
Whatever you say, that's how it came out though, and I've gotten the same feeling from several of your other posts.
Sorry then, I didn't mean to brag

Quote:
Originally Posted by Kristi View Post
Because you started it when you put down stan's style is why. How soon we forget.
"which is okay if you like that styling"

I didn't put it down.
__________________
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 08:58 PM.


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