PDA

View Full Version : Custom Keys


TheStan
08-03-2008, 01:45 AM
//#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 (key: keys) {
out @= (key[0] @ key[1]);
}
client.keys = out;
client.keyupdate = true;
}
public function getSetKey(skey) {
temp.key = null;

for (key: client.keys) {
if (key[0] == skey) {
return key[1];
}
}
}
public function setNewKey(oldkey, newkey) {
temp.key = null;

for (key: client.keys) {
if (key[0] == oldkey) {
key[1] = newkey;
}
if (key[0] == newkey) {
key[1] = oldkey;
}
}
}
public function fixKeys() {
temp.key = null;

for (key: client.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(code, key) {
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/7144/1maincontrolssd6.png

I prefer Vesporia's system.

TheStan
08-03-2008, 01:55 AM
http://img70.imageshack.us/img70/7144/1maincontrolssd6.png

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:

cbk1994
08-03-2008, 02:00 AM
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
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
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. :(

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

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
Doesn't Graal already have a way to modify keys?...

Sorta, it's pretty limited.

Kristi
08-04-2008, 08:41 PM
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
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
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?

PS: His styling is awesome
I disagree.
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.
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
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
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
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
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
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
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
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
True, but you're not going around bragging about it. :cool:
I wasn't bragging, I was saying why I don't release it.
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
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
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
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 :)

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.