Hello! I need some help. The thing is the "Elfgirls" are only responding to "(?)" but i want to add some other sData for the "Elfgirls" to respond to, like Hello etc. I have tried to just add ,"hello" into (sData,"(?)) like this:
s,e,inpm = strfind(sData,"$(To:)")
s,e,question = strfind(sData,"(?),"(hello)")
if question ~= nil and inpm == nil then
Then i get a error in the script...so how should i do it?! Any suggestions? :D
This is a part of the Elfgirl Bot with the response string:
--// This function is fired when a new data arrives
function DataArrival(curUser, sData)
s,e,cmd = strfind(sData,"%b<>%s++(%S+)")
if cmd ~= nil then cmd = (strsub(cmd,1,strlen(cmd)-1)) end
if (cmd == "elfon") then
heh = 1
elf = bot[random(1,getn(bot))]
SendToAll("[ElfGirl]"..elf,"So Anyways....")
return 1
elseif (cmd == "elfoff") then
heh = 0
elf = bot[random(1,getn(bot))]
SendToAll ("[ElfGirl]"..elf, "We'll Be Quiet Now")
return 1
end
s,e,inpm = strfind(sData,"$(To:)")
s,e,question = strfind(sData,"(?)")
if question ~= nil and inpm == nil then
qa = 1
SetTimer(random(3000,5000))
end
Cheers! // Dj_OcTaGoN
Hi,
This is how string find work:
strfind(sString, sFind)
sString - The String were you want to find some thing
sFind - The String that you want to find, you can use also magic chars, see it HERE (http://board.univ-angers.fr/thread.php?threadid=763&boardid=4&sid=d20c4cb5cf9cd4432edc7b96d0d74ca4) for great examples made by plop.
Best regards, nErBoS
--// This function is fired when a new data arrives
function DataArrival(curUser, sData)
s,e,cmd = strfind(sData,"%b<>%s++(%S+)")
if cmd ~= nil then cmd = (strsub(cmd,1,strlen(cmd)-1)) end
cmd = strlower(cmd)
if (cmd == "elfon") then
heh = 1
elf = bot[random(1,getn(bot))]
SendToAll("[ElfGirl]"..elf,"So Anyways....")
return 1
elseif (cmd == "elfoff") then
heh = 0
elf = bot[random(1,getn(bot))]
SendToAll ("[ElfGirl]"..elf, "We'll Be Quiet Now")
return 1
elseif (cmd == "?") then
--//DO STUFF
elseif (cmd == "hello") then
SendToAll("[ElfGirl]"..elf,"hello...")
--//do stuff
end
hope that helps...
-BH
thx for info! I learn new stuff everyday...but... the thing with (cmd == "hello") didnt work because it only trigger response when typing hello with prefix (+hello).
So i did it the easy way by copying strings from "(?)" code and changed "(?)" into "(hello)" and it responses to the word "hello" but now to another problem lol. I need to make new response sentences for the: "(hello)" sFind because as it is now it use the same sentences as for the: "(?)" sFind.
Here is the strings + the copied and added strfind(sData,"(hello)") ===>
SendToAll (""..elf, "We'll Be Quiet Now")
return 1
end
s,e,inpm = strfind(sData,"$(To:)")
s,e,question = strfind(sData,"(?)")
if question ~= nil and inpm == nil then
qa = 1
SetTimer(random(3000,5000))
end
s,e,inpm = strfind(sData,"$(To:)")
s,e,question = strfind(sData,"(hello)")
if question ~= nil and inpm == nil then
qa = 1
SetTimer(random(3000,5000))
end
I guess i need to change sData into something else when this is where it searches for responses...am i right? Or is the sData only telling script that it should look in the lua file?
And if this is the case, change to what? And what kind of additions for responses do i need?
This is the sData for: "(?)" sFind
--//Responses to question marks in sData
response = {
}
Jeez i know im confusing but plz have patient with me :P
Hmm ok i got one step further by testing and OPEN MY EYES lol
I now added a new string (1,getn(hello))] in the bottom of this code
but it now responses both with "(?)" and "(hello)" sentences...i want it only response with the
--// Responses on Hello
hello = {
"Hi there!!!",
}
function OnTimer()
if heh == 1 and qa ~= 1 then
SetTimer(random(mintime,maxtime))
elf = bot[random(1,getn(bot))]
chatter = convos[random(1,getn(convos))]
SendToAll(prefix..""..elf, chatter)
s,e,jan = strfind(chatter,"(naked)")
if jan ~= nil then SendToAll("NFRobocop","Spamwarning 1: "..elf.." has been warned!") end
s,e,mag = strfind(chatter,"(Meara)")
if mag ~= nil then SendToAll("NFRobocop",elf.." overrun exception in x:44,5 (end). Because of this I'll rip your damn head off bitch!!") end
s,e,imp = strfind(chatter,"(implant)")
if imp ~= nil then SendToAll("NFRobocop","Bad subject detected! "..elf.." has been warned!") end
if imp ~= nil then SendToAll(prefix..""..elf,"Really? Yah they look nice may I touch them?") end
s,e,pan = strfind(chatter,"(search)")
if pan ~= nil then SendToAll("NFRobocop","Hold ctrl and press S") end
elseif qa == 1 then
qa = 0
SetTimer(random(mintime,maxtime))
elf = bot[random(1,getn(bot))]
chatter = response[random(1,getn(response))]
SendToAll(prefix..""..elf, chatter)
<>
SetTimer(random(mintime,maxtime))
elf = bot[random(1,getn(bot))]
chatter = hello[random(1,getn(hello))]
SendToAll(prefix..""..elf, chatter)
end
end
(convos is the random sentences posted in mainchat)
(response is the sentences triggered by "(?)" but is also triggers the "(hello)" sentences)
(hello is the sentences triggered by "(hello)" but it also triggers the "(?)" sentences)
So i need to split respond on hello/response sentences.......
Jeez even more confusing.......................
confusing indeed... it is a lil past 4am here though ;)
i'll take another look after some good sleep.
-BH
LOL i c, brain is going in slowmotion then :D
And i will look for some way to explain better.....lol
BTW tell me if u want to see the whole script! I guess it?s more easy...but more to check through
Hi,
Here are some wints, use the table like this...
arrAnswer = {
["hello"] = {
"Answer 1",
"Answer 2",
},
["?"] = {
"Answer 1",
"Answer 2",
},
}
Now to search for a random answer to hello just do this...
local answer = arrAnswer["hello"][random(1,getn(arrAnswer["hello"]))]
Best regards, nErBoS
OK dunno if im doing it right...i dont get any errors, bue neither any responses...
--// The Elf Girls Random Chatter Bot
--// Revision 0.2b First public release
--// By Chaggydawg
--// Use +elfon and +elfoff to turn it off and on
mintime = 50000 --// Minimum time between chatter (milliseconds)
maxtime = 100000 --// Maximum time between chatter (milliseconds)
prefix = "" --// prefix to random chatters names
heh = 1 --// Start script off or on 1=on 0=off
--// Random chatters names
bot = {
"[BBB]Nalle_Puh",
"[8Mbit]FlameOfHeart",
"[NL]Dina",
"Pikachu",
"[0.2Mbit]ThunderStormGirl",
"(Fin)Ella",
"Meara_yang",
"[US]GiRlFiNdEr",
"[bostream]Jennifer",
"Zelda_Girl",
"CindyUpstairs",
"{Brasil}Sonita",
"?NiKkI?",
"[Hun]DreamIyou",
"(NOR)AnneLise",
"-?Jeen?-",
"SnoopGirl",
}
--//Phrases they say
convos = {
"Anyone got some good movies? And NO porn!.",
"OOOOooOOOoOOOO00000000OOooooooOOOOO soooooOOOO00000OOOOooooolemiiiiooooOOOOO00000!",
"Anyone up for some chattin'??",
"Anyone care for a sexy girl?!",
"Anyone Awake? I am...",
}
--// Responses to question marks and word hello in sData
arrAnswer = {
["hello"] = {
"Hi there!!!",
"Hey m8!",
},
["?"] = {
"I'm a girl not an encyclopedia",
"Yeah! Definately!",
"Nope...",
"Not really sure, dude..",
"What makes you ask that?",
"Of course... O_o",
"I don't know. I'm making this stuff up as I go.",
},
}
--// This function is fired at the serving start
function Main()
SetTimer(5000)
StartTimer()
end
--// This function is fired when a new data arrives
function DataArrival(curUser, sData)
s,e,cmd = strfind(sData,"%b<>%s++(%S+)")
if cmd ~= nil then cmd = (strsub(cmd,1,strlen(cmd)-1)) end
if (cmd == "elfon") then
heh = 1
elf = bot[random(1,getn(bot))]
SendToAll(""..elf,"So Anyways....we?re awak again!")
return 1
elseif (cmd == "elfoff") then
heh = 0
elf = bot[random(1,getn(bot))]
SendToAll (""..elf, "we will stfu now")
return 1
end
s,e,inpm = strfind(sData,"$(To:)")
s,e,question = strfind(sData,"(?)")
if question ~= nil and inpm == nil then
qa = 1
SetTimer(random(3000,5000))
end
s,e,inpm = strfind(sData,"$(To:)")
s,e,question = strfind(sData,"(hello)")
if question ~= nil and inpm == nil then
qa = 1
SetTimer(random(3000,5000))
end
--// name[curUser.sName] = curUser.sName --// for later usages
end
function OnTimer()
if heh == 1 and qa ~= 1 then
SetTimer(random(mintime,maxtime))
elf = bot[random(1,getn(bot))]
chatter = convos[random(1,getn(convos))]
SendToAll(prefix..""..elf, chatter)
s,e,jan = strfind(chatter,"(naked)")
if jan ~= nil then SendToAll("NFRobocop","Spamwarning 1: "..elf.." has been warned!") end
s,e,mag = strfind(chatter,"(Meara)")
if mag ~= nil then SendToAll("NFRobocop",elf.." overrun exception in x:44,5 (end). Because of this I'll rip your damn head off bitch!!") end
s,e,imp = strfind(chatter,"(implant)")
if imp ~= nil then SendToAll("NFRobocop","Bad subject detected! "..elf.." has been warned!") end
if imp ~= nil then SendToAll(prefix..""..elf,"Really? Yah they look nice may I touch them?") end
s,e,pan = strfind(chatter,"(search)")
if pan ~= nil then SendToAll("NFRobocop","Hold ctrl and press S") end
elseif qa == 1 then
qa = 0
SetTimer(random(mintime,maxtime))
elf = bot[random(1,getn(bot))]
local answer = arrAnswer["?"][random(1,getn(arrAnswer["?"]))]
SendToAll(prefix..""..elf, chatter)
SetTimer(random(mintime,maxtime))
elf = bot[random(1,getn(bot))]
local answer = arrAnswer["hello"][random(1,getn(arrAnswer["hello"]))]
SendToAll(prefix..""..elf, chatter)
end
end
Hi,
You are not sending the answer, at least i don't see it in your code.
Best regards, nErBoS
oh yeah.....changed to this....it will send messages by triggers but still sending from both hello and ?.
SetTimer(random(mintime,maxtime))
elf = bot[random(1,getn(bot))]
localanswer = arrAnswer["?"][random(1,getn(arrAnswer["?"]))]
SendToAll(""..elf, localanswer)
SetTimer(random(mintime,maxtime))
elf = bot[random(1,getn(bot))]
localanswer = arrAnswer["hello"][random(1,getn(arrAnswer["hello"]))]
SendToAll(""..elf, localanswer)
end
end
Should there be something between the sessions to cut them off from eachother? Im not good at lua yet so ... :D
Hi,
Your problem is in that piece of code that you have posted, you aren't making any comparing if the data that you have recived is 'hello' or '?'. You are sending both.
Best regards, nErBoS
ok im stuck in this one... have tried different things for 1 day now...and i guess its something simple lol
(and i have realized this has turned into a "development" thread....lol good for my training :D )
Hi,
What i was telling is that you are activing a var to "hello" and "?"...
elseif [b]qa[/b] == 1 then
qa = 0
SetTimer(random(mintime,maxtime))
elf = bot[random(1,getn(bot))]
local answer = arrAnswer["?"][random(1,getn(arrAnswer["?"]))]
SendToAll(prefix..""..elf, chatter)
SetTimer(random(mintime,maxtime))
elf = bot[random(1,getn(bot))]
local answer = arrAnswer["hello"][random(1,getn(arrAnswer["hello"]))]
SendToAll(prefix..""..elf, chatter)
end
You are sending both answer when qa = 1. You should use different var for both, for eg qa = 2 to "?" and qa = 3 to "Hello".
Best regards, nErBoS