basic help please

Posted by Guest1 on Wed 22 May 2002 05:36 PM — 29 posts, 83,029 views.

USA #0
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
USA #1
..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.. :)
Canada #2
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...
USA #3
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
Amended on Wed 22 May 2002 07:18 PM by Shadowfyr
USA #4
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
Australia Forum Administrator #5
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
USA #6
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].
Amended on Thu 23 May 2002 12:20 AM by Nick Gammon
Australia Forum Administrator #7
This example doesn't seem to be attempting to omit output. Can you post the version that does?
Canada #8
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.
Amended on Thu 23 May 2002 12:41 AM by Magnum
USA #9
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?
Australia Forum Administrator #10
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.
USA #11
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 :)
USA #12
sorry I should have mentioned, I am coding in vbs
USA #13
that echo problem is fixed thanks..

world.EchoInput = 0
World.send "grouptell TANK REPORT "
world.EchoInput = -1

worked great :)
Australia Forum Administrator #14
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
USA #15
Yeah I thought of something like that, but unfortunately it wont always be the same person, as I have yet another trigger that if someone -else- in the group needs help while we are fighting the same mob, they then 'sing', and I automatically rescue them, so basically the "You failed the rescue!' trigger will need re-rescue the person i last rescued in order to work effectively...
Can it be done?
USA #16
ahh i'm kind of understanding it a bit more now..the other option is to create another routine that updates another variable every time i rescue someone, and then the 'You failed th..' trigger then will set off another *snicker* subroutine to rescue the last person rescued.. yeah. *head spins a little* ok.. i'll try that then :)
Canada #17
Quote:

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.

That's backwards. You want False first (to turn it off), send your line, then True (to turn it back on).

I actually made the same mistake and had to edit my post to correct that, but I noticed right away.

You ended up using the literal values instead. :)
USA #18
doh. ok i'm now using the vbs

world.EchoInput = 0
world.send "grouptell message"
world.EchoInput = -1

one, which works most times.. but occasionally the echo stays switched off.. kind of strange.. if i try rewriting it as

world.EchoInput = 0
world.send "grouptell message"
world.EchoInput = -1
world.EchoInput = -1

I guess it wont hurt.. to be sure, to be sure. heh.
With the other rescue on fail one, I am suggesting to the mud scripters to amend it to 'You fail the rescue on playername' ..but I won't hold my breath. With the new variable being created every time I rescue as well as a separate variable for the stabber and more subroutines to then rescue again etc etc it's starting to create a smallish lag. If you could tell me the syntax for a trigger to repeat last command I could try it out anyway.
Thanks.. learning things is always good :)
Australia Forum Administrator #19
Quote:

world.EchoInput = 0
world.send "grouptell message"
world.EchoInput = -1


No, no. As I said earlier up, you need to use 1, not -1.

Do this instead...


world.EchoInput = 0
world.send "grouptell message"
world.EchoInput = 1


What version of MUSHclient are you using? This should work too:


world.send world.getcommandlist (1) (0)


That will send the last command. If you are using an early version then getcommandlist isn't implemented, and the bug with EchoInput is still there.
USA #20
Hiya. Using ver 3.17 client (o/s is windows 2000 pro)
I tried "world.send world.getcommandlist (1) (0)" but it didn't recognize it. I should update.

"No, no. As I said earlier up, you need to use 1, not -1."

I'm using vbs so thought it was meant to be -1 or 0.. I will change it over :)

Talked to a few ppl on mud who said one of two things in regard to failed rescues. One is to spam the original rescue, so that when the trigger to rescue someone is fired, it sends "rescue playername" 3 or 4 times.. the other option more commonly used is to repeat the last command.
USA #21
hmm.. just installed ver3.20. If I have a trigger set like so:

trigger : * tells you *
send : tell %1 <auto response> I am currently AFK


In ver 3.17, without omit from output selected, I'd see them tell me something, and I would see

Airhead tells you 'ping'
tell Airhead <auto reply> I am currently afk.
You tell Airhead '<auto reply> I am currently afk.'

in the output window. With omit output selected, I'd see

Airhead tells you 'ping'
You tell Airhead '<auto reply> I am currently afk.'

which is what I wanted. On ver3.2, without selecting omit from output I get the same result as ver3.17 above.. however when I select omit from output, I do not see what Airhead tells me.. all I get is

You tell Airhead '<auto reply> I am currently afk.'

is this what should happen? does omit from output now omit whatever fired the trigeer as well?
It's really just an aesthetic thing for me.. *shrug*
USA #22
Great :) been testing newer vers with the
world.send world.getcommandlist (1) (0)
on fail rescue and it works great, as does the stabber rescue.
awesome. thanks :)
Australia Forum Administrator #23
The idea of "omit from output" is to omit the triggered line.

More recently, I added the extra feature that anything you send is also omitted. This is for situations like this:

Say, Magnum is annoying you with lots of tells. You set up a trigger:


Match: Magnum tells you, *
Send: tell Magnum I am ignoring you, don't bother
Omit from output: checked


The idea here is that you silently ignore the tells, and don't see the response. Otherwise you would still see your response, which would probably be just as annoying.

If you want to work around that, call a script and do the send in there.
Canada #24
Magnum smirks amusingly.

Here's some code from my own script file:

Const vbsTrue = 1
Const vbsFalse = 0

' ------------------------------------------------------------
Sub Join_Party (thename, theoutput, arrWildcards)
	World.SetVariable "InParty", True
	World.SetVariable "InPartyStatus", "InParty: Yes"
	World.Note World.GetVariable("InPartyStatus")
	World.SpeedWalkDelay = 250
	Display_StatusLine()
	World.EchoInput = vbsTrue
End Sub

Sub Quit_Party (thename, theoutput, arrWildcards)
	World.SetVariable "InParty", False
	World.SetVariable "InPartyStatus", "InParty: No"
	World.Note World.GetVariable("InPartyStatus")
	World.SpeedWalkDelay = 0
	Display_StatusLine()
	World.EchoInput = vbsTrue
End Sub

Sub Toggle_InParty (thename, theoutput, arrWildcards)
	If World.GetVariable("InParty") Then
		Quit_Party "Toggle_InParty", "-", "-"
	Else
		Join_Party "Toggle_InParty", "-", "-"
	End If
End Sub
' ------------------------------------------------------------

I keep track of weather I am in a party or not using triggers, so that I don't send party tells when I am not actually in a party...

<triggers>

  <trigger
   enabled="y"
   match="dissolved the party."
   name="Party_Dissolved"
   regexp="y"
   script="Quit_Party"
   sequence="100"
  >
  </trigger>
</triggers>

<triggers>

  <trigger
   enabled="y"
   match="You create a party."
   name="Party_Create"
   script="Join_Party"
   sequence="100"
  >
  </trigger>
</triggers>

<triggers>

  <trigger
   enabled="y"
   match="You join * party."
   name="Party_Join"
   script="Join_Party"
   sequence="100"
  >
  </trigger>
</triggers>

<triggers>

  <trigger
   enabled="y"
   match="You left the party."
   name="Party_Leave"
   script="Quit_Party"
   sequence="100"
  >
  </trigger>
</triggers>

<triggers>

  <trigger
   enabled="y"
   match="You were kicked out of the party."
   name="Party_Kicked"
   script="Quit_Party"
   sequence="100"
  >
  </trigger>
</triggers>

In case one of the triggers fails to fire for some reason, or due to whatever error, I can toggle the status with an alias:

<aliases>

  <alias
   name="Set_Toggle_InParty"
   script="Toggle_InParty"
   match="inparty"
   enabled="y"
   ignore_case="y"
  >
  </alias>
</aliases>

Back to my script, I can now present messages according to my party status. Here's one example:

Sub Display_End_Inspiration (thename, theoutput, arrWildcards)
	If World.GetVariable("InParty") Then
		World.EchoInput = vbsFalse
		LogSend "party emote no longer feels inspired."
	End If
	World.EchoInput = vbsTrue
End Sub

(There are calls made from some of the above routines to other routines I have not quoted)

If EchoInput ever fails for some reason (and it did a ton in that older version that was bugged), I can turn it back on quickly with an alias:

<aliases>

  <alias
   name="Set_Echo_On"
   script="Echo_On"
   match="eon"
   enabled="y"
  >
  </alias>
</aliases>

...which calls this small subroutine:

Sub Echo_On (thename, theoutput, arrWildcards)
	World.EchoInput = vbsTrue
End Sub

As you can see in my "Inparty" code, I sometimes put a "World.EchoInput" in a subroutine even though I never turned it off... that was mostly a holdever from the bugged version, and I had almost every routine turn it back on just before the 'End Sub'.

Well, how's this for spam?

Magnum grins demonically.
Australia Forum Administrator #25
Quote:

Sub Echo_On (thename, theoutput, arrWildcards)
World.EchoInput = vbsTrue
End Sub


Of course, this did the very thing that caused the bug. :)

You wanted:


Sub Echo_On (thename, theoutput, arrWildcards)
World.EchoInput = 1
End Sub


*grins evilly*
Canada #26
Note the constants I declare (at the top of my previous post).

Note: vbsTrue not vbTrue.

When you documented the bug, I created the two constants, then search/replace'd vbTrue with vbsTrue [and False].

Magnum flexes his muscles.
USA #27
Just a thought magnum:

Sub Display_Ends (thename, theoutput, arrWildcards)
  If World.GetVariable("InParty") Then
    World.EchoInput = vbsFalse
    select case thename
      case "inspiretrig" (or whatever you called it)
        LogSend "party emote no longer feels inspired."
      case ... (the rest of the labels, one after another)
    end select
  End If
  World.EchoInput = vbsTrue
End Sub


I find it is often a lot easier to fix related stuff when you put it in one place. ;) Your tag line should be:

'Magnum - Always doing things the hard way.' lol

Been to lazy to do this myself, but now...
Amended on Fri 24 May 2002 06:55 PM by Shadowfyr
Canada #28
Something to consider. It will be much more complex though, as I have started to implement timestamps for most spells:

Sub Grab_GodShield (thename, theoutput, arrWildcards)
	SS_GS = Now()
	SC_GS = arrWildcards(2)
End Sub

Sub Display_End_Godshield (thename, theoutput, arrWildcards)
	Dim TimeStamp
	If SS_GS <> Empty Then
		SD_GS = TimeDiff(SS_GS, Now())
		TimeStamp = " (" & SD_GS & " - " & SC_GS & ")."
	End If
	If World.GetVariable("InParty") Then
		World.EchoInput = vbsFalse
		LogSend "party emote no longer has a Godshield." & TimeStamp
	Else
		World.Note "END: GodShield" & TimeStamp
	End If
	SS_GS = Empty
	World.EchoInput = vbsTrue
End Sub

Even more complex, is the dropping of Health Blessing or Aura of Resistance, where I auto flee if it dropped while in Combat:

Sub Grab_HealthBlessing (thename, theoutput, arrWildcards)
	Dim Minutes
	SS_HB = Now()
	SC_HB = arrWildcards(2)
	If SD_HB <> Empty Then
		Minutes = Mid(SD_HB, 4, 2)
		Minutes = CInt(Minutes) - 3
		World.AddTimer "Warning_HB_Timer", 0, Minutes, 0, "", 5, "Display_HealthBlessing_Warning"
	End If
End Sub

Sub Display_End_HealthBlessing (thename, theoutput, arrWildcards)
	Dim TimeStamp
	FleeNow "Display_End_HealthBlessing", theoutput, arrWildcards
	If SS_HB <> Empty Then
		SD_HB = TimeDiff(SS_HB, Now())
		TimeStamp = " (" & SD_HB & " - " & SC_HB & ")."
	End If
	If World.GetVariable("InParty") Then
		World.EchoInput = vbsFalse
		LogSend "party emote no longer has blessed health." & TimeStamp
	Else
		World.Note "END: Health Blessing" & TimeStamp
	End If
	SS_HB = Empty
	World.EchoInput = vbsTrue
End Sub

Sub Display_HealthBlessing_Warning (TimerName)
	If World.GetVariable("InParty") Then
		World.EchoInput = vbsFalse
		LogSend "party emote expects Health Blessing will drop within 3 minutes."
	Else
		World.Note "WARNING: Health Blessing will drop within 3 minutes."
	End If
End Sub

Still, it might be worthwile to write just a few subroutines to handle all spells dropping. This too, is part of something I was thinking I could clean up and offer as a "Plugin".