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
➜ Problem with DoAfterSpecial
Problem with DoAfterSpecial
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Zorra
(2 posts) Bio
|
Date
| Sat 03 Oct 2009 11:37 AM (UTC) |
Message
| I have a trigger does the following script when match found:
DoAfterSpecial (1, 'Simulate("Find enemies\n")', sendto.script)
However, the program prompts me an error box saying that
[string "Trigger: "]:18: unfinished string near ''Simulate("Find enemies'
What is the problem? When I execute
/world.Simulate("Find enemies\n")
it works just fine. Anyone can help? Thanks a lot in advance | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #1 on Sat 03 Oct 2009 12:03 PM (UTC) Amended on Sat 03 Oct 2009 12:32 PM (UTC) by Worstje
|
Message
| Try:
DoAfterSpecial (1, 'Simulate("Find enemies\\n")', sendto.script)
The \n is interpreted by the 'outer' string and replaced by a newline. Causing the executed script to look like:
Simulate("Find enemies
")
And that is invalid syntax, since a string can't contain a literal newline. Adding the double backslashes makes the outer string turn it into a single backslash, which means the inner string still has a \n to convert.
Edit: Really late edit. Seems the forum somehow ate half the backslashes. | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #2 on Sat 03 Oct 2009 10:11 PM (UTC) |
Message
| Worstje is right, in the "send" box, characters like \n are initially treated by MUSHclient as newlines, so to put them in a script you have to double the backslashes.
However I need to ask why you are using Simulate in a trigger? The Simulate was really intended for debugging scripts, by pumping through simulated MUD output.
What you have shown would put "Find enemies" on a line on its own, but you can use Note or ColourNote for that.
Simulate injects a simulated packet into the input stream, it may cause unexpected results if that packet happens to arrive between two packets from the MUD, perhaps breaking up MUD output in strange ways. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Zorra
(2 posts) Bio
|
Date
| Reply #3 on Sun 04 Oct 2009 05:21 AM (UTC) |
Message
| Thanks a lot Worstje, it works now :D
To Nick, I am using the trigger to do send some control messages. The reason I am using simulate is that sometimes I have to do it offline, and that is the only way I found.. | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #4 on Sun 04 Oct 2009 09:59 AM (UTC) |
Message
| Zorra, the best way to do that would probably be to have a general control function of sorts (e.g. ControlFunction("Stop eating.") or something), and have your triggers and DoAfterFunc() call that.
Although I'd personally go straight to the source and set whatever variables would need setting, rather than simulating anything. | 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.
16,859 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top