Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ how to fire a trigger when receive messages without newline characters?

how to fire a trigger when receive messages without newline characters?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Jcl   (42 posts)  Bio
Date Tue 16 Apr 2013 09:46 AM (UTC)
Message
When receive messages without newline characters, how can I fire a trigger?
For example, MUD server send a message "100/100> ", a second later, MUD server send another message "99/100> ", and so on.
Client will displays messages as "100/100> 99/100> ...".
I need to fire a trigger when incoming number less than "80/100> ", how can I do it?

Thanks.
Top

Posted by AnalogConspiracy   (9 posts)  Bio
Date Reply #1 on Wed 17 Apr 2013 02:06 PM (UTC)

Amended on Wed 17 Apr 2013 04:20 PM (UTC) by AnalogConspiracy

Message
There's various things on the forum that answer exactly that question.

I'd like you to try and find it, for the best possible answer.

However, I'd probably use in IF statement.

"100/100" would need to be "(.+)\/100" (Regex, will use LUA as well). I don't know the full line, so you can do the matchline yourself.

if "%1" < 100 then
Note("This trigger has fired successfully.")
end -- if statement.

If you can't find what I'm talking about, please respond saying so, and I shall fetch it.

EDIT: Actually, how about <= 100 instead? That's less than or equal to.

-- Analog
Top

Posted by Fiendish   USA  (2,535 posts)  Bio   Global Moderator
Date Reply #2 on Thu 18 Apr 2013 04:30 AM (UTC)
Message
Quote:
There's various things on the forum that answer exactly that question.
Erm...sort of, but not well.

Jcl, if you enable the "Convert IAC EOR/GA to new line" option in Game->Configure->Output, does that break those chunks up into multiple lines?

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Jcl   (42 posts)  Bio
Date Reply #3 on Thu 18 Apr 2013 10:29 AM (UTC)
Message
AnalogConspiracy said:

There's various things on the forum that answer exactly that question.

I'd like you to try and find it, for the best possible answer.

However, I'd probably use in IF statement.

"100/100" would need to be "(.+)\/100" (Regex, will use LUA as well). I don't know the full line, so you can do the matchline yourself.

if "%1" < 100 then
Note("This trigger has fired successfully.")
end -- if statement.

If you can't find what I'm talking about, please respond saying so, and I shall fetch it.

EDIT: Actually, how about <= 100 instead? That's less than or equal to.


Thanks for your post.
The question is not about the trigger itself, but the line has not been terminated by a newline character.
I will try OnPluginPacketReceived later.
Top

Posted by Jcl   (42 posts)  Bio
Date Reply #4 on Thu 18 Apr 2013 10:38 AM (UTC)
Message
Fiendish said:

Quote:
There's various things on the forum that answer exactly that question.
Erm...sort of, but not well.

Jcl, if you enable the "Convert IAC EOR/GA to new line" option in Game->Configure->Output, does that break those chunks up into multiple lines?


Yes, it works, but only once!
Before, it displays:
Quote:

100/100> 99/100> 98/100> 97/100> 96/100> ...

After enable the "Convert IAC EOR/GA to new line" option, it displays:
Quote:

100/100>
99/100> 98/100> 97/100> 96/100> ...


I searched the forum and found OnPluginPacketReceived. I will try it later.

Thanks a lot.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 18 Apr 2013 12:09 PM (UTC)
Message
Template:faq=11 Please read the MUSHclient FAQ - point 11.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Jcl   (42 posts)  Bio
Date Reply #6 on Fri 19 Apr 2013 07:30 AM (UTC)
Message
Nick Gammon said:

(faq=11)


I have tried using OnPluginPacketReceived, and it worked.
But I found that parsing all packets in Lua have performance problems. It is as slow as Zmud!
Can you setup a option about whether to resolve the prompt line in C++ ?
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #7 on Fri 19 Apr 2013 10:52 PM (UTC)
Message
Can you show your plugin? A simple string replace shouldn't take that long.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Jcl   (42 posts)  Bio
Date Reply #8 on Sat 20 Apr 2013 05:09 AM (UTC)

Amended on Sat 20 Apr 2013 05:10 AM (UTC) by Jcl

Message
Nick Gammon said:

Can you show your plugin? A simple string replace shouldn't take that long.




local prompt_expr1 = ".%[256D.%[1;32m%d+/%d+.%[1;33m>%s.%[2;37;0m"
local prompt_expr2 = ".%[256D.%[1;32m(%d+)/(%d+).%[1;33m>%s.%[2;37;0m"
function OnPluginPacketReceived(sText)
	local nText = string.gsub(sText, prompt_expr1, function(s)
		local mana, hp = string.match(s, prompt_expr2)
		SetStatus("" .. mana .. "/" .. hp)
		return ""
	end)
	return nText
end -- function
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #9 on Sun 21 Apr 2013 10:05 AM (UTC)
Message
What's the SetStatus doing there? That will take a little while. It's not the place for it.

Detect your mana in the trigger and do the SetStatus there.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Jcl   (42 posts)  Bio
Date Reply #10 on Mon 22 Apr 2013 02:51 AM (UTC)
Message
Nick Gammon said:

What's the SetStatus doing there? That will take a little while. It's not the place for it.

Detect your mana in the trigger and do the SetStatus there.


I need to detect mana to do something automatically, and I need to see it for do something manually.
Do you have any good suggestions?
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


31,247 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.