small fix needed
 

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

small fix needed

Started by Psycho_Chihuahua, 17 November, 2004, 17:33:21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Psycho_Chihuahua

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
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

nErBoS

#1
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
--## nErBoS Spot ##--

charlie

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?

nErBoS

Hi,

What do you have in the file2 to be done ???

Best regards, nErBoS
--## nErBoS Spot ##--

charlie

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

nErBoS

Hi,

I am trying to understand your script, you are reading what ??? Code or simple text to be showed ???

Best regards, nErBoS
--## nErBoS Spot ##--

charlie

simple text in all txt files

SMF spam blocked by CleanTalk