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
➜ VBscript
➜ Hunt Trigger Not Auto-Disabling
Hunt Trigger Not Auto-Disabling
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| C
(10 posts) Bio
|
Date
| Tue 25 Feb 2003 09:14 PM (UTC) |
Message
| Hey,
I have a trigger that works fine at the moment. It recently decided to add a new feature to it where it will disable itself automatically if my health goes below a certain value. I am able to get my health from the prompt fine, and I have coded all the matches, but it seems even when my health goes below the value I have set, it doesn't disable. Here is the code:
Sub huntCheck (sName, sLine, Wildcards)
dim Health_Status <-- If health goes below this, disable
dim Health <-- Current health
dim Status <-- Checks if the trigger is enabled in the first place
Health_Status = world.GetVariable("healthTrigger")
Health = Wildcards(1)
world.Note Health <--- Displays the correct health / Just there as a test
if Health < Health_Status then
Status = world.GetVariable("hunt")
if HuntStatus = "1" then
world.EnableTrigger "OnLeaving", 0
world.Note "Health Below " & Health & ". Hunt Trigger Disabled."
end if
end if
end sub
My gut feeling is that I am matching strings, so the numeric matching operators aren't going to work. Does that sound reasonable? If so can I convert the health and health status to numbers or is there a string comparison function?
Thanks a lot,
C- | Top |
|
Posted by
| Shadowfyr
USA (1,790 posts) Bio
|
Date
| Reply #1 on Wed 26 Feb 2003 05:09 AM (UTC) |
Message
| Hmm. Good guess. Unfortunate that is exactly what VBScript does every time it handles a variable. I have found that 'often' it guesses wrong in if-then statement and the like. Easiest fix is to place cint() around the places you set them, this should force them into integers and should then work. If you instead used cint() only in the if-then, however it is safer to do it where you first set the values, since that way you don't run into the same problem later. ;) | Top |
|
Posted by
| Rhinoa
United Kingdom (37 posts) Bio
|
Date
| Reply #2 on Wed 26 Feb 2003 07:32 PM (UTC) |
Message
| Isn't the line:
Supposed to be
Since you have it
Status = world.GetVariable("hunt")
Just a thought. :)
~Rhinoa~ | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Tue 04 Mar 2003 12:40 AM (UTC) |
Message
|
Quote:
if Health < Health_Status then
Also I would force them to be integers, otherwise "100" will be less than "20" as a string comparison.
eg.
if CInt (Health) < CInt (Health_Status) then
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
14,675 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top