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.
 Entire forum ➜ MUSHclient ➜ General ➜ what am I doing wrong?

what am I doing wrong?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Guest1   USA  (256 posts)
Date Tue 05 Aug 2003 07:28 PM (UTC)
Message
I've narrowed down one of the problems to the following trigger (MC freezes when it happens)

trigger fires on:
Total exp for kill is *.

send to: World

calls script 'expcounter'


..should the 'send to' field be set to something else? Should there be something else checked? The value for * is a numerical value.


The script it calls always worked before I upgraded to 3.42:


sub expcounter (thename, theoutput, thewildcards)
   dim expnew
   dim expold
   dim expnewtotal
	expnew =  thewildcards (1)
	expold = World.GetVariable("groupexptotal")
	expnewtotal = cLng(expold) + cLng(expnew)
		World.SetVariable "groupexptotal", expnewtotal
end sub


anyone?
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 05 Aug 2003 08:38 PM (UTC)
Message
Looks OK from here. Can you paste two more things?

* The actual trigger - click the copy button when it is highlighted in the trigger list.

* A line from the MUD that it will match on.

Also, can you confirm it is indeed this trigger alone? ie. make a new world file, just paste in this trigger and the script, and try it on a suitable line (you can use Ctrl+Shift+F12 to dummy-up a line).

- Nick Gammon

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

Posted by Guest1   USA  (256 posts)
Date Reply #2 on Tue 05 Aug 2003 09:05 PM (UTC)
Message
here's the full trigger:


  <trigger
   group="reports"
   keep_evaluating="y"
   match="Total exp for kill is *."
   script="expcounter"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>


and here's the line from mud it matches on:


Total exp for kill is 19221.


There is another trigger that fires on the same thing which is why keep_evaluating="y" .. I've alternately enabled/disabled each but the other one is fine.. Here's the other one in if you want to see:


  <trigger
   enabled="y"
   group="loot"
   keep_evaluating="y"
   match="Total exp for kill is *."
   name="lootsolo"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  <send>get all corpse
sacrifice corpse
save</send>
  </trigger>


On the one with the problem, should the 'send to' field be set to something else, like send to script..? (currently set to 'send to world')

Hrmm.. ok I tried it on it's own on a separate character etc and it worked fine. Now I'm confused.
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #3 on Tue 05 Aug 2003 10:42 PM (UTC)
Message
Since the "send" text is empty it doesn't really matter where it is sent to.

I notice you have:

World.GetVariable("groupexptotal")

I wonder what "groupexptotal" contains? Is it a non-number for instance, or not there at all? Use the variables configuration screen to check that out.

- Nick Gammon

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

Posted by Guest1   USA  (256 posts)
Date Reply #4 on Wed 06 Aug 2003 12:13 AM (UTC)
Message
yup already checked that - it is numerical and not misspelt etc. A separate alias sets the value originally when I reset my group experience counter, and that still works fine. I think it may be a combination of other triggers that use the same line to match on ..possibly. I'm going to rewrite it from scratch I think.

Also I have another very basic trigger that fires when I cast aegis on myself. It does two things: it grouptells that my aegis is up, and also calls a script that starts a 'ticks remaining on aegis' countdown timer as well as a 30 second warning to advise when the aegis is about to drop. For some reason it didn't do the grouptell when I cast aegis. I made no changes to it. After the aegis dropped, I recast it and this time it did do the grouptell (both times the script was called ok) ..some strange things going on I just can't explain.
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #5 on Wed 06 Aug 2003 01:14 AM (UTC)
Message
It doesn't fail for me (nor did it for you in your other world). I tried a very large number in the total experience with no great ill effect (except an overflow message).

I can't think what it is, except that some combination of things is doing it.

All I can suggest is either email me the world file (zip it up to make it smaller) or try to isolate it down in a separate (smaller) world file and email me that one.

Try copying the variables from the non-working world to the other one - maybe the variable content influences it somehow.

Perhaps copy and paste that variable here?

- Nick Gammon

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

Posted by Guest1   USA  (256 posts)
Date Reply #6 on Wed 06 Aug 2003 03:59 AM (UTC)
Message
Here's a question you can hopefully answer while I'm going through everything.

I have a line from the mud that I want to match on and have 3 things occur;

(a) change the value of a variable
(b) cast a spell (send a command to the mud)
(c) call another script that resets a timer to keep it in synch with the mud ticks

This is actually the same for about 15 different mud-generated messages as it happens, except that each one (a) sends a different command (spell) to the mud and (b) changes the value of a different variable, but they all call the same timer reset script (c).

Presently in each case I have 3 separate triggers all firing from the same matching line and have them all set for 'keep evaluating'. One sends a command (spell) to the mud, one sets the individual variable for that match, and one calls the reset timer script.

Is this the best way to do it, or is it better to just have the one trigger for each message and have it call a script which will perform all 3 functions above? ..keeping in mind that one of those 3 functions is the same subroutine for all 15 different mud messages.. Does it even matter which way I go?
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #7 on Wed 06 Aug 2003 04:16 AM (UTC)
Message
To save your sanity I would combine and simplify all those by using the new "send to script" feature. eg. Rather than having 3 triggers all of which match the same thing and keep evaluating, do something like this:

match="Total exp for kill is *."

send:


SetVariable "foo", "bar"
Send "cast 'foobah' "
ResetTimer "ticktimer"


send to: script


If you want to call a sub in your script file you can do that too. eg.

send:


SetVariable "foo", "bar"
Send "cast 'foobah' "
ResetTimer "ticktimer"
mysub "%1"


That example calls "mysub" passing the first wildcard as a string argument. Thus mysub would be declared like this:


sub mysub (x)
  Note x
end sub




- Nick Gammon

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

Posted by Guest1   USA  (256 posts)
Date Reply #8 on Wed 06 Aug 2003 05:05 AM (UTC)

Amended on Wed 06 Aug 2003 05:15 AM (UTC) by Guest1

Message
Wow that is excellent! Thanks Nick.

In the triggers I'm working on atm there is no wildcard; the variable that is being set is just to say that a spell is down which is then called by another script and spat out as a world note when I enter an alias - (this is purely just to save me typing 'score' and trying to figure out which of the many spells I cast on myself are not up).

This is a damn kewl feature I wasn't aware of, which will change much of the existing scripts/triggers I have, including some of the ones that appear to have been freezing up MC for me since I upgraded. Nice work Nick.

Just to confirm I understood you correctly, I have a heap of other triggers that just call a subroutine and nothing else (no wildcard involved). Presently this is done by having the sub name being called in the 'script:' field at the lower right of the edit trigger window.
Instead of that, can I just select 'send to script' and write the sub name I want to call in the big send field in some form? (This is what I'll be wanting to do with the triggers I mentioned in my previous post), something like this:

SetVariable "strength", "down"
Send "cast 'strength'"
Reset_Timer     ( <-- the name of the subroutine to be called )

or would I instead do 'sent to script' and write

SetVariable "strength", "down"
Send "cast 'strength'"

in the big send field, and then also on that same trigger have the script to be called entered in the script field at the lower right of the edit trigger window? Just need to clarify which way to do that..

note: I realize I can write
ResetTimer "ticktimer"
in there and avoid a sub altogether, but in other cases I need to call a sub.

FYI the reason for the spell down thing is that if the spell falls while I'm fighting (which is often) I can't recast it until I've finished that fight. In the case of long fights (also fairly often) several spells may fall and I don't notice it amongst the spam of the fight, hence the world note I can bring up after the fight to see what spells may have fallen.
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #9 on Wed 06 Aug 2003 05:13 AM (UTC)
Message
Either way will work, but I think it is less confusing to put it all in the one place. *However* the difference is the way the sub is written.

Your current method, which is having the trigger call the script from putting the script name in the "script" box needs the script sub to look like this:

sub mysub (thename, theoutput, thewildcards)
' blah blah
end sub

However if you call it like you suggested:

Reset_Timer ( <-- the name of the subroutine to be called )


Then the sub will not take arguments, and should look like this:

sub Reset_Timer
' blah blah
end sub






- Nick Gammon

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

Posted by Guest1   USA  (256 posts)
Date Reply #10 on Wed 06 Aug 2003 05:31 AM (UTC)
Message
Ahh ok thank you, this is a really useful improvement Nick. I'll get back into the coding now (I agree - tidier putting them all in one place). Some of my existing scripts were written a few years back when I first started mudding and using MC, so a rewrite and tidy-up of my entire world & script files is pretty much required anyway hehe. Strange, I sometimes actually enjoy doing the coding more than playing the mud. Go figure.

note: I realize in the case above I can write
ResetTimer "nameoftimer"
in there for timers and avoid a sub altogether, but in other cases I will need to call a sub anyway, so thanks for the clarification.
Top

Posted by Guest1   USA  (256 posts)
Date Reply #11 on Wed 06 Aug 2003 06:36 AM (UTC)
Message
Another question. I'm guessing it's ok but thought I'd check. Will expand variables work ok with 'send to: script' option? eg:

trigger:
You are thirsty.

send:
tickset
Send "drink @containerdrink"

send to: script

expand variables: Y
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #12 on Wed 06 Aug 2003 07:59 AM (UTC)
Message
I think it will, but that is the sort of thing that it is much quicker to try for yourself, rather than post a question.

Just make a trigger that is likely to match something soon, and do something like:

Note "test @weapon"

... where "weapon" is one of your variables.

Either you will see it expanded or not. If not, this will always work:

Note "blah " & GetVariable ("weapon")


- Nick Gammon

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

Posted by Guest1   USA  (256 posts)
Date Reply #13 on Wed 06 Aug 2003 07:17 PM (UTC)

Amended on Wed 06 Aug 2003 07:23 PM (UTC) by Guest1

Message
Ok, just so you know, using expand variables with send to script works fine. Thanks for your help and advice Nick :)

I've rewritten the script and it all seems to be working fine so far, although I've yet to tank a group and test that part. There was a few routines I was able to chop entirely by building them into others which seems to have stopped the crashing so that's all good.

Just out of interest, can you use an expanded variable in a trigger line? ie: match on:

@tank is dead! R.I.P.

instead of using

* is dead! R.I.P.

and using a sub to see if the wildcard = variable for tank.

..I guess I should try it myself instead of asking hehe.
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.


29,595 views.

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.