[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]  Problem with DoAfterSpecial
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Problem with DoAfterSpecial

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


Posted by Zorra   (2 posts)  [Biography] 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
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,323 posts)  [Biography] 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
[Go to top] top

Posted by Zorra   (2 posts)  [Biography] 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..
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] 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.
[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.


4,012 views.

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]