Trigger problem

Posted by Stormy on Fri 30 Apr 2004 08:50 AM — 3 posts, 15,808 views.

#0
Hi there,

Got a bit of a problem. I'm trying to make a trigger to show experience gain/loss in RetroMUD. the status bar ingame, which shows after each time you enter a command or simply hit enter, shows in the format:

Hp: 584/584 Sp: 1223/1223 Ep: 280/280 Gold: 212 Exp: 1166950 >

/world.debug "triggers" shows:

{{Hp: * Sp: * Ep: * Gold: * Exp: * >}}={{%5}} label=iworldexp script=expgained colour=1 send_to:variable seq:100

and the expgained script is:

sub expgained (thename, theoutput, thewildcards)

dim iNewexp
dim iOldexp
dim iDiff

iOldExp=world.GetVariable("ioldexp")
iNewExp=world.GetVariable("iworldexp")

if iNewexp > iOldexp then
iDiff=iNewexp-iOldexp
world.note "Exp gained : " & cstr (iDiff)
end if
if iNewexp < iOldexp then
iDiff=iOldexp-iNewexp
world.note "Exp lost : " & cstr (iDiff)
end if

if iNewexp=iOldexp then
world.note "No exp change"
end if
World.SetVariable "ioldexp", iNewexp
end sub

/world.debug "variables" :

iworldexp = 1166950
ioldexp = 1166950

Can anyone see what I'm missing? It just doesn't want to work :(

Thanks!
USA #1
Why are you sending to variable? You can just get it from the wildcards.

Anyway, you might be better off declaring outside of your sub, and then not storing the oldxp in an MC variable, just use a VBscript. Itll stay as long as you dont need to reset your script. And even then, itll only last for one promt, then itll get re-written. Itll save you a lot of time for your script, and since this happens a lot, it might make a difference.

<wrong>
For your if statement, you need to have a double equals sign (==) (since its logical). </wrong> (No, Its not, I was just being weird and staying in C (actually, I think it was TIBasic), pay no attention to the man behind the curtain)

This is assuming your trigger matches. Theres plenty of problems associated with matching a prompt, search the forums for a bunch of threads on it. You might be fine if you simply add a spot for other stuff at the end of your prompt (see other threads for more details). This MIGHT require you to convert your trigger to a regexp.

To see if your trigger is matching all the time, you can turn trace on. This way you can see if your problem is in the trigger, or the script, for any given time.

Also, for future reference, copy/paste your trigger/alias/whatever rather than doing the debug thing.
Amended on Sat 01 May 2004 06:38 PM by Flannel
Greece #2
Actually, VBScript doesn't use the == operator, = is right. And yes, it would be better if instead of sending to a variable you used a scripting variable. If you need to save the script with its variables, you could try SetVariable to do it from within the script.