hi can some tell me why i cant get this to work .what have i done wrong
botname = "-(LOK-BOT-LUA5)-"
lokbot = "add.txt"
function ChatArrival(user,data)
if string.sub(data, 1, 1) == "<" then
local data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data, "%b<>%s+(%S+)")
if cmd == "!add" and (user.bOperator) then
readfrom(lokbot)
while 1 do
line = read()
if line == nil then break end
user:SendPM(botname,line)
end
readfrom()
return 1
end
end
end
getting this error
\new hub\scripts\art.lua:10: attempt to call global `readfrom' (a nil value)
i got folder name lokbot with add.txt in it hellp
try this m8
botname = "-(LOK-BOT-LUA5)-"
function ChatArrival(user,data)
if string.sub(data, 1, 1) == "<" then
local data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data, "%b<>%s+(%S+)")
if cmd == "!add" and (user.bOperator) then
AddMessage(user)
end
return 1
end
end
function AddMessage(user)
local f,e = io.open("add.txt","r")
local message = ""
while 1 do
local line = f:read("*l")
if line == nil then break
else
message = message..line.."\r\n"
end
end
f:close(f)
user:SendPM(botname,message)
end
??????Hawk??????
Thx Hawk works well what would it need to send to main chat sorry i am still learning lua5 after geting use to lua4
QuoteOriginally posted by Skynet
Thx Hawk works well what would it need to send to main chat sorry i am still learning lua5 after geting use to lua4
To send to main chat, change this:
user:SendPM(botname,message)
to this:
user:SendData(botname, message)
I think...
thank you so much works now simple as that lol i had wording wrong best i start working on ascii art and adds for the hub thankyou again :)
Skynet
land of karaoke
found one problem with it no one can type in main chat tryed a few things but not worked also made a bit tidy
by adding txt to a folder :>
function AddMessage(user)
local f,e = io.open("images/add.txt","r")
any one out now why no one and type in main its got me
It blocked mainchat by default. :P
Fixed (hopefully).
-- fixed by bastya_elvtars
botname = "-(LOK-BOT-LUA5)-"
function ChatArrival(user,data)
local data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data, "%b<>%s+(%S+)")
if cmd == "!add" and (user.bOperator) then
AddMessage(user)
return 1
end
end
function AddMessage(user)
local f,e = io.open("add.txt","r")
local message = "" while 1 do
local line = f:read("*l")
if line == nil then break
else
message = message..line.."\r\n" end
end
f:close(f)
user:SendPM(botname,message)
end
Hiya,
To allow typing in mainchat, changefunction ChatArrival(user,data)
if string.sub(data, 1, 1) == "<" then
local data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data, "%b<>%s+(%S+)")
if cmd == "!add" and (user.bOperator) then
AddMessage(user)
end
return 1
end
end
tofunction ChatArrival(user,data)
if string.sub(data, 1, 1) == "<" then
local data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data, "%b<>%s+(%S+)")
if cmd == "!add" and (user.bOperator) then
AddMessage(user)
return 1
end
end
end
and btw the script doesn't need to check whether the 1st character is "<" since we're in ChatArrival so...function ChatArrival(user,data)
local data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data, "%b<>%s+(%S+)")
if cmd == "!add" and (user.bOperator) then
AddMessage(user)
return 1
end
end
should work even better ;)
Oops took me longer than it did Bast... hardly surprising ^^ :D
thx great is working :)
if i am being a pain tell me tryed to edit abit more thought i had it working and jumped the gun :>
botname = "-(LOK-BOT-LUA5)-"
LOKFolder = "images"
function ChatArrival(user,data)
local data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data, "%b<>%s+(%S+)")
cmd = string.sub(cmd, 1,string.len(cmd))
if io.open(LOKFolder.."/"..cmd..".txt",r) ~= nil then
AddMessage(user.cmd)
return 1
end
end
function AddMessage(user)
local f,e = io.open(LOKFolder.."/"..cmd..".txt","r")
local message = "" while 1 do
local line = f:read("*l")
if line == nil then break
else
message = message..line.."\r\n" end
end
f:close(f)
user:SendPM(botname,message)
end
i am trying to get a folder of txt fill eg add gun etc etc to go to main for all to view like below
.
.
. \ \ ~ ~ //
. ( 0-0 )
. ----------oOO-------(_)---------------------------
.
. ---------------------------------oOO---------------
. I__I__I
. I I I I
. ooO Ooo
.
.
.
Error i have now is :>
Syntax ...nd Settings\Owner\Desktop\new hub\scripts\tester.lua:19: attempt to concatenate global `cmd' (a nil value)
sorted script to send to main for all to see posted in finish scripts for all