Graal Forums

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

TheStan 08-03-2008 01:45 AM

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. :)

cbk1994 08-03-2008 01:53 AM

http://img70.imageshack.us/img70/714...ontrolssd6.png

I prefer Vesporia's system.

TheStan 08-03-2008 01:55 AM

Quote:

Originally Posted by cbk1994 (Post 1410979)

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:

cbk1994 08-03-2008 02:00 AM

Quote:

Originally Posted by TheStan (Post 1410980)
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 x_x)

LoneAngelIbesu 08-03-2008 02:09 AM

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. :p

Chompy 08-03-2008 02:13 AM

Quote:

Originally Posted by cbk1994 (Post 1410984)
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 x_x)

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...

TheStan 08-03-2008 02:17 AM

Quote:

Originally Posted by LoneAngelIbesu (Post 1410986)
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. :p

Thank you Dylan, even though you don't remember me. :(

Quote:

Originally Posted by Chompy (Post 1410989)
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.

cbk1994 08-03-2008 02:27 AM

Quote:

Originally Posted by Chompy (Post 1410989)
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".

LoneAngelIbesu 08-03-2008 02:53 AM

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. ^^

excaliber7388 08-03-2008 03:08 AM

Doesn't Graal already have a way to modify keys?...

cbk1994 08-03-2008 03:12 AM

Quote:

Originally Posted by excaliber7388 (Post 1411008)
Doesn't Graal already have a way to modify keys?...

Sorta, it's pretty limited.

Kristi 08-04-2008 08:41 PM

Quote:

Originally Posted by cbk1994 (Post 1410984)
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 x_x)

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

DustyPorViva 08-04-2008 08:46 PM

Quote:

Originally Posted by cbk1994 (Post 1410984)
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.

LoneAngelIbesu 08-04-2008 08:49 PM

It's because it's not 80% white space. :p

cbk1994 08-04-2008 11:01 PM

Quote:

Originally Posted by Kristi (Post 1411353)
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 (Post 1411356)
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 (Post 1411357)
It's because it's not 80[percent] white space. :p

I prefer code that isn't so crowded, yes.

xXziroXx 08-04-2008 11:12 PM

Quote:

Originally Posted by cbk1994 (Post 1411396)
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.

cbk1994 08-04-2008 11:17 PM

Quote:

Originally Posted by xXziroXx (Post 1411403)
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.

TheStan 08-07-2008 05:31 PM

Quote:

Originally Posted by Kristi (Post 1411353)
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

xXziroXx 08-07-2008 05:37 PM

Well, I'm with HR and Stan on this one - the styling is flawless. ;)

Skyld 08-07-2008 05:44 PM

Quote:

Originally Posted by xXziroXx (Post 1411403)
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.

cbk1994 08-07-2008 05:44 PM

Quote:

Originally Posted by xXziroXx (Post 1412173)
Well, I'm with HR and Stan on this one - the styling is flawless. ;)

If you say so. :whatever:

I've actually been changing my styling slightly recently :\

xXziroXx 08-07-2008 05:45 PM

Quote:

Originally Posted by Skyld (Post 1412176)
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. :cool:

zokemon 08-07-2008 09:49 PM

Quote:

Originally Posted by cbk1994 (Post 1411396)
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.

cbk1994 08-07-2008 09:59 PM

Quote:

Originally Posted by xXziroXx (Post 1412178)
True, but you're not going around bragging about it. :cool:

I wasn't bragging, I was saying why I don't release it.
Quote:

Originally Posted by zokemon (Post 1412262)
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.

xXziroXx 08-07-2008 10:11 PM

Quote:

Originally Posted by cbk1994 (Post 1412267)
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.

Kristi 08-07-2008 10:35 PM

Quote:

Originally Posted by cbk1994 (Post 1412267)
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.

cbk1994 08-07-2008 11:00 PM

Quote:

Originally Posted by xXziroXx (Post 1412272)
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 (Post 1412285)
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.


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

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