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
➜ basic help please
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| Guest1
USA (256 posts) |
Date
| Wed 22 May 2002 05:36 PM (UTC) |
Message
| i have an alias that calls a subroutine that sets a variable, which works fine. The variable name is 'stabperson' and the contents are the playername of the person who is currently the designated 'stabber' when in a group. No worries so far.
I am then trying to set a trigger so that when that particular person (and ONLY that person) stabs something, I automatically rescue them. This is where I'm having the problem.
the syntax when they stab is
"playername places an ice chisel in the back of the..."
so I have tried setting a trigger like this..
trigger: * places
send: rescue @stabperson
i have 'expand variables' checked and have tried this trigger with ' send : rescue @@stabperson ' as well, with no luck. Ideally I want the trigger set up so that the trigger AND what it sends is particular only to whatever the variable is that I've set.. like
trigger : @stabperson places
send : rescue @stabperson
can someone please help me with the correct syntax for this trigger and what it sends?
thanks | Top |
|
Posted by
| Guest1
USA (256 posts) |
Date
| Reply #1 on Wed 22 May 2002 05:47 PM (UTC) |
Message
| ..add on
I'm aware I could just have
trigger : * places
send : rescue %1
but I don't want it to be activated by anyone other than the playername i set in the variable.. :) | Top |
|
Posted by
| Magnum
Canada (580 posts) Bio
|
Date
| Reply #2 on Wed 22 May 2002 07:03 PM (UTC) |
Message
| Trigger: @stabperson places *
Expand Variables: Checked
Enabled: Checked
Send: rescue @stabperson
You were forgetting to allow for the rest of the text on the line... |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | Top |
|
Posted by
| Shadowfyr
USA (1,788 posts) Bio
|
Date
| Reply #3 on Wed 22 May 2002 07:17 PM (UTC) Amended on Wed 22 May 2002 07:18 PM (UTC) by Shadowfyr
|
Message
| Ok first off.. Simply using one word to match along with the name is asking from trouble. I imagine that if 'Someone places a pot on the ground' they probably don't need rescuing. ;)
Your second problem is that using only one word like that requires regular expressions, which makes the possible errors even worse in your case since it would hit on 'any' match in which the word 'places' was found with at least one word in front of it.
So here's the simplest solution:
trigger : ^@stabperson places an ice chisel in the back of the .*
send : rescue @stabperson
Regular Expression: Checked
The .* is the key here since now the trigger says 'Match on the variable followed by "places an ice..." and then followed by anything else that may be there.', where your attempt said 'Match if there are -only- two words and the second one is "places"'.
This (assuming is even works lol) should be spoof proof, since the ^ will only allow it to match if it is at the start of the line and not in the middle of a tell, etc.
Hope this helps. It would probably be the first time I got a regular expression right the first try. ;) lol | Top |
|
Posted by
| Guest1
USA (256 posts) |
Date
| Reply #4 on Wed 22 May 2002 08:09 PM (UTC) |
Message
| Thankyou both for your help.
Magnum - hehe yup I realised a little later that I had forgotton the * at the end to cover the rest of the line.. no wonder nothing would work.
Shadowfyr - unfortunately I cannot go any further than using '* places' as the weapons used vary greatly, however, the ^ is a great help, thanks.
By using the set variable at least i'll be limited to rescuing the designated stabber if they place a pot on the ground. Ya never know, it might be a very violent pot that doesn't like being placed on the ground :)
thanks again. If I have any probs, I'll post again. If not, you'll know you got it right first try :)
cheers | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #5 on Wed 22 May 2002 10:32 PM (UTC) |
Message
| The syntax:
^@stabperson places an ice chisel in the back of the .*
won't work because of a bug in MUSHclient that is fixed in 3.23.
However for now, match on everything, and test it in a script, eg like this:
<triggers>
<trigger
enabled="y"
match="^(.*) places an ice chisel in the back of the .*"
name="stab"
regexp="y"
script="OnStab"
sequence="100"
>
</trigger>
</triggers>
Script ...
sub OnStab (sName, sLine, wildcards)
if wildcards (1) = world.getvariable ("stabperson") then
world.send "rescue " & wildcards (1)
end if
end sub
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Guest1
USA (256 posts) |
Date
| Reply #6 on Wed 22 May 2002 11:34 PM (UTC) Amended on Thu 23 May 2002 12:20 AM (UTC) by Nick Gammon
|
Message
| Thanks for that :) will be testing it out soon.
I have another one for ya.. this one hopefully more basic. All I'm trying to do is to omit output from a world.send command sent from a sub routine..
I actually got it to work, but then it seemed to also stop me viewing some things generated by the mud..
Ok, here's one of the subroutines.. all I want to see is what everyone else sees in the World.send "grouptell..", not me inputting it as well.. just for this routine only, not for all my commands. I've been trying to add in the
world.note world.EchoInput
world.EchoInput = vbTrue
world.EchoInput = vbFalse;
but it's effecting things outside the subroutine as well.. can you help? I may have just been putting the above in the wrong place, but anyway, here is the script I'm trying to amend.
sub whiner (strTriggerName, trig_line, arrWildCards)
dim maxhpVar
dim oldhpVar
dim hpVar
dim difference
hpVar = arrWildCards (1)
maxhpVar = World.GetVariable("maxhp")
oldhpVar = World.GetVariable("oldhp")
difference = oldhpVar - hpVar
if difference > 40 then
World.send "grouptell \a02\c17>>\c12 TANK REPORT \c17<<\a01\c12 " & hpVar & " / " & maxhpVar & " \a02\c17(-"
& difference & ") \a01\c12*OUCH*\a01"
World.SetVariable "oldhp", hpVar
end if
difference = hpVar - oldhpVar
if difference > 40 then
World.send "grouptell \a02\c17>>\c12 TANK REPORT \c17<<\a01\c12 " & hpVar & " / " & maxhpVar & " \a02\c15(+"
& difference & ") \a01\c12*mmm*\a01"
World.SetVariable "oldhp", hpVar
end if
end sub
Amended by Nick to add [code]. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #7 on Thu 23 May 2002 12:23 AM (UTC) |
Message
| This example doesn't seem to be attempting to omit output. Can you post the version that does? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Magnum
Canada (580 posts) Bio
|
Date
| Reply #8 on Thu 23 May 2002 12:28 AM (UTC) Amended on Thu 23 May 2002 12:41 AM (UTC) by Magnum
|
Message
| Heh Heh. This is something I use extensively myself.
You should be able to put "world.EchoInput = vbFalse" just before a "World.Send" and then "world.EchoInput = vbTrue" on the line immediately after, and you will get the results you want.
In earlier versions, this was bugged, due to an inconsistency in the value stored in the VB constant vbTrue and vbFalse.
(Look for other threads on this subject "Echo Input")
Once it was pointed out, Nick fixed the bug, but I believe it may have creeped back in.
Recently, I experienced my echoinput remaining off, despite having it working properly for months in my script. Check the very recent posts, I think someone else just brought this up as well. |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | Top |
|
Posted by
| Guest1
USA (256 posts) |
Date
| Reply #9 on Thu 23 May 2002 12:47 AM (UTC) |
Message
| Hi Nick, Hi Magnum.. the one I tried was exactly as I posted, but with 'world.EchoInput = vbTrue' just before the 'World.Send' lines, and then 'world.EchoInput = vbFalse' just at the end of each 'World.Send' line. The result was exactly as Magnum said - echo input remained off.. had to switch it back on in file -> world properties -> input -> commands window.
This only happens with ones in script... selecting 'omit input' on triggers and aliases works fine.
just a fact of life? | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #10 on Thu 23 May 2002 01:34 AM (UTC) |
Message
| Depends which version of MUSHclient you have. However this should work in any version:
world.EchoInput = 1 ' turn echo on
The problem is, VB uses -1 for true, whereas C uses 1. The difference is what is causing the problem. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Guest1
USA (256 posts) |
Date
| Reply #11 on Thu 23 May 2002 01:40 AM (UTC) |
Message
| and another stoopid question..
when I send 'rescue playername' and then fail the rescue, I get the message 'You fail the rescue!' as normal.
I want to set this as a trigger to rescue the same playername again, but since there is no char name in that message, I need to use the 'repeat last command' option to do it (manually CTRL + R).. but how to code this?
I've tried getting the trigger to fire a subroutine called repeat, and loaded in a subroutine containing
world.send world.getcommandlist (1) (0)
and keep getting errors.. *ack*
appreciate your help :) | Top |
|
Posted by
| Guest1
USA (256 posts) |
Date
| Reply #12 on Thu 23 May 2002 01:44 AM (UTC) |
Message
| sorry I should have mentioned, I am coding in vbs | Top |
|
Posted by
| Guest1
USA (256 posts) |
Date
| Reply #13 on Thu 23 May 2002 01:48 AM (UTC) |
Message
| that echo problem is fixed thanks..
world.EchoInput = 0
World.send "grouptell TANK REPORT "
world.EchoInput = -1
worked great :) | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #14 on Thu 23 May 2002 02:03 AM (UTC) |
Message
| Repeating the last command might be dangerous if you slipped another command in, in the meantime.
You already know the person, don't you? That is in the variable "stabperson".
Just make the trigger do this:
<triggers>
<trigger
enabled="y"
expand_variables="y"
match="You fail the rescue!"
sequence="100"
>
<send>rescue @stabperson</send>
</trigger>
</triggers>
However, if you are rescuing a different person, make an alias to remember the person's name, then change the trigger above to use that variable. eg.
<aliases>
<alias
name="Rescue"
script="OnRescue"
match="rescue *"
enabled="y"
>
<send>%0</send>
</alias>
</aliases>
Script ...
sub onrescue (sName, sLine, wildcards)
world.setvariable "rescuename", wildcards (1)
end sub
|
- 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.
56,526 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top