getting mismatch variable error

Posted by Talith on Thu 20 Jan 2005 01:02 PM — 6 posts, 25,539 views.

#0
this script is a counter that counts my skill improvments. I will get a message that will say something like "* You think your offensive skill has improved. *" It will then say "ooc +offensive-X" where x is the number of times i have gotten that message.
Problem is whenever i get a message that says * You think your two-handed sword skill has improved. * i get an error about mismatch variable type.
Here is the trigger and script:

<triggers>
<trigger
enabled="y"
match="* You think your * * skill has improved. *"
script="skills"
send_to="9"
sequence="1"
variable="skills"
other_text_colour="black"
other_back_colour="black"
>
<send>%2%3</send>
</trigger>
<trigger
enabled="y"
keep_evaluating="y"
match="* You think your * skill has improved. *"
script="skills"
send_to="9"
sequence="2"
variable="skills"
other_text_colour="black"
other_back_colour="black"
>
<send>%2</send>
</trigger>
</triggers>



sub skills (sName, b, c)
dim skill
dim chan
skill = world.getvariable ("skills")
chan = world.getvariable (skill)
chan = chan + 1
world.setvariable skill, chan
world.send "ooc +" & skill & "-" & chan
end sub
Russia #1
It might be due to this line in your script:


chan = chan + 1


By the time you reach this point, chan holds a string (since that's what GetVariable() returns), trying to add an integer to a string will give you a type error. Change the line where chan is set, to be:


chan = cint(world.GetVariable(skill))


to make sure that it holds an integer.
USA #2
Why are you setting a variable, and not using the wildcard?

If anything, you could set the variable in your script.

You'd need to do that anyway. Mushclient Variables cannot contain "-" only letters, numbers, and underscores.

So, the "two-handed" is messing it up (you could easily replace - with _, which will get rid of your extra setting/getting of the variable as well (you set the variable via the trigger, then you get it right away, you could use the wildcard, and if you needed to set it (to use in other scripts) you could then set it. If you don't need to set it, you've saved yourself a variable, and a good deal of time.
#3
sub skills (sName, b, c)
dim skill
dim chan
skill = world.getvariable ("skills")
chan = world.getvariable (skill)
chan = chan + 1
world.setvariable skill, chan
world.Replace "skill", "-", "_",
world.send "ooc +" & skill & "-" & chan
end sub


is that how i would use the replace function? Kinda stumped on this one also. If i could get that to work it seems would fix my problems completly. thanks
USA #4
Replace is a VB function, not a Mushclient one. You don't use world. infront of it.

And you need to replace before you set the variable as well.

<triggers>
<trigger
enabled="y"
keep_evaluating="y"
match="* You think your * skill has improved. *"
script="skills"
send_to="1"
sequence="2"
other_text_colour="black"
other_back_colour="black"
>
</trigger>
</triggers>

sub skills (sName, b, c)
dim skill
dim chan
skill = c(2)
skill = replace skill," ", ""
skill = replace skill,"-", "_"
chan = world.getvariable("skill")
chan = chan + 1
world.setvariable skill, chan
world.send "ooc +" & skill & "-" & chan
end sub

That's both of those previous triggers in one trigger. You can edit out the space via a replace (which you had previously used your first trigger for). You can also (since you don't need to share your script) put the script into the send box of the trigger, to encapsulate it better (you'll have to change c(2) to "%2", actually, remove that first line, and replace the 'skill' in the replace function to "%2").
Australia Forum Administrator #5
It is a MUSHclient function. See:

http://www.gammon.com.au/scripts/doc.php?function=Replace

It returns the replaced string. You don't quote the variable, that won't work. Something like:


skill = world.Replace (skill, "-", "_")