Register forum user name Search FAQ

Gammon Forum

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 ➜ Regular Exp Trigger problem

Regular Exp Trigger problem

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


Pages: 1  2 

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #15 on Fri 03 Feb 2006 05:11 AM (UTC)
Message
You have misinterpreted the documentation slightly. It says the returned results are:


The contents of the specified trigger wildcard, as described above.

An EMPTY variant, if the trigger does not exist.
A NULL variant if the trigger name is invalid.
An empty string if the wildcard does not exist.


An empty variant is something you test with "IsEmpty" - that is returned if the trigger does not exist. However your trigger does exist.

An empty string is what is returned if the wildcard does not exist. An empty string is this: "".

So your code should read like this:


if gain <> "" then
  ColourNote "white", "red", gain
end if


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #16 on Fri 03 Feb 2006 05:14 AM (UTC)

Amended on Fri 03 Feb 2006 05:17 AM (UTC) by Nick Gammon

Message
I have amended the documentation for GetTriggerWildcard to make that a bit clearer.


You can test this sort of thing yourself. I did this:


Note (VarType (GetTriggerWildcard ("mytrigger", 1)))
Note (VarType (GetTriggerWildcard ("mytrigger", 8)))


It was clear from the results (8 and 8) that I was getting a string result, however in the second case the string was an empty string.

See the VBscript documentation for the meaning of VarType:


vbEmpty     0 Empty (uninitialized) 
vbNull      1 Null (no valid data) 
vbInteger   2 Integer 
vbLong      3 Long integer 
vbSingle    4 Single-precision floating-point number 
vbDouble    5 Double-precision floating-point number 
vbCurrency  6 Currency 
vbDate      7 Date 
vbString    8 String 
vbObject    9 Automation object 
vbError    10 Error 
vbBoolean  11 Boolean 
vbVariant  12 Variant (used only with arrays of Variants) 


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #17 on Fri 03 Feb 2006 06:05 AM (UTC)
Message
Thanks a bunch Nick, I greatly appreciate it.

I can't even tell you how frustrated I was. I'm glad you noticed that I was misunderstanding what it meant. Cause I had no idea.

But It's working perfectly now.

Final Trigger:
<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   keep_evaluating="y"
   match="^\&lt;(.*?)\%\&gt; \/ \&lt;(.*?)/(.*?)\&gt;(( vs. \&lt;(.*)\&gt;)?| (\+(.*) Max Powerlevel)?)$"
   name="Prompt"
   regexp="y"
   repeat="y"
   send_to="12"
  >
  <send>maxpl = GetTriggerWildcard ("Prompt", 3)
form = "@Form"
SetVariable "MaxPowerLevel", maxpl
if form = "Super Saiyan" then
expectedgain = Int((maxpl / 2) * .05)
elseif form = "Super Saiyan 2" then
expectedgain = Int((maxpl / 3) * .05)
elseif form = "Super Saiyan 3" then
expectedgain = Int((maxpl / 4) * .05)
elseif form = "Ultimate Super Saiyan" then
expectedgain = Int((maxpl / 2) * .05)
elseif form = "2" then
expectedgain = Int((maxpl / 1.25) * .05)
elseif form = "3" then
expectedgain = Int((maxpl / 1.75) * .05)
elseif form = "4" then
expectedgain = Int((maxpl / 2.625) * .05)
else
expectedgain = Int(maxpl * .05)
end if

sleep = GetVariable("Sleep")
gain = GetTriggerWildcard ("Prompt" , 8)

if sleep = "sleeping" then
if gain &lt;&gt; "" then
gamesessiongain = Int(GetVariable("GameSessionGain")) + gain
powerlevelgain = Int(GetVariable("PowerLevelGained")) + gain
SetVariable "PowerLevelGained", FormatNumber(powerlevelgain,0,0,0,-1)
SetVariable "GameSessionGain", FormatNumber(gamesessiongain,0,0,0,-1)
Note "Current gain is: +" &amp; FormatNumber(powerlevelgain,0,0,0,-1)
end if
end if
SetVariable "Expectedgain", expectedgain</send>
  </trigger>
</triggers>
Works like a charm with a few other triggers I have.
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.


67,488 views.

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

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

Go to topic:           Search the forum


[Go to top] top

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