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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  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] Refresh page


Posted by C   (10 posts)  [Biography] 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-
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] 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. ;)
[Go to top] top

Posted by Rhinoa   United Kingdom  (37 posts)  [Biography] bio
Date Reply #2 on Wed 26 Feb 2003 07:32 PM (UTC)
Message
Isn't the line:
if HuntStatus = "1" then

Supposed to be
 if Status = "1" then

Since you have it
Status = world.GetVariable("hunt")


Just a thought. :)

~Rhinoa~
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] 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
[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.


13,165 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]