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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  getting mismatch variable error

getting mismatch variable error

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


Posted by Talith   (3 posts)  [Biography] bio
Date Thu 20 Jan 2005 01:02 PM (UTC)
Message
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
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #1 on Thu 20 Jan 2005 03:20 PM (UTC)
Message
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.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #2 on Thu 20 Jan 2005 07:20 PM (UTC)
Message
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.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Talith   (3 posts)  [Biography] bio
Date Reply #3 on Sun 23 Jan 2005 04:51 PM (UTC)
Message
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
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #4 on Mon 24 Jan 2005 06:56 AM (UTC)
Message
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").

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Wed 26 Jan 2005 01:12 AM (UTC)
Message
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, "-", "_")

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


16,493 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 HostDash]