matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: First script testing
The array contents should be in a text file however here is a nice way of doing it as well.
code: // This was made by Paul Dean - Version 1.0
// Improved by SpunkyLoveMuff - Version 1.1
// Improved by matty - Version 1.2
var rn_txt = new Array("Why isn't phonetic spelled the way it sounds?",
"Why are there interstate highways in Hawaii?",
"Why are there flotation devices under plane seats instead of parachutes?",
"Why are cigarettes sold in petrol stations when smoking is prohibited there?",
"Why do fat chance and slim chance mean the same thing?",
"If you can't drink and drive, why do you need a driver's license to buy liquor, and why do bars have parking spaces?",
"Do you need a silencer if you are going to shoot a mime?",
"Have you ever imagined a world with no hypothetical situations?",
"How does the guy who drives the snowplow get to work in the mornings?",
"If 7-11 is open 24 hours a day, 365 days a year, why are there locks on the doors?",
"If a cow laughed real hard, would milk come out her nose?",
"If nothing ever sticks to Teflon, how do they make Teflon stick to the pan?",
"If you tied buttered toast to the back of a cat and dropped it from a height, what would happen?",
"If you're in a vehicle going the speed of light, what happens when you turn on the headlights?",
"Why do they put Braille dots on the keypad of the drive-up ATM?",
"Why do we drive on parkways and park on driveways?",
"Why isn't palindrome spelled the same way backwards as it is forwards?",
"Why is it that when you transport something by car, it's called a shipment, but when you transport something by ship, it's called cargo?",
"If a black box in a plane is indestructible, why can't they make the whole plane out of it?",
"Why is it that when you're driving and looking for an address, you turn down the volume on the radio?",
"If someone invented instant water, what would they mix it with?",
"Why is it called a TV set when you only get one?",
"Why does your nose run and your feet smell?",
"Why does an alarm clock go off when it begins ringing?",
"Why does cleave mean both split apart and stick together?",
"Why is it, whether you sit up or sit down, the result is the same?",
"Why is there an expiry date on my sour cream container?",
"Why call it a building if it's already been built?",
"Why do kamikaze pilots wear helmets?",
"Is it true that cannibals don't eat clowns because they taste funny?",
"Does 'virgin wool' come from sheep the shepherd hasn't caught yet?",
"What do sheep count when they can't get to sleep?",
"When you choke a Smurf, what color does it turn?",
"Do blind Eskimos heave seeing-eye sled dogs?",
"Do they have reserved parking for non-handicap people at the Special Olympics?",
"How come wrong numbers are never busy?",
"Do radioactive cats have 18 half-lives?",
"Why call it take a dump, when you leave something behind?",
"What was the best thing before sliced bread?",
"Why do we call it a hot water heater if the water is already hot?",
"If you throw a cat out a car window does it become kitty litter?",
"If corn oil comes from corn, where does baby oil come from?",
"If it's tourist season, why can't we shoot them?",
"After eating, do amphibians have to wait one hour before getting out of the water?",
"How can there be self-help groups?",
"If a mute swears, does his mother make him wash his hands with soap?",
"If someone with multiple personalities threatens to kill himself, is it considered a hostage situation?",
"Instead of talking to your plants, if you yelled at them would they still grow, but only to be troubled and insecure?",
"Isn't it a bit unnerving that doctors call what they do practice?",
"It is hard to understand how a cemetery raised its burial cost and blamed it on the cost of living.",
"If Barbie is so popular, why do you have to buy her friends?",
"Why did God give men nipples?",
"Why do you wear a pair of panties and only one bra?",
"If you spin an Oriental person around and around, does he become disorientated?",
"If a vegetable goes into a coma, is it called a person?",
"If you wear an antennae to a wedding, would the reception be better?",
"If you put a chameleon in a mirrored box what color would it change to?",
"Why is there an 's' in lisp?",
"If the cops arrest a mime, do they tell him he has the right to remain silent?",
"If one synchronized swimmer drowns, do the rest end up drowning as well?",
"If a man is standing in the middle of the forest speaking and there is no woman around to hear him, is he still wrong?");
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
if (/^\/([^\s\/]+)\s*([\s\S]*)$/.exec(Message) !== null) {
switch (RegExp.$1.toLowerCase()) {
case 'ponder':
try{
return rn_txt[Math.round((rn_txt.length-1)*Math.random())];
}catch(e){
MsgPlus.DisplayToast("Error!", "Something bad happened! :o");
Debug.Trace(e.message);
return "";
}
}
}
}
function OnGetScriptCommands(){
return '<ScriptCommands><Command><Name>ponder</Name><Description>What will you think of today?</Description></Command></ScriptCommands>';
}
Why is there a need to store the Script Commands in a variable then return it? Why not just return the string?
This post was edited on 03-12-2008 at 05:07 PM by matty.
|
|