Monitor chat ... if event XYZ, then load WP/file
Monitor chat ... if event XYZ, then load WP/file
Is it possible to monitor chat and if event XYZ is being broadcast, then run/load a specific WP file or specific WP within a file?
For example, I may want to bot outside OS. Then if the notice about the harpies outside OS shows up on chat, I would want the bot to load a specific WP that includes that area with the harpies. After the event (the end also being noted by another msg in chat), I would want the bot to go back to the original route outside OS.
Is possible to monitor chat and load WP accordingly? If so, any pointers or tips on how to do so? Thanks.
For example, I may want to bot outside OS. Then if the notice about the harpies outside OS shows up on chat, I would want the bot to load a specific WP that includes that area with the harpies. After the event (the end also being noted by another msg in chat), I would want the bot to go back to the original route outside OS.
Is possible to monitor chat and load WP accordingly? If so, any pointers or tips on how to do so? Thanks.
Re: Monitor chat ... if event XYZ, then load WP/file
Yup, mind you if you load a WP while you are far away from any of the new WP coords it will try to run up cliffs to get to the nearest coords of the WP. If you make the new WP cover the entire map then it would be fine.
You will need to start a monitor event.
I'll use GM detect as an example.
So you can call this function from an onload Wp or profile
startGMDetect()
I changed it to be CHAT_MSG_SYSTEM as you want to monitor system messages.
So this will make it do the function GMdetection() every 5 seconds.
in the GMdetection() you will need code to check for the text you want.
What you will be after is what msg means.
do a check for msg
you want to then check to see if msg is anything like what you want, can do a string.find for that.
Obviously change the **** for what ever it is you are looking for in the message.
then just tell bot what you want to do
Add it together and looks like this
So remember this used names from the gmdetect as an example, so you should change names to what you want. It should be enough to get you started atleast.
You will need to start a monitor event.
I'll use GM detect as an example.
So you can call this function from an onload Wp or profile
startGMDetect()
Code: Select all
function startGMDetect()
if settings.profile.options.GMDETECT == true then
unregisterTimer("GMdetection");
printf("GM detection started\n");
EventMonitorStart("GMdetect", "CHAT_MSG_SYSTEM");
registerTimer("GMdetection", secondsToTimer(5), GMdetection);
end
end
So this will make it do the function GMdetection() every 5 seconds.
in the GMdetection() you will need code to check for the text you want.
Code: Select all
repeat
local time, moreToCome, name, msg = EventMonitorCheck("GMdetect", "4,1")
do a check for msg
Code: Select all
if msg ~= nil then
Code: Select all
if string.find(msg,"****") then
then just tell bot what you want to do
Code: Select all
loadPaths("**")
Code: Select all
repeat
local time, moreToCome, name, msg = EventMonitorCheck("GMdetect", "4,1")
if msg ~= nil then
if string.find(msg,"****") then
loadPaths("**")
end
end
until moreToCome == false
Remember no matter you do in life to always have a little fun while you are at it
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Monitor chat ... if event XYZ, then load WP/file
Thanks much. Will give it a try later today.
Re: Monitor chat ... if event XYZ, then load WP/file
So I loaded the following in the <onLoad> section of my waypoint file but the bot never started even though the system message showed up in chat. Thoughts?
Code: Select all
function startEVENTDetect()
if settings.profile.options.GMDETECT == true then
unregisterTimer("EVENTdetection");
printf("EVENT detection started\n");
EventMonitorStart("EVENTdetect", "CHAT_MSG_SYSTEM");
registerTimer("EVENTdetection", secondsToTimer(5), EVENTdetection);
end
end
repeat
local time, moreToCome, name, msg = EventMonitorCheck("EVENTdetect", "4,1")
if msg ~= nil then
if string.find(msg,"<START TEXT HERE>") then
__WPL:setWaypointIndex(__WPL:findWaypointTag("START"));
end
if string.find(msg,"<END TEXT HERE>") then
__WPL:setWaypointIndex(__WPL:findWaypointTag("GOTOSLEEP"));
end
end
until moreToCome == false
Re: Monitor chat ... if event XYZ, then load WP/file
Code: Select all
registerTimer("EVENTdetection", secondsToTimer(5), EVENTdetection);
So if you do it all purely in onload of a WP then do it like this.
Code: Select all
function EVENTdetection()
repeat
local time, moreToCome, name, msg = EventMonitorCheck("EVENTdetect", "4,1")
if msg ~= nil then
if string.find(msg,"<START TEXT HERE>") then
__WPL:setWaypointIndex(__WPL:findWaypointTag("START"));
end
if string.find(msg,"<END TEXT HERE>") then
__WPL:setWaypointIndex(__WPL:findWaypointTag("GOTOSLEEP"));
end
end
until moreToCome == false
end
function startEVENTDetect()
unregisterTimer("EVENTdetection");
printf("EVENT detection started\n");
EventMonitorStart("EVENTdetect", "CHAT_MSG_SYSTEM");
registerTimer("EVENTdetection", secondsToTimer(5), EVENTdetection);
end
startEVENTDetect()
This won't get you stuck in a loop though, so it will still go to the nearest set of coords when you start the WP.
Remember no matter you do in life to always have a little fun while you are at it
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Monitor chat ... if event XYZ, then load WP/file
Hey lisa, hi rock.
How can I realize this:
toon1 stay at the position (e.a waypoint1) until sended message (from toon2) in group chat ("come" or somesing else) was detected and how to send a message into a group-chat-frame?
thx in advance!
How can I realize this:
toon1 stay at the position (e.a waypoint1) until sended message (from toon2) in group chat ("come" or somesing else) was detected and how to send a message into a group-chat-frame?
thx in advance!
Re: Monitor chat ... if event XYZ, then load WP/file
Lisa, okay... so I was mincing between your "LOL" eventmonitortest and an attempt to --make it work-- with monitoring system chat and then I stumbled on this post.
This works fine but I want to try something else, further down
The code below gives a string error. Studied a bit and learned string.find is looking for the text. Unfortunately it doesn't seem like the system chat gets logged the same OR (more likely) I'm assigning the event monitor incorrectly. I read about EventMonitorCheck saving to a log... is this a real-time log or is it saved somewhere I can view?
Another swing and a miss as I tried to make the code look more like yours LOL
So now, after reading this thread it looks like my solution is this?
And then at a WP
So I changed the system message to look for above to "Positive Effect" and "Time remaining" based on what I know "sendMacro("SendSystemChat(PE_GetPOBInfo( 1 , 0 ),'SYSTEM');")" will return in the system chat window.
Once startEVENTDetect() is initiated in the /onLoad section do I need to call it again at a specific WP or does it just run continually as long as the WP is running?
Thx again and again
This works fine but I want to try something else, further down
Code: Select all
<!-- # 1 --><waypoint x="-18556" z="-18129" y="999"> EventMonitorStart("Test", "CHAT_MSG_SAY");
sendMacro("SendChatMessage('LOL','SAY');")
yrest(1000)
local time, moreToCome, msg = EventMonitorCheck("Test", "1") if string.find(msg, "LOL") then printf("Event monitoring works fine.\n")
player:sleep()
end
</waypoint>
</waypoints>
The code below gives a string error. Studied a bit and learned string.find is looking for the text. Unfortunately it doesn't seem like the system chat gets logged the same OR (more likely) I'm assigning the event monitor incorrectly. I read about EventMonitorCheck saving to a log... is this a real-time log or is it saved somewhere I can view?
Code: Select all
<!-- # 1 --><waypoint x="-18556" z="-18129" y="999"> EventMonitorStart("Test", "CHAT_MSG_SYSTEM");
sendMacro("SendSystemChat(PE_GetPOBInfo( 1 , 0 ),'SYSTEM');")
yrest(1000)
local time, moreToCome, msg = EventMonitorCheck("Test", "1")
if string.find(msg, "Time remaining") then
printf("Event monitoring works fine.\n")
player:sleep()
end
</waypoint>
</waypoints>
Code: Select all
<!-- # 1 --><waypoint x="-18556" z="-18129" y="999"> EventMonitorStart("Test", "CHAT_MSG_SYSTEM");
sendMacro("SendSystemChat(PE_GetPOBInfo( 1 , 0 ),'SYSTEM');")
yrest(1000)
local time, moreToCome, msg = EventMonitorCheck("Test", "1") if string.find(msg, "PE_GetPOBInfo( 1 , 0 )") then printf("Event monitoring works fine.\n")
player:sleep()
end
</waypoint>
</waypoints>
Code: Select all
</onLoad>
function EVENTdetection()
repeat
local time, moreToCome, name, msg = EventMonitorCheck("EVENTdetect", "4,1")
if msg ~= nil then
if string.find(msg,"Positive Effect") then
__WPL:setWaypointIndex(__WPL:findWaypointTag("START"));
end
if string.find(msg,"Time remaining") then
__WPL:setWaypointIndex(__WPL:findWaypointTag("GOTOSLEEP"));
end
end
until moreToCome == false
end
function startEVENTDetect()
unregisterTimer("EVENTdetection");
printf("EVENT detection started\n");
EventMonitorStart("EVENTdetect", "CHAT_MSG_SYSTEM");
registerTimer("EVENTdetection", secondsToTimer(5), EVENTdetection);
end
startEVENTDetect()
</onLoad>
Code: Select all
<!-- # 1 --><waypoint x="-18556" z="-18129" y="999">
sendMacro("SendSystemChat(PE_GetPOBInfo( 1 , 0 ),'SYSTEM');")
yrest(100)
EVENTdetection()
</waypoint>
</waypoints>
Once startEVENTDetect() is initiated in the /onLoad section do I need to call it again at a specific WP or does it just run continually as long as the WP is running?
Thx again and again
Re: Monitor chat ... if event XYZ, then load WP/file
Why do you want to do this? Why print the values returned from the function and then monitor the chat, when you can just return the values from the function?
I'm not sure what the returned values are but I copied those variable names from the publicencounterframe.lua file.
Code: Select all
local namePOB , itype , ikind , nowvalue, doolsill = RoMScript("PE_GetPOBInfo( 1 , 0 )")
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
Re: Monitor chat ... if event XYZ, then load WP/file
The "PE_GetPOBInfo( 1 , 0 )" gives different outputs such as "Positive Effect" and "Time remaining". I want it to do different WP based on that text. I don't know how to make "local namePOB , itype , ikind , nowvalue, doolsill = RoMScript("PE_GetPOBInfo( 1 , 0 )")" do that.
However, the event monitor test seemed like a way. If it would print something then surely it would load a waypoint.
However, the event monitor test seemed like a way. If it would print something then surely it would load a waypoint.
Re: Monitor chat ... if event XYZ, then load WP/file
Its simple really. PE_GetPOBInfo( 1 , 0 ) is an ingame function that returns 5 values. When you use
you are telling it to print the values the function returns but because SendSystemChat can't print multiple values it only prints the first. If you wanted to you could do this
and then print each of those 5 values.
Now in the bot, if you usebecause there is only one variable it will only capture the first value which is the one you've been playing with. But if you want to look at all the values that function returns you could do
RoMScript can return any values, variables or function outputs just like they do in game.
Hope that helps.
Code: Select all
/script SendSystemChat(PE_GetPOBInfo( 1 , 0 ))
Code: Select all
/script aa,bb,cc,dd,ee = PE_GetPOBInfo( 1 , 0 )
Now in the bot, if you use
Code: Select all
msg = RoMScript("PE_GetPOBInfo( 1 , 0 )")
Code: Select all
aa,bb,cc,dd,ee = RoMScript("PE_GetPOBInfo( 1 , 0 )")
Hope that helps.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
Re: Monitor chat ... if event XYZ, then load WP/file
Ahhh.... edit here.. lol. Think I got it. So "namePOB" was the key I couldn't seem to grasp. right there in front of my face. grrrr
omgosh i must need sleep or more than 24 hours in a day. don't know how you guys get it. I blame my lack of attention to detail as diminished by lack of sleep. menal acuity shot need zzzzzzZZZZzzzZZZzz
Code: Select all
<!-- # 1 --><waypoint x="1" z="9" y="8">
EventMonitorStart("Test", "CHAT_MSG_SYSTEM");
sendMacro("SendSystemChat(PE_GetPOBInfo( 1 , 0 ));")
yrest(1000)
local namePOB = RoMScript("PE_GetPOBInfo( 1 , 0 )")
if string.find(namePOB, "Positive Effect") then
printf("Positive Effect!!!!.\n")
else
if string.find(namePOB, "Time remaining") then
printf("Time remaining!!!!.\n")
end
end
</waypoint>
Re: Monitor chat ... if event XYZ, then load WP/file
I think the point you seem to be missing is you don't need to monitor chat or print it.
try this.
try this.
Code: Select all
<!-- # 1 --><waypoint x="1" z="9" y="8">
local namePOB = RoMScript("PE_GetPOBInfo( 1 , 0 )")
if string.find(namePOB, "Positive Effect") then
printf("Positive Effect!!!!.\n")
elseif string.find(namePOB, "Time remaining") then
printf("Time remaining!!!!.\n")
else print("value returned is "..namePOB)
end
</waypoint>
Remember no matter you do in life to always have a little fun while you are at it
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Monitor chat ... if event XYZ, then load WP/file
Thanks so much again. For this part:
seems it returns w/e else the current status of namePOB is but why are the ".." in front of namePOB needed?
Code: Select all
else print("value returned is "..namePOB)
-
- Posts: 446
- Joined: Wed Aug 03, 2011 7:37 pm
Re: Monitor chat ... if event XYZ, then load WP/file
the .. concatenates the two strings together
Re: Monitor chat ... if event XYZ, then load WP/file
Ok a string is any text inside " "grande wrote:but why are the ".." in front of namePOB needed?
So "lollies" is a string
a variable is something that has a value, defined or not.
lollies = "fruit"
As an example if you have this
Code: Select all
lollies = "Fruit"
print("Lollies "..lollies)
Code: Select all
Lollies Fruit
So as extra info
print("Lollies "..lollies.." are yummy")
will print
Lollies Fruit are yummy
Remember no matter you do in life to always have a little fun while you are at it
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Monitor chat ... if event XYZ, then load WP/file
Ahh yes, excellent thx again and again and again Lisa. your description makes it crystal clear.
So the ".." pulls out whatever may be the current result/status of the namePOB equation.
Like Bill said, concatenates the string component namePOB to whatever the current status is.
If it's blank, as in on a bugged channel would it just fail and stop the MM or would it just print nil? I can mess with it later.
So the ".." pulls out whatever may be the current result/status of the namePOB equation.
Like Bill said, concatenates the string component namePOB to whatever the current status is.
If it's blank, as in on a bugged channel would it just fail and stop the MM or would it just print nil? I can mess with it later.
Re: Monitor chat ... if event XYZ, then load WP/file
I am trying to monitor party chat, and I am trying to use the code above. Here's what I have:
I can trigger the print line to show that msg1 or msg2 are received. However, the code loops infinitely displaying my yellow screen prints, and doesn't escape the repeat ... until in function EVENTdetection
What am I missing? How do I escape the repeat ... until and actually go to the specified waypoints? Thanks.
Code: Select all
function EVENTdetection()
repeat
cprintf(cli.yellow,"Inside EVENTdetection function; inside repeat ... until \n");
local time, moreToCome, name, msg = EventMonitorCheck("EVENTdetect", "4,1")
if msg ~= nil then
if string.find(msg,"msg1") then
cprintf(cli.lightblue,"msg1 received in PARTY chat. \n");
__WPL:setWaypointIndex(__WPL:findWaypointTag("START"));
end
if string.find(msg,"msg2") then
cprintf(cli.lightblue,"msg2 received in PARTY chat. \n");
__WPL:setWaypointIndex(__WPL:findWaypointTag("SLEEP"));
end
end
until moreToCome == false
end
function startEVENTDetect()
unregisterTimer("EVENTdetection");
printf("EVENT detection started\n");
EventMonitorStart("EVENTdetect", "CHAT_MSG_PARTY");
registerTimer("EVENTdetection", secondsToTimer(10), EVENTdetection);
end
What am I missing? How do I escape the repeat ... until and actually go to the specified waypoints? Thanks.
Re: Monitor chat ... if event XYZ, then load WP/file
The code itself looks fine, only thing I can come up with is the timer is set to 10 seconds, so if you type in party chat a few times before it actually calls the function then it will print in MM for each time.
Try setting it to 1 second calls and see if it helps.
As a side note I added some functions to party.lua to make it easier to monitor party chat.
Try setting it to 1 second calls and see if it helps.
Code: Select all
registerTimer("EVENTdetection", secondsToTimer(1), EVENTdetection);
Remember no matter you do in life to always have a little fun while you are at it
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: Monitor chat ... if event XYZ, then load WP/file
I tried changing the 10 seconds to 1, but it still doesn't escape the repeat...until. Here's what shows up in the MM window: The bot just stands there, then.lisa wrote:The code itself looks fine, only thing I can come up with is the timer is set to 10 seconds, so if you type in party chat a few times before it actually calls the function then it will print in MM for each time.
Try setting it to 1 second calls and see if it helps.As a side note I added some functions to party.lua to make it easier to monitor party chat.Code: Select all
registerTimer("EVENTdetection", secondsToTimer(1), EVENTdetection);
Re: Monitor chat ... if event XYZ, then load WP/file
Just because it keeps printing that message doesn't necessarily mean it's stuck in that loop. It might be stuck somewhere else and the timed event is doing it's thing every second. Where did you start monitoring the event? How did you start it? If you comment out the line that starts the monitor does it still get stuck?
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
Who is online
Users browsing this forum: No registered users and 9 guests