Hiya i got a little timebot for extra adds for main and i was wondering if somebody could convert it for me please :)
--Timebot for LUA 5
--
-- To main chat by blackwings
--Little changed by nErboS
--
-- Converted to LUA 5 by Mutor 2/28/2005
--
bot = "info bot"
name1 = "Hub Info"
name2 = "Hub message"
sec = 60
fMsgAll = "MsgAll.txt"
sMsgAll = ""
fMsgAll2 = "MsgAll2.txt"
sMsgAll2 = ""
tClock = {
["tMsgAll"] = os.clock() + 1*sec, -- Time to show in math.minutes
["tMsgAll2"] = os.clock() + 1*sec, -- Time to show in math.minutes
}
function Main()
frmHub:RegBot(bot)
sMsgAll = Readtext(fMsgAll)
sMsgAll2 = Readtext(fMsgAll2)
StartTimer()
end
function OnTimer()
if (tClock["tMsgAll"] <= os.clock() and sMsgAll~= "") then
tClock["tMsgAll"] = os.clock() + 150*sec
SendToAll(bot, sMsgAll)
end
if (tClock["tMsgAll2"] <= os.clock() and sMsgAll2~= "") then
tClock["tMsgAll2"] = os.clock() + 220*sec
SendToAll(name2, sMsgAll2)
end
end
function Readtext(file)
local sTmp="\r\n\r\n"
for line in io.lines(file) do
sTmp = sTmp..line.."\r\n"
end
return sTmp
end
thank you :D
--Timebot for LUA 5
--
-- To main chat by blackwings
--Little changed by nErboS
--
-- Converted to LUA 5 by Mutor 2/28/2005
--
-- Converted to API 2 by Madman, 18.03.08
bot = "info bot"
name1 = "Hub Info"
name2 = "Hub message"
sec = 60
fMsgAll = "MsgAll.txt"
sMsgAll = ""
fMsgAll2 = "MsgAll2.txt"
sMsgAll2 = ""
tClock = {
["tMsgAll"] = os.clock() + 1*sec, -- Time to show in math.minutes
["tMsgAll2"] = os.clock() + 1*sec, -- Time to show in math.minutes
}
function OnStartup()
Core.RegBot(bot,"","",true)
sMsgAll = Readtext(fMsgAll)
sMsgAll2 = Readtext(fMsgAll2)
tID = TmrMan.AddTimer(1*sec)
end
function OnTimer(ID)
if tID then
if (tClock["tMsgAll"] <= os.clock() and sMsgAll~= "") then
tClock["tMsgAll"] = os.clock() + 150*sec
Core.SendToAll("<"..bot.."> ".. sMsgAll)
end
if (tClock["tMsgAll2"] <= os.clock() and sMsgAll2~= "") then
tClock["tMsgAll2"] = os.clock() + 220*sec
Core.SendToAll("<"..name2.."> ".. sMsgAll2)
end
end
end
function Readtext(file)
local sTmp="\r\n\r\n"
for line in io.lines(file) do
sTmp = sTmp..line.."\r\n"
end
return sTmp
end
That should do it...
It's untested tho..
It works great thank you Madman :D
Ive changed the hub now to ptokax 4.1.1 and now the time bot has an error
this is the error I get scripts\timebot.lua:50: bad argument #1 to 'lines' (MsgAll.txt: No such file or directory)
worked fine on the 4.0.0e hub
I was wondering can somebody fix it please :D
Yes the files were there. Its working great now thanks Mutor :D