no, 8-ball is dead! lua4 -> lua5
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

no, 8-ball is dead! lua4 -> lua5

Started by Dumledude, 06 May, 2005, 01:43:22

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dumledude

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 <yes/no-question>
-- 
--  If 
iInterval is set it even answers if somebody asks a question in main chat
--  and nobody answers after iInterval milliseconds.
-- 
-- 
CHANGELOG:
--   
v0.21BugfixAuto-answer is now not sent when users PM eachother
--   v0.2:  Added:  Auto-answer in main chatsee "available commands" for further details.
--          
Added:  Neat-looking tag :)
--   
v0.11Bugfixcan'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 };

  
frmHub:RegBot(bot.sBotName);
  
UpdateBotInfo();

  
SetTimer(iInterval);
end

function NewUserConnected(curUser)
  
curUser:SendData(sBotInfo);
end

function OpConnected(curUser)
  
curUser:SendData(sBotInfo);
end

function DataArrival(curUsersData)
  
local __cmdargs strfind(sData"^%b<>%s+(%S+)%s*([^%|]*)%|$");

  if (
cmd == nilthen
    
return 0end;

  
cmd strlower(cmd);

  if (
cmd == sAskPhrasethen
    SendToAll
(sData);

    -- 
quick-check whether it COULD be a question somehow

    
if (strfind(strsub(args, -3), "%?") and strfind(args"%s+")) then
      SendToAll
(bot.sBotNameGetRandomSentence());
    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 (iIntervalthen
    
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 (
bQuestionthen
    SendToAll
(bot.sBotNameGetRandomSentence());
  
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 

Madman

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 ;)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Typhoon

#2
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?



Dumledude

#3
hey thank to you both! =)

and sorry for the php fuckup, didn't know =/ but anyways thanks again for the help  :D

Typhoon

your welcome :)

Typhoon?



Madman

We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

SMF spam blocked by CleanTalk