PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: blackwings on 06 March, 2005, 07:07:57

Title: Help with timebot and textbot
Post by: blackwings on 06 March, 2005, 07:07:57
I have problem with 2 bots.

1st = This text bot doesn't work. the script says it can't find the text file(even if the folder exist in the script folder and the text files is there to) and there is no error messages in ptokax. =
Text bot (http://board.univ-angers.fr/thread.php?threadid=3696&boardid=28&styleid=1&sid=8503f98720aa93db15c56b996af119b7#2)

2nd = this timebot doesn't work either. I get this error message = Syntax C:\ptokax1604\scripts\zTimeBotLua5.lua:48: bad argument #1 to `lines' (No such file or directory)Here is the code for the timebot = --Timebot for LUA 5
--
-- by blackwings
--Little changed by nErboS
--
-- Converted to LUA 5 by Mutor 2/28/2005
--

bot = "name1"
name2 = "name2"


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
SendPmToAll(bot, sMsgAll)
end
if (tClock["tMsgAll2"] <= os.clock() and sMsgAll2~= "") then
tClock["tMsgAll2"] = os.clock() + 220*sec
SendPmToAll(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
Title:
Post by: blackwings on 06 March, 2005, 07:52:55
QuoteOriginally posted by Mutor
Do you have MsgAll.txt & MsgAll2.txt in your scripts folder?
lol, I had spelled the filename of one of the files wrong, now it works :D