PDA

View Full Version : Dictionary


fowlplay4
10-04-2006, 12:47 AM
Dictionary
Heres my functions :D, while playing with this script you'll find many funny definitions. LOL

Requesting Definition of boobies:
- small tropical gannet having a bright bill or bright feet or both
- an ignorant or foolish person


function Define(word) {
temp.link = "http://www.onelook.com/?w=" @ word @ "&ls=a";
echo("Requesting Definition of" SPC word @ ":");
temp.req = requesturl(temp.link);
this.catchevent(temp.req,"onReceiveData","onDefine");
}
function onDefine(obj) {
temp.toks = obj.fulldata.tokenize("\n");
for(b: temp.toks) {
if (b == "<LI>") continue;
if (b.starts("<LI>") > 0) {
temp.ntoks = b.tokenize(";");
temp.npos = temp.ntoks[2].pos("(");
temp.defin = temp.ntoks[2].substring(0,temp.npos);
if (temp.defin.length() > 1) echo(" - " @ temp.defin);
temp.msg++;
}
}
if (temp.msg == 0) echo("No Definitions Found!");
}

KuJi
10-04-2006, 12:59 AM
Haha, that's a pretty cool idea lol

P.S. Repped.. and I think you get like 5 rep points from me too ;)

xAndrewx
10-04-2006, 09:18 AM
Great Idea +1 Rep

Twinny
10-04-2006, 10:46 AM
Why would graal need this? >_<

KuJi
10-04-2006, 02:10 PM
Why would graal need this? >_<

Because some people don't know words =o?

xXziroXx
10-04-2006, 03:46 PM
Haha, a script that made me laugh.. originall and a hillarious, yet usefull idea. Heres your rep!

contiga
10-04-2006, 08:55 PM
Funny! Rep++;

Rapidwolve
10-05-2006, 01:20 AM
Why would graal need this? >_<

Its a good tool for when your on RC and you would like to find the definition of a word without having to open a web browser and such. I'm sure there are many more other reasons why it would be good to have too.

smirt362
10-05-2006, 03:03 AM
Nifty!

fowlplay4
10-05-2006, 04:25 AM
Its a good tool for when your on RC and you would like to find the definition of a word without having to open a web browser and such. I'm sure there are many more other reasons why it would be good to have too.

Exactly why I made it.

Chompy
10-05-2006, 01:50 PM
bingo! looks funny :)
:pluffy: --> Rep time!

Rapidwolve
10-06-2006, 01:07 AM
I've already given you rep before Chompy ;)

Chompy
10-06-2006, 01:55 PM
I've already given you rep before Chompy ;)

<3 Thanks :D

killerogue
04-18-2007, 01:10 AM
Hate to revive this, but just read it and found it to be useful. But I've tried a few ways to call the function but it didn't quite work.

What's the issue? Or how should I do it? As I am obviously doing it wrong..:P

Chompy
04-18-2007, 01:34 PM
Hate to revive this, but just read it and found it to be useful. But I've tried a few ways to call the function but it didn't quite work.

What's the issue? Or how should I do it? As I am obviously doing it wrong..:P

Call the function serverside with a word as the parameter
for example you can make a class and have a little script in the Control-NPC:

dictionary (class):

function Define(word) {
temp.link = "http://www.onelook.com/?w=" @ word @ "&ls=a";
echo("Requesting Definition of" SPC word @ ":");
temp.req = requesturl(temp.link);
this.catchevent(temp.req,"onReceiveData","onDefine");
}
function onDefine(obj) {
temp.toks = obj.fulldata.tokenize("\n");
for(b: temp.toks) {
if (b == "<LI>") continue;
if (b.starts("<LI>") > 0) {
temp.ntoks = b.tokenize(";");
temp.npos = temp.ntoks[2].pos("(");
temp.defin = temp.ntoks[2].substring(0,temp.npos);
if (temp.defin.length() > 1) echo(" - " @ temp.defin);
temp.msg++;
}
}
if (temp.msg == 0) echo("No Definitions Found!");
}


Control-NPC

function onCreated()
join("dictionary");
public function onRCChat() {
if (params[0] == "defineword") {
temp.word = params[1];
Define(temp.word);
}
}

can be a part of the Control-NPC script at the bottom and then..
/npcdefineword <word here>
in RC chat


I think that should work..

killerogue
04-18-2007, 07:48 PM
Ah thanks Chomp.