[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  2 things!

2 things!

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


Posted by Zendu   (66 posts)  [Biography] bio
Date Thu 05 Feb 2004 09:39 AM (UTC)
Message
first off, im playign aetolia and i have a trigger set for
you press your hands toghter, your practice complete
the responce should be practice


however, it sends the command to the mud instead of the client, how do i fix this?





2nd is there a way i can make a rat counter that will add up the prices and the number ive collected? ive seen it done on zmud.

God im helpless
Currently using MushClient 3.46 on Win Xp pro on [url=www.aetolia.com]Aetolia[/url]
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Fri 06 Feb 2004 09:18 PM (UTC)
Message
To send to the client and not the MUD, set the trigger to "send to output" (see "send to" combo box).

A rat counter?

Make a trigger that matches on whatever you see when a rat dies, and do a small script in the trigger (set the trigger to "send to script"). For example:


ratcount = ratcount + 1
world.Note "You have now killed " & CStr (ratcount) & " rats"


This would count rats in the current MUSHclient session. To save for the future you need to use a MUSHclient variable instead, like this:


SetVariable "ratcount", CInt (GetVariable ("ratcount")) + 1
world.Note "You have now killed " & GetVariable ("ratcount") & " rats"

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Zendu   (66 posts)  [Biography] bio
Date Reply #2 on Sat 07 Feb 2004 12:45 AM (UTC)
Message
The problem is there is 5 kinds of rats with differing values, so my trigger should look like this?


Trigger "You have killed a baby rat"
SetVariable "ratcount", CInt (GetVariable ("ratcount")) + 1
SetVariable "ratcash", CInt (GetVariable ("ratcash")) + 10
world.Note "You have now killed " & GetVariable ("ratcount") & " rats, worth " & GetVariable ("ratcash")


Trigger "You have killed a young rat"
SetVariable "ratcount", CInt (GetVariable ("ratcount")) + 1
SetVariable "ratcash", CInt (GetVariable ("ratcash")) + 20
world.Note "You have now killed " & GetVariable ("ratcount") & " rats, worth " & GetVariable ("ratcash")




thanks for your help

God im helpless
Currently using MushClient 3.46 on Win Xp pro on [url=www.aetolia.com]Aetolia[/url]
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sat 07 Feb 2004 08:09 PM (UTC)

Amended on Sat 07 Feb 2004 08:13 PM (UTC) by Nick Gammon

Message
You don't need 5 triggers. One simple way would be:

Match: You have killed a * rat

That matches the wildcard (asterisk) for any type of rat.

Or, to be fancier, you could use a regular expression and list the rat types:

Match: ^You have killed a (baby|young|old|large|small) rat$
Regular expression: checked

That way you match the exact rat type, however I doubt that you need that level of detail.

(edit)

Ah, I see they are worth different amounts. OK, in that case you still can run with the first trigger, but do something like this:


Match: You have killed a * rat

Send: 

select case "%1"
  case "baby" cash = 10
  case "young" cash = 20
  case "medium" cash = 30
  case "large" cash = 40
  case "old" cash = 50
end select

SetVariable "ratcount", CInt (GetVariable ("ratcount")) + 1
SetVariable "ratcash", CInt (GetVariable ("ratcash")) + cash
world.Note "You have now killed " & GetVariable ("ratcount") & " rats, worth " & GetVariable ("ratcash")


I have made up the amounts and rat types, but it shows the general idea.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Zendu   (66 posts)  [Biography] bio
Date Reply #4 on Sun 08 Feb 2004 05:14 AM (UTC)
Message
^You have slain (a|an)*rat.$


select case "%1"
case "baby" cash = 10
case "young" cash = 20
case " " cash = 30
case "old" cash = 40
case "black" cash = 50
end select

SetVariable "ratcount", CInt (GetVariable ("ratcount")) + 1
SetVariable "ratcash", CInt (GetVariable ("ratcash")) + cash
world.Note "You have now killed " & GetVariable ("ratcount") & " rats, worth " & GetVariable ("ratcash")



message examples You have slain a rat
you have slain an old rat

i should send it to execute right?



sorry, but im haveing the worst time with this

God im helpless
Currently using MushClient 3.46 on Win Xp pro on [url=www.aetolia.com]Aetolia[/url]
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Sun 08 Feb 2004 05:42 AM (UTC)

Amended on Sun 08 Feb 2004 09:16 PM (UTC) by Nick Gammon

Message
So what went wrong exactly? Did it add zero to the points count?

Your triggers doesn't make a lot of sense:

^You have slain (a|an)*rat.$

You are combining a regular expression (the ^ ..$ part) with the * for a wildcard.

Your regular expression would have matched on zero or more occurrences of a/an, followed by "rat" followed by a single character. In other words, it might have matched on:

You have slain aaaaanananananratX

But not "You have slain a young rat"

If you are using regular expressions it needs to read:

^You have slain (?:a|an)(.*) rat$

Then since the wildcard part (.*) will have the leading space, you need to "trim" the wildcard, eg. like this in the script:

select case trim ("%1")

See this page for more on regular expressions:

http://www.gammon.com.au/mushclient/regexp.htm


Edited to correct typo in regular expression.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Zendu   (66 posts)  [Biography] bio
Date Reply #6 on Sun 08 Feb 2004 03:16 PM (UTC)
Message
using "^You have slain (?:a|an)(*.) rat$" gave me a error before i even left the screen (failed at offset 25 i think?)


im having problems 1) triggering the trigger becuase obvoisly, i dont get reguler expressions as well as i thought i did


the largest problem is that one of the rats doesnt have a title.

lets just start with the simplest one, a baby rat

trigger: you have killed a baby rat
responce SetVariable "ratcount", CInt (GetVariable ("ratcount")) + 1
SetVariable "ratcash", CInt (GetVariable ("ratcash")) + 10
world.Note "You have now killed " & GetVariable ("ratcount") & " rats, worth " & GetVariable ("ratcash")

this should work correct?

God im helpless
Currently using MushClient 3.46 on Win Xp pro on [url=www.aetolia.com]Aetolia[/url]
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #7 on Sun 08 Feb 2004 08:07 PM (UTC)

Amended on Sun 08 Feb 2004 08:08 PM (UTC) by Shadowfyr

Message
Well. First off.. You got the '*' and '.' backwards. That is what the error points too, the '*' immediately after '('. It should be:

"^You have slain (?:a|an)(.*)? rat\.$"

I also added the extra '?', which will make it match even if there is no type, and a '\.'. That last '\.' part is important, since your trigger ends with '$'. '$' means 'this must be the end of this line', so the version you had would always fail, since it would expect the line to end, even before it got to the period at the end of it. '\.' tells it to also look for that period.

For the rat without a name you would then just add a new section to the case:

select case "%1"
  case "baby" cash = 10
  case "young" cash = 20
  case "medium" cash = 30
  case "large" cash = 40
  case "old" cash = 50
  case else cash = 25
end select

SetVariable "ratcount", CInt (GetVariable ("ratcount")) + 1
SetVariable "ratcash", CInt (GetVariable ("ratcash")) + cash
world.Note "You have now killed " & GetVariable ("ratcount") & " rats, worth " & GetVariable ("ratcash")

The 'case else' will match on any type of rat you didn't already provide in the list, including your rat with no type. Assuming you put all the correct types of rats listed, it should 'only' set that value for the ones with no type.
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Sun 08 Feb 2004 09:22 PM (UTC)
Message
Well, Zendu, you need to be very precise when doing triggers.

Here are some of the examples you have given in your posts of the message:


  • you have killed a baby rat
  • You have killed a baby rat
  • ^You have slain (a|an)*rat.$
  • You have slain a rat
  • you have slain an old rat


It would be nice if you actually copied and pasted some output rather then retyping it.

So far I can see about 3 things that are different in them:


  • Does the message start "You" or "you"?
  • Have you "killed" or "slain" the rat?
  • Does the message end with a period (.) or not? Your trigger example (third one above) suggests it might.


I mention this, because a trigger, for instance:

Match: you have killed a baby rat

Will clearly not match a message from the MUD:

You have slain a baby rat.

That is 3 differences there (You/you, killed/slain, and the final period).

You have to get it precisely right, or no match.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Zendu   (66 posts)  [Biography] bio
Date Reply #9 on Mon 09 Feb 2004 03:56 AM (UTC)
Message
okay things are getting a little too complicated for such a seeming idea!
step one
"You have slain a baby rat."
thats the text, the trigger works [tested by saying "it works" in game

the responce should be

SetVariable "ratcount", CInt (GetVariable ("ratcount")) + 1
SetVariable "ratcash", CInt (GetVariable ("ratcash")) + cash
world.Note "You have now killed " & GetVariable ("ratcount") & " rats, worth " & GetVariable ("ratcash")


however the world (aetolia) says
You cannot see that being here.
Nothing can be seen here by that name.You've baffled me!
I do not understand.
Most perplexing.


which implys all 4 of the lines are being sent to the world
it is set to execute, should it be script or varible?

God im helpless
Currently using MushClient 3.46 on Win Xp pro on [url=www.aetolia.com]Aetolia[/url]
[Go to top] top

Posted by Gore   (207 posts)  [Biography] bio
Date Reply #10 on Mon 09 Feb 2004 03:59 AM (UTC)
Message
You probably have the trigger set to Send to World instead of Send to Script. Where you can edit the trigger, you can set it there.
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #11 on Mon 16 Feb 2004 12:17 PM (UTC)
Message
This is a plugin that used to reside on achaea.mc0wnage.com/forums before that site crashed and got deleted. It does basically what you are looking for but using an info bar for display:


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE muclient >

<muclient>
   <plugin name="Ratter" author="Keldar" language="vbscript" purpose="Display ratting info"
     save_state="y" date_written="2003-11-15" date_modified="2003-11-16" requires="3.32" version="1.0" 
     id="152d7cdff704e856e0c00d58">
 
    <description trim="y">

        <![CDATA[
This simple plugin will display the basic statistics of your ratting. It 
uses the Info bar for display, and can show either counts for each type
of rat you have slain so far, or their gold worths. The commands to use it
are:

ratter on|off            - turn the Ratter on or off, turning it off resets the current count
ratter nums|gold    - defines whether the plugin will display amounts or gold values
                                 of rats
rats *                      - * stands for a ratman's name, sends 'sell rats to *'

        ]]>
    </description>

</plugin>
 <include name="constants.vbs" />

<triggers>
<trigger
 name="RatPickup"
 enabled="n"
 regexp="y"
 match="^You have slain (?:a|an) (baby rat|young rat|rat|old rat|black rat) and retrieve the corpse\.$"
 script="CountRats"
 keep_evaluating="y"
 sequence="10"
></trigger>
</triggers>

<aliases>
<alias
 name="ratter_switch"
 enabled="y"
 regexp="y"
 match="^ratter (on|off|nums|gold)$"
 sequence="100"
 script="Ratter"
/>
<alias
 name="sellrats"
 enabled="y"
 match="rats *"
 sequence="100"
><send>sell rats to %1</send></alias>
</aliases>

<variables>

</variables>

<script> 
<![CDATA[

dim displayMode
displayMode = 1         '1 displays amounts, 2 - gold values

dim ratPrice(5)         'This array holds prices for different rats
ratPrice(0) = 7          'baby rat
ratPrice(1) = 14        'young rat
ratPrice(2) = 21        'rat
ratPrice(3) = 28        'old rat
ratPrice(4) = 35        'black rat

dim ratNums(5)       'This array holds the number of different rats you've killed
ratNums(0) = 0        'baby rats
ratNums(1) = 0        'young rats
ratNums(2) = 0        'rats
ratNums(3) = 0        'old rats
ratNums(4) = 0        'black rats

sub Ratter(name, output, wildcs)
 select case wildcs(1)
   case "on"
    world.EnableTrigger "RatPickup", 1
    DisplayInfo
    world.Note "Ratter plugin is ON"
   case "off"
    world.EnableTrigger "RatPickup", 0
    world.InfoClear
    world.InfoBackground "lightgrey"
    dim i
    for i = 0 to ubound(ratNums)
     ratNums(i) = 0
    next
    displayMode = 1
    world.Note "Ratter plugin is OFF"
   case "nums"
    displayMode = 1
    DisplayInfo
   case "gold"
    displayMode = 2
    DisplayInfo
 end select
end sub

sub CountRats(name, output, wildcs)
 select case wildcs(1)
  case "baby rat"
    ratNums(0) = ratNums(0) + 1
  case "young rat"
    ratNums(1) = ratNums(1) + 1
  case "rat"
    ratNums(2) = ratNums(2) + 1
  case "old rat"
    ratNums(3) = ratNums(3) + 1
  case "black rat"
    ratNums(4) = ratNums(4) + 1
 end select
 DisplayInfo
end sub

sub DisplayInfo
 world.InfoClear
 world.InfoFont "FixedSys", 12, 0
 world.InfoColour "white"
 world.InfoBackground "black"
 dim totalNums, totalGold, i
 totalNums = 0
 totalGold = 0
 for i = 0 to ubound(ratNums)
   totalNums = totalNums + ratNums(i)
 next
 if (displayMode = 1) then
  world.Info "Total: " & cstr(totalNums) & " | "
  world.Info "Baby rats: " & cstr(ratNums(0)) & " | "
  world.Info "Young Rats: " & cstr(ratNums(1)) & " | "
  world.Info "Rats: " & cstr(ratNums(2)) & " | "
  world.Info "Old rats: " & cstr(ratNums(3)) & " | "
  world.Info "Black rats " & cstr(ratNums(4))
 elseif (displayMode = 2) then
  for i = 0 to ubound(ratNums)
   totalGold = totalGold + ratNums(i)*ratPrice(i)
  next   
  world.Info "Total: " & cstr(totalGold) & "gp | "
  world.Info "Baby rats: " & cstr(ratNums(0)*ratPrice(0)) & "gp | "
  world.Info "Young Rats: " & cstr(ratNums(1)*ratPrice(1)) & "gp | "
  world.Info "Rats: " & cstr(ratNums(2)*ratPrice(2)) & "gp | "
  world.Info "Old rats: " & cstr(ratNums(3)*ratPrice(3)) & "gp | "
  world.Info "Black rats " & cstr(ratNums(4)*ratPrice(4)) & "gp"
 end if
end sub

]]>        
</script>

</muclient>
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #12 on Mon 16 Feb 2004 12:20 PM (UTC)
Message
Erm, you might want to edit the match text for the RatPickup trigger, since I don't think there's such a thing as auto-pickup of corpses in Aetolia. Just change it to:

^You have slain (?:a|an) (baby rat|young rat|rat|old rat|black rat)\.$
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #13 on Mon 16 Feb 2004 11:31 PM (UTC)
Message
Also, I think it would be better if we included a ready made trigger for users to paste in the triggers window if they are new to MUSHClient... Since MUSHClient supports that functionality, it would make users' lives much easier, and they can still edit it to match their needs.
By the way Nick, congratulations, I'm loving 3.44 :)

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #14 on Thu 14 Apr 2005 07:58 AM (UTC)
Message
The currently working version of Ratter for Achaea is:


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE muclient >

<muclient>
   <plugin name="Ratter" author="Keldar" language="vbscript" purpose="Display ratting info"
     save_state="y" date_written="2003-11-15" date_modified="2004-06-06" requires="3.32" version="1.1" 
     id="152d7cdff704e856e0c00d58">
 
    <description trim="y">

        <![CDATA[
This simple plugin will display the basic statistics of your ratting. It 
uses the Info bar for display, and can show either counts for each type
of rat you have slain so far, or their gold worths. The commands to use it
are:

ratter on|off            - turn the Ratter on or off, turning it off resets the current count
ratter nums|gold    - defines whether the plugin will display amounts or gold values
                                 of rats
sr *                      - * stands for a ratman's name, sends 'sell rats to *'

        ]]>
    </description>

</plugin>

<triggers>
<trigger
 name="RatPickup"
 enabled="n"
 regexp="y"
 match="^You have slain (?:a|an) (baby rat|young rat|rat|old rat|black rat), retrieving the corpse\.$"
 script="CountRats"
 group="RatTriggers"
 keep_evaluating="y"
 sequence="10"
></trigger>
<trigger
name="RatGiven"
enabled="n"
regexp="y"
match="^(?:.*?) gives you the corpse of (?:a|an) (baby rat|young rat|rat|old rat|black rat)\.$"
script="CountRats"
group="RatTriggers"
keep_evaluating="y"
sequence="10"
></trigger>
</triggers>

<aliases>
<alias
 name="ratter_switch"
 enabled="y"
 regexp="y"
 match="^ratter (on|off|nums|gold)$"
 sequence="100"
 script="Ratter"
/>
<alias
 name="sellrats"
 enabled="y"
 match="sr *"
 sequence="100"
><send>sell rats to %1</send></alias>
</aliases>

<variables>

</variables>

<script> 
<![CDATA[

dim displayMode
displayMode = 1         '1 displays amounts, 2 - gold values

dim ratPrice(5)         'This array holds prices for different rats
ratPrice(0) = 7          'baby rat
ratPrice(1) = 14        'young rat
ratPrice(2) = 21        'rat
ratPrice(3) = 28        'old rat
ratPrice(4) = 35        'black rat

dim ratNums(5)       'This array holds the number of different rats you've killed
ratNums(0) = 0        'baby rats
ratNums(1) = 0        'young rats
ratNums(2) = 0        'rats
ratNums(3) = 0        'old rats
ratNums(4) = 0        'black rats

sub Ratter(name, output, wildcs)
 select case wildcs(1)
   case "on"
    world.EnableTriggerGroup "RatTriggers", 1
    DisplayInfo
    world.Note "Ratter plugin is ON"
   case "off"
    world.EnableTriggerGroup "RatTriggers", 0
    world.InfoClear
    world.InfoBackground "lightgrey"
    dim i
    for i = 0 to ubound(ratNums)
     ratNums(i) = 0
    next
    displayMode = 1
    world.Note "Ratter plugin is OFF"
   case "nums"
    displayMode = 1
    DisplayInfo
   case "gold"
    displayMode = 2
    DisplayInfo
 end select
end sub

sub CountRats(name, output, wildcs)
 select case wildcs(1)
  case "baby rat"
    ratNums(0) = ratNums(0) + 1
  case "young rat"
    ratNums(1) = ratNums(1) + 1
  case "rat"
    ratNums(2) = ratNums(2) + 1
  case "old rat"
    ratNums(3) = ratNums(3) + 1
  case "black rat"
    ratNums(4) = ratNums(4) + 1
 end select
 DisplayInfo
end sub

sub DisplayInfo
 world.InfoClear
 world.InfoFont "FixedSys", 12, 0
 world.InfoColour "white"
 world.InfoBackground "black"
 dim totalNums, totalGold, i
 totalNums = 0
 totalGold = 0
 for i = 0 to ubound(ratNums)
   totalNums = totalNums + ratNums(i)
 next
 if (displayMode = 1) then
  world.Info "Total: " & cstr(totalNums) & " | "
  world.Info "Baby rats: " & cstr(ratNums(0)) & " | "
  world.Info "Young Rats: " & cstr(ratNums(1)) & " | "
  world.Info "Rats: " & cstr(ratNums(2)) & " | "
  world.Info "Old rats: " & cstr(ratNums(3)) & " | "
  world.Info "Black rats " & cstr(ratNums(4))
 elseif (displayMode = 2) then
  for i = 0 to ubound(ratNums)
   totalGold = totalGold + ratNums(i)*ratPrice(i)
  next   
  world.Info "Total: " & cstr(totalGold) & "gp | "
  world.Info "Baby rats: " & cstr(ratNums(0)*ratPrice(0)) & "gp | "
  world.Info "Young Rats: " & cstr(ratNums(1)*ratPrice(1)) & "gp | "
  world.Info "Rats: " & cstr(ratNums(2)*ratPrice(2)) & "gp | "
  world.Info "Old rats: " & cstr(ratNums(3)*ratPrice(3)) & "gp | "
  world.Info "Black rats " & cstr(ratNums(4)*ratPrice(4)) & "gp"
 end if
end sub

]]>        
</script>

</muclient>


They keep changing the kill messages all the time, so the plugin regularly stops working due to a single trigger.
[Go to top] 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.


38,191 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]