[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  How to write trigger for text without newline?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

How to write trigger for text without newline?

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


Pages: 1 2  

Posted by Tianxz   (30 posts)  [Biography] bio
Date Sun 23 May 2010 12:36 AM (UTC)
Message
In the mud. The server ask me to choose 1 or 2. I want to input by robot. I use the code in PHP:
$world->Execute(2);

But It can't run correct. It need a 'enter'. How can I do it?
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #1 on Sun 23 May 2010 12:45 AM (UTC)
Message
Is your question about how to send a newline to the world?

Try using "\n".

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #2 on Sun 23 May 2010 01:29 AM (UTC)
Message
You might want to try just using Send, because I don't think you're planning on having a 2 alias (are you?)

$world->Send("2");

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Tianxz   (30 posts)  [Biography] bio
Date Reply #3 on Sun 23 May 2010 02:13 AM (UTC)
Message
what is the different between the execute and send?
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #4 on Sun 23 May 2010 02:16 AM (UTC)
Message
Execute checks aliases first, Send doesn't.

Though, neither of them needs a newline at the end, they both add one automatically. Perhaps you should try quoting the number, that is, "2" instead of 2. $world->Execute("2") should work fine.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Tianxz   (30 posts)  [Biography] bio
Date Reply #5 on Sun 23 May 2010 02:34 AM (UTC)
Message
Not only send("2") but also execute('2') can't work correctly.
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #6 on Sun 23 May 2010 02:40 AM (UTC)
Message
Please make sure you're using Execute, not execute, and Send, not send. Other than that... well, please explain exactly what you mean by "can't work correctly".

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Tianxz   (30 posts)  [Biography] bio
Date Reply #7 on Sun 23 May 2010 03:00 AM (UTC)

Amended on Sun 23 May 2010 03:11 AM (UTC) by Tianxz

Message
I use the Send and Execute to try it. But both can't work correctly.

The problem is
The mud ask me a Question A. Then the trigger will answer this question with 2. I use the command:/$world.Send('2');

Then the mud continue ask me another Question.

I trace it and find the trigger doesn't work before I input the "Enter". The trigger on question A only work after I input "enter". So I think the regular expression is good. It can't work after I input "enter" if it is wrong. I find when I input the "enter" just send the answer to question 2. But I don't know where is the problem.

Thank you.
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #8 on Sun 23 May 2010 03:10 AM (UTC)
Message
What's the "Send to" box set to? It should be set to "Script", and make sure there's no slash on that line.

In this case, you could also set "Send to" to "World", and just have 2 in the send box. That would do the exact same thing.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Tianxz   (30 posts)  [Biography] bio
Date Reply #9 on Sun 23 May 2010 03:24 AM (UTC)
Message
Yes,I send to script.

There are four question and one by one.

First, Mud send the question A to me. I make a trigger on question A and send $world->Send('2'); to script. But The mud can't send the question B to me. It Send the question B and C to me after I input the "enter" in command window. It only ask me answer the question C.

If I send the $world->Send('2');$world->Send('1'); to the script. It still can't display next question. Only after I inut the "enter", it send the the question B,C and Dto me and ask me answer the question D.

If I don't input the "enter", it can't trigger the trigger and send answer to server even I choice send it to world immediate with 2.
[Go to top] top

Posted by Tianxz   (30 posts)  [Biography] bio
Date Reply #10 on Sun 23 May 2010 03:26 AM (UTC)
Message
Additional: The first trigger work on input the "enter". I don't why?
[Go to top] top

Posted by Tianxz   (30 posts)  [Biography] bio
Date Reply #11 on Sun 23 May 2010 03:32 AM (UTC)
Message
Oh. I found the problem prehaps is the question a doesn't send the \n to mushclient. So the trigger can't be triggered. How can I do it?
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #12 on Sun 23 May 2010 03:35 AM (UTC)
Message
Ahh, that explains a lot. Hmm... You might want to try enabling "Convert IAC EOR/GA to newline". It's in Game -> Configure -> Output, at the bottom of the list on the right.

If that doesn't work, there's not much more you can do. If all of these questions come in the same order every time, you can try triggering on a line right before the first question, and sending your answers all at once. It's a little hacky, but under the circumstances...

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #13 on Sun 23 May 2010 06:09 AM (UTC)
Message
Can't multiline triggers be convinced to process this? At worse, there's always looking at packets received...

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Gammon   Australia  (21,323 posts)  [Biography] bio   Forum Administrator
Date Reply #14 on Sun 23 May 2010 06:17 AM (UTC)
Message
Template:faq=11 Please read the MUSHclient FAQ - point 11.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


11,065 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]