Variable Mismatch problem.

Posted by Gore on Thu 26 Feb 2004 10:55 AM — 9 posts, 28,495 views.

#0
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!
#1
er, Also, I tried to do stuff like..

health = CInt(Wildcard(1) but I got some CInt problems, any ideas on that as well?
Greece #2
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?
#3
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-
Greece #4
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>

Australia Forum Administrator #5
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))

Amended on Thu 26 Feb 2004 09:32 PM by Nick Gammon
#6
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
Australia Forum Administrator #7
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 .*?"
#8
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*