[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]  VBscript
. . -> [Subject]  conditional checking
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

conditional checking

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


Posted by Ignis   (26 posts)  [Biography] bio
Date Thu 09 May 2013 04:46 AM (UTC)

Amended on Thu 09 May 2013 05:02 AM (UTC) by Ignis

Message
I've been setting up triggers to paste channels to a notpad window so that if I'm busy fighting and miss a message it's in another window to find instead of having to wade through scroll back. I'm familiar with vba to a certain extent but keep running into errors. The last channel I'm trying to get to append only shows a person's name and what s/he said.


<Name> the message that was sent

the only problem with doing a match on <*> * is that's also the format for most of the other prompts in game

<[892X] [7835H 13M] [14 Blood]> 


The one thing I do know is the line for that channel will never start with <[, so I tried doing a check but I keep getting an error I don't quite follow.

Here's what I've been trying:

if len(world.replace(%1,"[","")) = len(%1) Then
world.AppendToNotepad "Trigger", %0
end if


and the error I got as this:

Execution of line 1 column 33
Immediate execution
Expected ')'
Line in error: 
if len(world.replace([Crippled] [7835H 13M] [14 Blood],"[","")) = len([Crippled] [7835H 13M] [14 Blood]) Then


I tried adding in an extra ) at the 33rd character but that also didn't fix the issue, is there a way to make this script work? Also I think another issue here is not quite understanding replace and len as I've only really used those in excel/vba/ms office, is it possible to replace characters within a script the way i'm attempting to and then calculate the length of the string?
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 13 May 2013 12:10 PM (UTC)
Message
Can you paste the whole trigger?

Template:copying For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


Looks like this is the issue:

Template:faq=32 Please read the MUSHclient FAQ - point 32.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Ignis   (26 posts)  [Biography] bio
Date Reply #2 on Wed 15 May 2013 02:48 AM (UTC)
Message
Ah, it took me a bit to understand, but yes, that was it!

Finished version:

<triggers>
  <trigger
   enabled="y"
   group="social"
   match="&lt;*&gt;*"
   send_to="12"
   sequence="100"
  >
  <send>If (len (World.Replace ("%1","[","",1)) = len ("%1")) Then
World.AppendToNotepad "Trigger: ", "%0" &amp; vbcrlf
end If
</send>
  </trigger>
</triggers>


the "Trigger: " was to get it to paste to the same notepad window as a few triggers I have that are "send to notepad(append)" instead of "send to script". I might work on converting the others to script as well to clean it up, but the one tip really did help.
[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.


3,262 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]