[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Variable Mismatch problem.

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Variable Mismatch problem.
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Gore   (207 posts)  [Biography] bio
Date Fri 27 Feb 2004 09:59 AM (UTC)  quote  ]
Message
Thanks a lot Nick, I'm not sure how that fixed it, because I had a test echo, that would echo the wildcards, and I'd always get my health and mana. But, I haven't received any errors, so thanks a lot *g*
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Fri 27 Feb 2004 04:32 AM (UTC)  quote  ]
Message
I put an extra line in to display wildcard 1:


note "wildcard 1 = '" & wildcard (1) & "'"


If I have the prompt on the line, I got this:


wildcard 1 = '<33/33 hp 100/100 m 110/110 mv>3387'


And, the "type mismatch" error, because it was trying to convert all that to a number.

What you may want to do is modify the regexp, to only allow numbers through, like this:


match="^(\d*?)h\, (\d*?)m .*?"


Also, the "*" means "zero or more" which may give you a match on just "h", so maybe you should use "one or more" which is "+", like this:


match="^(\d+?)h\, (\d+?)m .*?"

- Nick Gammon

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

Posted by Gore   (207 posts)  [Biography] bio
Date Thu 26 Feb 2004 11:06 PM (UTC)  quote  ]
Message
Hmm, still getting another error, here's the code, output from mud, trigger, and error:

Quote:
Sub Auto_sip (a,b,wildcard)
  Dim health, mana
  health = CInt(Wildcard(1)) 'Line 277
  mana = CInt(Wildcard(2))
  World.ColourNote "black", "white", health & " " & mana
  If health < 2800 then
    If drink = 1 then
      World.Send "drink health"
      drink = 0
    End If
  End If
End Sub

<triggers>
  <trigger
   enabled="y"
   group="autobashing"
   keep_evaluating="y"
   match="^(.*?)h\, (.*?)m *"
   regexp="y"
   script="auto_sip"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>
</triggers>

Error number: -2146828275
Event:        Execution of line 277 column 3
Description:  Type mismatch: 'CInt'
Called by:    Function/Sub: auto_sip called by trigger
Reason: processing trigger ""

3387h, 1746m exk-River long dead.
You see exits leading southeast and southwest.
3387h, 1746m exk-


I don't echo commands, so my prompt won't have anything after it, -until- I send something through.

Any ideas on this one? I don't understand why it's telling me type mismatch. Earlier today I looked up a vbscript reference site, and it had an example of code that was:

CInt(String -variablenamehere-)

But that didn't work either, thanks for your help again, Nick
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Thu 26 Feb 2004 09:31 PM (UTC)  quote  ]

Amended on Thu 26 Feb 2004 09:32 PM (UTC) by Nick Gammon

Message
The trigger wildcard is a string (text) and you want a number. Change the lines to read:

health = CInt (Wildcard(1))
mana = CInt (Wildcard(2))


- Nick Gammon

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

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Thu 26 Feb 2004 07:59 PM (UTC)  quote  ]
Message
Try this perhaps, although i don't know, the trigger looks fine :/

<triggers>
  <trigger
   enabled="y"
   group="autobashing"
   keep_evaluating="y"
   match="^(\d+)h\, (\d+)m"
   regexp="y"
   script="auto_sip"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>
</triggers>


Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Gore   (207 posts)  [Biography] bio
Date Thu 26 Feb 2004 04:16 PM (UTC)  quote  ]
Message
Here's the trigger:

Quote:
<triggers>
  <trigger
   enabled="y"
   group="autobashing"
   keep_evaluating="y"
   match="^(.*?)h\, (.*?)m .*?"
   regexp="y"
   script="auto_sip"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>
</triggers>

Example prompt:

3387h, 2253m ex-
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Thu 26 Feb 2004 04:00 PM (UTC)  quote  ]
Message
Hm, if it matches on text instead of a number you could try changing the regular expression to match on a character, which is (\<IDontRememberTheCharCode:P>+), and then do a CInt perhaps?

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Gore   (207 posts)  [Biography] bio
Date Thu 26 Feb 2004 01:19 PM (UTC)  quote  ]
Message
er, Also, I tried to do stuff like..

health = CInt(Wildcard(1) but I got some CInt problems, any ideas on that as well?
[Go to top] top

Posted by Gore   (207 posts)  [Biography] bio
Date Thu 26 Feb 2004 10:55 AM (UTC)  quote  ]
Message
What's up.. I'm having a problem with one of my variables. Here's my code:

Quote:
Sub Auto_sip (a,b,wildcard)
  Dim health
  Dim mana
  health = Wildcard(1)
  mana = Wildcard(2)
  If health < 2800 then
    If drink = 1 then
      World.Send "drink health"
      drink = 0
    End If
  End If
End Sub


The problem I'm getting is Type Mismatch: health

Any help would be appreciated, thanks!
[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.


2,540 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]