Skip to content

Commit f75c3d2

Browse files
committed
Merge pull request #1 from coyotte508/master
Merge
2 parents 96cd447 + f4f6d7f commit f75c3d2

File tree

4 files changed

+44
-12
lines changed

4 files changed

+44
-12
lines changed

scripts.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function require(file) {
2-
return sys.eval(sys.getFileContent(file));
2+
return sys["import"](file);
33
}
44

55
function User(id)
@@ -9,8 +9,9 @@ function User(id)
99
this.channel = null;
1010
}
1111

12-
require ("scripts/printer.js");
13-
commands = require ("scripts/commands.js");
12+
require ("utilities.js");
13+
require ("printer.js");
14+
commands = require ("commands.js");
1415

1516
SESSION.identifyScriptAs("RPG Script");
1617

@@ -31,7 +32,9 @@ function testClearChat() {
3132
poScripts = ({
3233

3334
afterLogIn : function(source) {
34-
35+
var user = SESSION.users(source);
36+
user.print("Abra", "Type /commands to get a list of commands!");
37+
user.print("blank", "");
3538
}
3639
,
3740
beforeBattleMatchup : function() {
@@ -41,7 +44,7 @@ beforeBattleMatchup : function() {
4144
beforeChatMessage : function(src, msg, chan) {
4245
SESSION.users(src).channel = chan;
4346

44-
if (msg.substr(0, 1) == "/") {
47+
if (msg.substr(0, 1) === "/") {
4548
sys.stopEvent();
4649
testClearChat();
4750

@@ -60,4 +63,4 @@ beforeChatMessage : function(src, msg, chan) {
6063
}
6164
}
6265

63-
});
66+
});

scripts/commands.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,26 @@ var handleCommand = function(src, command, data, tar, channel) {
44
var user = SESSION.users(src);
55

66
if (command in commands) {
7-
commands[command]({"user":user, "data":data, "target":tar, "channel":channel});
7+
commands[command][1]({"user":user, "data":data, "target":tar, "channel":channel});
88
}
99
};
1010

11-
commands['help'] = function(params) {
11+
commands['commands'] = ["get a list of commands.", function(params) {
12+
var user = params.user;
13+
//user.print("blank","");
14+
user.print("***", "Commands");
15+
user.print("blank","");
16+
17+
for(var command in commands) {
18+
user.print("/"+command, commands[command][0]);
19+
}
20+
21+
user.print("blank", "");
22+
}];
23+
24+
commands['help'] = ["get started.", function(params) {
1225
var user = params.user;
1326
user.print("Meowth", "This is a RPG server in construction! Nothing to see just yet, be patient ~");
14-
};
27+
}];
1528

1629
ret = ({handleCommand: handleCommand});

scripts/printer.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,30 @@ function is_undefined(val) {
2424
};
2525

2626
User.prototype.print = function(bot, message) {
27-
var pokemon = sys.pokemon(bot);
27+
if (bot === "blank") {
28+
sys.sendMessage(this.id, message);
29+
return;
30+
}
31+
if (bot === "***") {
32+
sys.sendMessage(this.id, "*** " + message + " ***");
33+
return;
34+
}
35+
36+
var pokemon = sys.pokeNum(bot);
2837
var color;
2938

3039
if (!is_undefined(pokemon)) {
3140
color = colors[sys.pokeType1(pokemon)];
3241
}
3342

43+
if (bot.startsWithLetter()) {
44+
bot = "±" + bot;
45+
}
46+
3447
if (is_undefined(color)) {
35-
sys.sendMessage(this.id, "±" + bot + ": " + message, this.channel);
48+
sys.sendMessage(this.id, bot + ": " + message, this.channel);
3649
} else {
3750
sys.sendHtmlMessage(this.id, "<span style='color: " + color + "'><timestamp/>"
38-
+ "<b>±" + bot + ":</b></span> " + message);
51+
+ "<b>" + bot + ":</b></span> " + message);
3952
}
4053
};

scripts/utilities.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
String.prototype.startsWithLetter = function() {
2+
return this[0].toLowerCase() !== this[0].toUpperCase();
3+
}

0 commit comments

Comments
 (0)