Hunt Trigger Not Auto-Disabling

Posted by C on Tue 25 Feb 2003 09:14 PM — 4 posts, 18,850 views.

#0
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-
USA #1
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. ;)
United Kingdom #2
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~
Australia Forum Administrator #3
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