Thread: Dictionary
View Single Post
  #2  
Old 04-18-2007, 12:34 PM
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 killerogue View Post
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):
PHP Code:
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(
btemp.toks) {
  if (
== "<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
PHP Code:
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..
NPC Code:
 /npcdefineword <word here>


in RC chat


I think that should work..
__________________

Last edited by Chompy; 04-18-2007 at 01:15 PM..
Reply With Quote