How to write trigger for text without newline?

Posted by Tianxz on Sun 23 May 2010 12:36 AM — 17 posts, 74,941 views.

#0
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?
USA #1
Is your question about how to send a newline to the world?

Try using "\n".
USA #2
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");
#3
what is the different between the execute and send?
USA #4
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.
#5
Not only send("2") but also execute('2') can't work correctly.
USA #6
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".
#7
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.
Amended on Sun 23 May 2010 03:11 AM by Tianxz
USA #8
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.
#9
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.
#10
Additional: The first trigger work on input the "enter". I don't why?
#11
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?
USA #12
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...
USA #13
Can't multiline triggers be convinced to process this? At worse, there's always looking at packets received...
Australia Forum Administrator #14
Template:faq=11
Please read the MUSHclient FAQ - point 11.
#15
That is great answer.
USA #16
I've taken the liberty of changing the topic from "How to deal with the problem?" to "How to write trigger for text without newline?" to be more helpful for people trying to search for this later on.