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 ➜ Trying to create a VB Script

Trying to create a VB Script

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,133 posts)  Bio   Forum Administrator
Date Reply #15 on Mon 07 Jan 2002 10:09 PM (UTC)
Message
Magnum didn't mean to repeat "world.note", here is what the line should have read:



World.Note " CurrentHP: " & World.GetVariable("CurrentHP") & " HP: " & World.GetVariable("hp")


Enter as one line, even if it wraps into two or more on the forum.

- Nick Gammon

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

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #16 on Wed 09 Jan 2002 01:14 AM (UTC)
Message
Careful about making assumptions about what you expect to be in a variable, especially when you are attempting to debug your script.

Nick is correct, of course. I put an extra "World.Note" in by mistake.

Try his line for a while to confirm BOTH variables are what you expect. When you are sure one or both are correct, remove what you don't want to see anymore.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Mike Kilian   (15 posts)  Bio
Date Reply #17 on Thu 10 Jan 2002 05:09 PM (UTC)
Message
Ok, used it and here's what I get: When @hp<1000 and @CurrentHP>999, except when @hp=100, there is an error in the math function.

Example:

@CurrentHP=1123 @hp=250 comes back as @CurrentHP<@hp.
@CurrentHP=1123 @hp=100 comes back as @CurrentHP>@hp.
@CurrentHP=1123 @hp=1050 comes back as @CurrentHP>@hp.

It's not the trigger, it's not the variables. I even put a "." at the end of the variable to make sure there wasn't a wierd space there when displaying it. Here's the VB script again:

Sub Heal_Action
if world.getvariable("tank") = world.getvariable("name") then
World.Note " CurrentHP: " & World.GetVariable("CurrentHP") &"." & " HP: " & World.GetVariable("hp") &"."
if world.getvariable("CurrentHP") < world.getvariable("hp") then
World.Send "cast '" & World.GetVariable("spell") & "' " & World.GetVariable("name")
end if
end if
End Sub

Mike
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #18 on Thu 10 Jan 2002 10:04 PM (UTC)

Amended on Fri 11 Jan 2002 04:56 AM (UTC) by Nick Gammon

Message
The way that variables are stored is as text, so the comparison is between "1123" and "250", and since "1xxx" is less than "2xxx" it comes back as "less than".

You can fix that by converting to integer (cint), in which case the comparison works correctly, eg.


if cint(world.getvariable("CurrentHP")) < cint(world.getvariable("hp")) then


- Nick Gammon

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

Posted by Mike Kilian   (15 posts)  Bio
Date Reply #19 on Fri 11 Jan 2002 03:19 AM (UTC)
Message
That makes perfect sense. Thanks again! I'm sure al lwill be ok now, but if more problems arise I know where to come.

Mike
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.


49,117 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.