PtokaX forum
Archive => Archived 5.0 boards => Request for scripts => Topic started by: SilvaO on 22 July, 2005, 01:21:31
Hi!
can you conver to LUA 5
Quote-- ![AscIIArtBot]!? V:1.1 by [ES]latinmusic
-- Some improvements inside the code
-- Old AscII files have been retouched for better display
-- New cool art files have been added
-- To download the new ASCII files use the same link as before
-- Enjoy
botName = "![AscIIArtBot]!?"
DirArray = {}
TimerStatus = 0
CommandStatus = 1
file = "ArtList.txt"
ErrorMsg = "You do not have enough privileges to execute this command."
function Main()
execute("dir AscIIArtFiles > ArtList.txt /B")
MakeArray(curUser)
local version = botName.." V:1.1 by [ES]latinmusic"
SendToAll(botName, "Script restarted.\r\n "..version..date(" launched at day: %d/%m/%Y. Local Hub Time: %X."))
SendToAll(botName, "The 'AscII Art List File' have been generated.")
end
function DataArrival(curUser, data)
if strsub(data, 1, 1) ~= "<" then return end
local s, e, cmd, args = strfind(data, "^%b<> %-(%a+)%s*(.*)%|$")
if not s then return end
cmd = strlower(cmd)
if cmd == "showart" then
if CommandStatus == 1 then
variable = DirArray[random(1,getn(DirArray))]
local result = Show(TheFile)
curUser:SendData(botName,result)
else
curUser:SendData(botName,"The command '-showart' is temporarily deactivated.")
end
return 1
elseif cmd == "reloadart" then
if (curUser.iProfile ~= 0) then curUser:SendData(botName,ErrorMsg) return 1 end
execute("dir AscIIArtFiles > ArtList.txt /B")
MakeArray(curUser)
SendToAll(botName,"The 'AscII Art List File' have been updated.\r\n")
return 1
elseif cmd == "showhelp" then
curUser:SendData(botName,"List of the commands available for "..botName.."\r\n\r\nCommands --> Description\r\n-reloadart --> Reload the AscII art files\r\n-startimer --> Start the timer\r\n-stoptimer --> Stop the timer\r\n-showart --> Display AscII art files ramdomly on user request\r\n-showhelp --> Display this help\r\n")
elseif cmd == "startimer" then
if not curUser.bOperator then curUser:SendData(botName,ErrorMsg) return 1 end
if TimerStatus == 0 then
local s,e,_,minutes = strfind( data, "%b<>%s+(%S+)%s+(%S+)%|$")
if not s then curUser:SendData(botName,"Syntax: -startimer ") return 1 end
TimerStatus = 1
CommandStatus = 0
SetTimer(minutes*60000)
StartTimer()
curUser:SendData(botName,"The 'Timer' function have been activated. First 'AscII Art' will be displayed in "..minutes.." minute(s) from now.")
SendToAll(botName,"The command '-showart' have been temporarily deactivated.")
else
curUser:SendData(botName,"The 'Timer' function is already active.")
end
return 1
elseif cmd == "stoptimer" then
if not curUser.bOperator then curUser:SendData(botName,ErrorMsg) return 1 end
if TimerStatus == 1 then
TimerStatus = 0
CommandStatus = 1
StopTimer()
curUser:SendData(botName,"The 'Timer' function have been deactivated.")
SendToAll(botName,"The command '-showart' have been activated.")
else
curUser:SendData(botName,"The 'Timer' function is already deactivated.")
end
return 1
else return end
end
function MakeArray(curUser)
readfrom(file,"r")
while 1 do
local line = read()
if line == nil or line == "" then break
else
tinsert(DirArray, line)
end
end
readfrom()
return DirArray
end
function Show(TheFile)
readfrom("AscIIArtFiles/"..variable,"r")
local art = ""
while 1 do
local line = read()
if line == nil then break
else
art = art..line.."\r\n"
end
end
readfrom()
return art
end
function OnTimer()
variable = DirArray[random(1,getn(DirArray))]
local result = Show(TheFile)
SendToAll(botName,result)
end