Hi as you can read in the topic my 8ball is dead =/ we miss him ;P so now i wonder if anyone can help me convert this lua4? (a wild guess) to lua5 so he will work again and make the hard choiceses for us in the hub so we no longer have to think for ourselves.
// Tian
-- [8-Ball] - v0.21
--
-- Written by bonki 2003
--
-- ABOUT:
-- A very simple magic 8-ball implementation.
--
-- AVAILABLE COMMANDS:
-- !8-ball
--
-- If iInterval is set it even answers if somebody asks a question in main chat
-- and nobody answers after iInterval milliseconds.
--
-- CHANGELOG:
-- v0.21: Bugfix: Auto-answer is now not sent when users PM eachother
-- v0.2: Added: Auto-answer in main chat, see "available commands" for further details.
-- Added: Neat-looking tag :)
-- v0.11: Bugfix: can't remember :P
-- v0.1: Initial Version
sVer = "0.21";
sName = "8-Ball"
sAskPhrase = "!8-ball";
iInterval = 8 * 1000;
--iInterval = nil; -- uncomment this if you don't want to use this feature
aAnswers = {
"No.",
"Yes.",
"NOOOOOOOOOOOOOOOOOOO!",
"Definitely.",
"All signs point to yes.",
"Yeah :)",
"HELL NO!",
"No way my friend!",
"Never ever.",
"As certain as death!",
"No...now go and blame bonki!",
"Don't count on it.",
"Without a doubt!",
"My reply is no.",
"You may rely on it.",
"I can't predict now, need some food first!",
"My sources say no...",
"Yes, most likely.",
"Concentrate and ask again.",
"This is very doubtful.",
"Better not tell you know ;-)",
"Couldn't read from brain. (A)bort, (R)etry, (I)gnore?_",
"I calculated the probability to 50 percent.",
"I know but I won't tell you :-)",
"Pay me and I'm gonna tell you.",
"Ask your mummy, she knows better than a stupid billard ball!",
"Are you kidding?",
"What? Sorry I haven't paid attention, ask again...",
"Huh?",
"Blah blahhh blahh...",
"You must be kidding!",
"Are you serious?",
"Haha, I like you...funny guy, you are :-)",
"Geeeeee...what a stupid question.",
"Stop doing drugs :-P",
"How could you think of such things?",
"How should I know?",
"And they say there are no stupid questions...",
"Get a life and leave me alone!",
"BLOOD SHALL COME UPON YOU!",
"TRUE NORWEGIAN BLACK METAL!!!", -- sue me!!!
"Get some money first.",
"Ask RabidWombat, he'll know for sure :-)", -- honor to whom honor is due! :-)
"W-e a-r-e B-o-r-g, y-o-u w-i-l-l b-e a-s-s-i-m-i-l-a-t-e-d, R-e-s-i-s-t-a-n-c-e i-s f-u-t-i-l-e ! Err...I mean...No.",
};
sLastNick = nil;
function Main()
randomseed(clock());
bot = { sBotName = sName,
sBotVer = sVer,
sBotEmail = "bonki@no-spam.net",
sBotSpeed = "Sol", -- "Speed of Light" =)
sBotTag = "<++ V:"..sVer..",P:bonki,T:"..getn(aAnswers)..">",
sBotDescr = "Magic 8-Ball-Bot v"..sVer.." written by bonki 2003",
iBotShare = 0 };
frmHub:RegBot(bot.sBotName);
UpdateBotInfo();
SetTimer(iInterval);
end
function NewUserConnected(curUser)
curUser:SendData(sBotInfo);
end
function OpConnected(curUser)
curUser:SendData(sBotInfo);
end
function DataArrival(curUser, sData)
local _, _, cmd, args = strfind(sData, "^%b<>%s+(%S+)%s*([^%|]*)%|$");
if (cmd == nil) then
return 0; end;
cmd = strlower(cmd);
if (cmd == sAskPhrase) then
SendToAll(sData);
-- quick-check whether it COULD be a question somehow
if (strfind(strsub(args, -3), "%?") and strfind(args, "%s+")) then
SendToAll(bot.sBotName, GetRandomSentence());
else
SendToAll(bot.sBotName, "I'm a magic 8-ball you fool. Ask me a question or leave me alone!");
end
return 1;
end
if (iInterval) then
if (strfind(strsub(args, -3), "%?") and strfind(args, "%s+")) then
bQuestion = 1;
StartTimer();
else
bQuestion = nil;
StopTimer();
end
end
return 0;
end
function OnTimer()
if (bQuestion) then
SendToAll(bot.sBotName, GetRandomSentence());
end
StopTimer();
end
function GetRandomSentence()
local iRnd = random(getn(aAnswers));
return aAnswers[iRnd];
end
function UpdateBotInfo()
sBotInfo = "$MyINFO $ALL "..bot.sBotName.." "..bot.sBotDescr..bot.sBotTag.."$ $"..bot.sBotSpeed..strchar(1).."$"..bot.sBotEmail.."$"..bot.iBotShare.."$" ;
end
Here we go....
-- [8-Ball] - v0.21
--
-- Written by bonki 2003
--
-- ABOUT:
-- A very simple magic 8-ball implementation.
--
-- AVAILABLE COMMANDS:
-- !8-ball
--
-- If iInterval is set it even answers if somebody asks a question in main chat
-- and nobody answers after iInterval milliseconds.
--
-- CHANGELOG:
-- v0.21: Bugfix: Auto-answer is now not sent when users PM eachother
-- v0.2: Added: Auto-answer in main chat, see "available commands" for further details.
-- Added: Neat-looking tag :)
-- v0.11: Bugfix: can't remember :P
-- v0.1: Initial Version
-- Converted to lua 5 by Madman
-- Some small changes to...
sAskPhrase = "!8-ball";
iInterva = 8 * 1000;
--iInterval = nil; -- uncomment this if you don't want to use this feature
function Main()
math.randomseed(os.clock());
Bot = {
["Name"] = "8-Ball", -- Bot's name
["Email"] = "bonki@no-spam.net",
["Speed"] = "Sol", -- "Speed of Light" =)
["Tag"] = "<++ V:0.21,P:bonki,T:"..table.getn(aAnswers)..">",
["Descr"] = "Magic 8-Ball-Bot v0.21 written by bonki 2003",
["Share"] = 0
};
frmHub:RegBot(Bot.Name);
SetTimer(iInterval);
sBotInfo = "$MyINFO $ALL "..Bot.Name.." "..Bot.Descr..Bot.Tag.."$ $"..Bot.Speed..string.char(1).."$"..Bot.Email.."$"..Bot.Share.."$" ;
SendToAll(sBotInfo);
end
aAnswers = {
"No.",
"Yes.",
"NOOOOOOOOOOOOOOOOOOO!",
"Definitely.",
"All signs point to yes.",
"Yeah :)",
"HELL NO!",
"No way my friend!",
"Never ever.",
"As certain as death!",
"No...now go and blame bonki!",
"Don't count on it.",
"Without a doubt!",
"My reply is no.",
"You may rely on it.",
"I can't predict now, need some food first!",
"My sources say no...",
"Yes, most likely.",
"Concentrate and ask again.",
"This is very doubtful.",
"Better not tell you know ;-)",
"Couldn't read from brain. (A)bort, (R)etry, (I)gnore?_",
"I calculated the probability to 50 percent.",
"I know but I won't tell you :-)",
"Pay me and I'm gonna tell you.",
"Ask your mummy, she knows better than a stupid billard ball!",
"Are you kidding?",
"What? Sorry I haven't paid attention, ask again...",
"Huh?",
"Blah blahhh blahh...",
"You must be kidding!",
"Are you serious?",
"Haha, I like you...funny guy, you are :-)",
"Geeeeee...what a stupid question.",
"Stop doing drugs :-P",
"How could you think of such things?",
"How should I know?",
"And they say there are no stupid questions...",
"Get a life and leave me alone!",
"BLOOD SHALL COME UPON YOU!",
"TRUE NORWEGIAN BLACK METAL!!!", -- sue me!!!
"Get some money first.",
"Ask RabidWombat, he'll know for sure :-)", -- honor to whom honor is due! :-)
"W-e a-r-e B-o-r-g, y-o-u w-i-l-l b-e a-s-s-i-m-i-l-a-t-e-d, R-e-s-i-s-t-a-n-c-e i-s f-u-t-i-l-e ! Err...I mean...No.",
};
sLastNick = nil;
function NewUserConnected(curUser)
curUser:SendData(sBotInfo);
end
OpConnected = NewUserConnected
function ChatArrival(curUser, sData)
local _, _, cmd, args = string.find(sData, "^%b<>%s+(%S+)%s*([^%|]*)%|$");
if (cmd == nil) then
return 0; end;
cmd = string.lower(cmd);
if (cmd == sAskPhrase) then
SendToAll(sData);
-- quick-check whether it COULD be a question somehow
if (string.find(string.sub(args, -3), "%?") and string.find(args, "%s+")) then
SendToAll(Bot.Name, GetRandomSentence());
else
SendToAll(Bot.Name, "I'm a magic 8-ball you fool. Ask me a question or leave me alone!");
end
return 1;
end
if (iInterval) then
if (string.find(string.sub(args, -3), "%?") and string.find(args, "%s+")) then
bQuestion = 1;
StartTimer();
else
bQuestion = nil;
StopTimer();
end
end
return 0;
end
function OnTimer()
if (bQuestion) then
SendToAll(Bot.Name, GetRandomSentence());
end
StopTimer();
end
function GetRandomSentence()
local iRnd = math.random(table.getn(aAnswers));
return aAnswers[iRnd];
end
And please next time.. post a scipt using [ code ] [ /code ] instead of [ php ] [ /php ] =)
the php stuff f*cked up the code some...
Exampled...
in php:
if (strfind(strsub(args, -3), "%?"

and strfind(args, "%s+"

) then
in code:
if (strfind(strsub(args, -3), "%?") and strfind(args, "%s+")) then
enjoy the script ;)
hmm, damn you Madman :p too slow again..
well i'll post anyway made some changes to :)
-- [8-Ball] - v0.22
--
-- Written by bonki 2003
--
-- ABOUT:
-- A very simple magic 8-ball implementation.
--
-- AVAILABLE COMMANDS:
-- !8-ball
--
-- If iInterval is set it even answers if somebody asks a question in main chat
-- and nobody answers after iInterval milliseconds.
--
-- CHANGELOG:
-- v0.22 Fix: Changed to Lua 5,and made some changes by Typhoon?
-- v0.21: Bugfix: Auto-answer is now not sent when users PM eachother
-- v0.2: Added: Auto-answer in main chat, see "available commands" for further details.
-- Added: Neat-looking tag :)
-- v0.11: Bugfix: can't remember :P
-- v0.1: Initial Version
local tSet = {}
tSet.sVer = "0.22";
tSet.sName = "8-Ball"
tSet.sAskPhrase = "!8-ball";
tSet.iInterval = 8 * 1000;
--iInterval = nil; -- uncomment this if you don't want to use this feature
tSet.aAnswers = {
"No.",
"Yes.",
"NOOOOOOOOOOOOOOOOOOO!",
"Definitely.",
"All signs point to yes.",
"Yeah :)",
"HELL NO!",
"No way my friend!",
"Never ever.",
"As certain as death!",
"No...now go and blame bonki!",
"Don't count on it.",
"Without a doubt!",
"My reply is no.",
"You may rely on it.",
"I can't predict now, need some food first!",
"My sources say no...",
"Yes, most likely.",
"Concentrate and ask again.",
"This is very doubtful.",
"Better not tell you know ;-)",
"Couldn't read from brain. (A)bort, (R)etry, (I)gnore?_",
"I calculated the probability to 50 percent.",
"I know but I won't tell you :-)",
"Pay me and I'm gonna tell you.",
"Ask your mummy, she knows better than a stupid billard ball!",
"Are you kidding?",
"What? Sorry I haven't paid attention, ask again...",
"Huh?",
"Blah blahhh blahh...",
"You must be kidding!",
"Are you serious?",
"Haha, I like you...funny guy, you are :-)",
"Geeeeee...what a stupid question.",
"Stop doing drugs :-P",
"How could you think of such things?",
"How should I know?",
"And they say there are no stupid questions...",
"Get a life and leave me alone!",
"BLOOD SHALL COME UPON YOU!",
"TRUE NORWEGIAN BLACK METAL!!!", -- sue me!!!
"Get some money first.",
"Ask RabidWombat, he'll know for sure :-)", -- honor to whom honor is due! :-)
"W-e a-r-e B-o-r-g, y-o-u w-i-l-l b-e a-s-s-i-m-i-l-a-t-e-d, R-e-s-i-s-t-a-n-c-e i-s f-u-t-i-l-e ! Err...I mean...No.",
};
tSet.sLastNick = nil;
function Main()
math.randomseed(os.clock());
bot = { sBotName = tSet.sName,
sBotVer = tSet.sVer,
sBotEmail = "bonki@no-spam.net",
sBotSpeed = "Sol", -- "Speed of Light" =)
sBotTag = "<++ V:"..tSet.sVer..",P:bonki,T:"..table.getn(tSet.aAnswers)..">",
sBotDescr = "Magic 8-Ball-Bot v"..tSet.sVer.." written by bonki 2003",
iBotShare = 0 };
frmHub:RegBot(bot.sBotName);
UpdateBotInfo();
SetTimer(tSet.iInterval);
end
function NewUserConnected(curUser)
curUser:SendData(sBotInfo);
end
OpConnected = NewUserConnected
function ChatArrival(curUser, sData)
local _, _, cmd, args = string.find(sData, "^%b<>%s+(%S+)%s*([^%|]*)%|$");
if (cmd == nil) then
return 0; end;
local cmd = string.lower(cmd);
if (cmd == tSet.sAskPhrase) then
SendToAll(sData);
-- quick-check whether it COULD be a question somehow
if (string.find(string.sub(args, -3), "%?") and string.find(args, "%s+")) then
SendToAll(bot.sBotName, GetRandomSentence());
else
SendToAll(bot.sBotName, "I'm a magic 8-ball you fool. Ask me a question or leave me alone!");
end
return 1;
end
if (tSet.iInterval) then
if (string.find(string.sub(args, -3), "%?") and string.find(args, "%s+")) then
bQuestion = 1;
StartTimer();
else
bQuestion = nil;
StopTimer();
end
end
return 0;
end
function OnTimer()
if (bQuestion) then
SendToAll(bot.sBotName, GetRandomSentence());
end
StopTimer();
end
function GetRandomSentence()
local iRnd = math.random(table.getn(tSet.aAnswers));
return tSet.aAnswers[iRnd];
end
function UpdateBotInfo()
sBotInfo = "$MyINFO $ALL "..bot.sBotName.." "..bot.sBotDescr..bot.sBotTag.."$ $"..bot.sBotSpeed..string.char(1).."$"..bot.sBotEmail.."$"..bot.iBotShare.."$" ;
end
Typhoon?
hey thank to you both! =)
and sorry for the php fuckup, didn't know =/ but anyways thanks again for the help :D
your welcome :)
Typhoon?
Your welcome =)