Can someone help me fix this to reade out certain files at certain times?
file1 = "txt/file1.txt"
file2 = "txt/file2.txt"
file3 = "txt/file3.txt"
file4 = "txt/file4.txt"
current = date("%H:%M")
iMin = 1000*60
tTime = {
--["timestring"] = "show this string"
["06:00"] = DoFile(file1),
["09:30"] = DoFile(file2)
["12:00"] = DoFile(file3)
["22:00"] = DoFile(file4)
}
function Main()
current = date("%H:%M")
if tTime[current] then
SendToAll( ("---" ..current .."---"), tTime[current] )
end
frmHub:RegBot("---" ..current .."---")
SetTimer(iMin)
StartTimer()
end
function OnTimer()
frmHub:UnregBot("---" ..current .."---")
current = date("%H:%M")
if tTime[current] then
SendToAll( ("---" ..current .."---"), tTime[current] )
end
frmHub:RegBot("---" ..current .."---")
end
function OnExit()
frmHub:UnregBot("---" ..current .."---")
end
Hi,
You have some syntax error, compare this to yours and check it...
file1 = "txt\file1.txt"
file2 = "txt\file2.txt"
file3 = "txt\file3.txt"
file4 = "txt\file4.txt"
current = date("%H:%M")
iMin = 1000*60
tTime = {
--["timestring"] = "show this string"
["06:00"] = dofile(file1),
["09:30"] = dofile(file2),
["12:00"] = dofile(file3),
["22:00"] = dofile(file4),
}
function Main()
current = date("%H:%M")
if tTime[current] then
SendToAll( ("---" ..current .."---"), tTime[current] )
end
frmHub:RegBot("---" ..current .."---")
SetTimer(iMin)
StartTimer()
end
function OnTimer()
frmHub:UnregBot("---" ..current .."---")
current = date("%H:%M")
if tTime[current] then
SendToAll( ("---" ..current .."---"), tTime[current] )
end
frmHub:RegBot("---" ..current .."---")
end
function OnExit()
frmHub:UnregBot("---" ..current .."---")
end
Best regards, nErBoS
Hi,
is there a mistake in this script?
I try it, but it don?t work at this position: ["09:30"] = dofile(file2),
Can someone help?
Hi,
What do you have in the file2 to be done ???
Best regards, nErBoS
Here the code I Change, but it don?t work.
At special time the script should read out from special txtfile.
Bot = "TxT-Reader"
file1 = "txt\file1.txt"
file2 = "txt\file2.txt"
file3 = "txt\file3.txt"
file4 = "txt\file4.txt"
current = date("%H:%M")
iMin = 1000*60
tTime = {
--["timestring"] = "show this string"
["06:00"] = readfile(file1),
["09:30"] = readfile(file2),
["12:00"] = readfile(file3),
["22:00"] = readfile(file4),
}
function Main()
current = date("%H:%M")
if tTime[current] then
SendToAll( ("---" ..current .."---"), tTime[current] )
end
frmHub:RegBot("---" ..current .."---")
SetTimer(iMin)
StartTimer()
end
function OnTimer()
frmHub:UnregBot("---" ..current .."---")
current = date("%H:%M")
if tTime[current] then
SendToAll( ("---" ..current .."---"), tTime[current] )
end
frmHub:RegBot("---" ..current .."---")
end
function OnExit()
frmHub:UnregBot("---" ..current .."---")
end
function readfile(file)
local handle = openfile(file, "r")
if (handle ~= nil) then
local line = read(handle)
while 1 do
if line == nil then break
else
text = line
text = ReplaceChars(text, "|", "--")
text = ReplaceChars(text, "<", " ")
text = ReplaceChars(text, ">", "| ")
SendToAll(Bot,text)
end
end
end
closefile(handle)
end
function ReplaceChars(string, old, new)
string = gsub(string, old, new)
return string
end
Hi,
I am trying to understand your script, you are reading what ??? Code or simple text to be showed ???
Best regards, nErBoS
simple text in all txt files