I get this [16:11] Syntax ...ts\Downloads\Programs\Ptokax\scripts\!requesitos.LUA:20: attempt to call global `ReadJokes' (a nil value)
---/-- File reader
---/-- Feito por?
---/-- Brevemente sera convertido em lua 5
---/-- Cmd !ler
Bot = "nomedobot"
filename = "ala.txt" --O ficheiro tem de estar criado na pasta script
function Main()
frmHub:RegBot(Bot)
end
function ChatArrival(user, data)
if (string.sub(data,1,1)=="<") or (string.sub(data,1,5+string.len(Bot))=="$To: "..Bot) then
data=string.sub(data,1,string.len(data)-1)
s,e,cmd = string.find(data,"%b<>%s+(%S+)")
if (cmd=="!ler") then
ReadJokes(user, data)
return 1
end
end
end
function ReadFromFile(filename)
local file = io.open(filename, "r") -- "r" read
for line in file:lines() do
user:SendPM(Bot, tmp)
end
file:close()
end
Please help me...trying to convert it to lua 5
I made thisone a little while ago:
-- Simple TXT / file viewer by TTB
-- Requested by Pingelmonster
-- Made: 06-05-05
----------------------------------
-- ## Settings ## --
bot = "[BOT]TXT-assistent" -- botname
path = "extratxt" -- path for your txt file(s)
File1= "hublists.txt" -- filename
cmd1 = "#hublists" -- command
regbot = "0" -- Reg your bot?
PM = "1" -- Send your message by PM or in MAIN chat? 1 = PM, 0 = Main Chat.
-- NOTE: If you choose to send by PM, your bot will be REGGED anyway (can't send PM without sender).
-- ## Don't change below! ## --
function Main()
if regbot == "1" or PM == "1" then
frmHub:RegBot(bot)
end
end
function ChatArrival(curUser,data)
data = string.sub(data,1,string.len(data)-1)
s,e,cmd = string.find(data,"%b<>%s+(%S+)")
if cmd and cmd == cmd1 then
local sdata = LoadFile(File1)
if PM == "1" then
curUser:SendPM(bot,"\r\n"..sdata)
else
curUser:SendData(bot,"\r\n\r\n"..sdata.."\r\n")
end
return 1
end
end
function LoadFile(file)
local handle = io.open(path.."/"..file,"r")
if handle then
local sdata = ""
local line = ""
for line in handle:lines() do
sdata = sdata..line.."\r\n"
end
return sdata
else
sdata = "File / command not available!"
return sdata
end
handle:close()
end
Thnks!