Rat Counter - Info Bar

Posted by Morgoth on Thu 31 Jul 2003 10:15 AM — 12 posts, 48,225 views.

Israel #0
Alright, here's my problem. Here's what I want to achieve,
I want to make a rat counter, so it triggers "You pick up a black rat" (there's a couple of rats btw) so each time I pick it up, it changes the amount of money I have and the number of rats, on the info bar. so like I trigger "You pick up a black rat", and the info bar changes to
Rats: 1 Gold: 15. I've done this before on zmud...not sure how to do it on mush. Please Help.
Greece #1
Could you paste the exact text, and tell us how your gold changes each time you pick up a rat?
Israel #2
No.....I mean like the info bar changes. I want it to have text like this Gold: 0 Rats: 0, each rat is worth a differant amount, so I know how much golds worth of rats I'm holding. so each time I Pick it up, the info bar changes, so if I have 50 rats, it will say Rats: 50, and how many the rats are worth. I think it would need variables.....so like everytime I pick up the rats the variables change.
Australia Forum Administrator #3
It isn't clear what your question is exactly? How to match on the rat message? How to store variables? How to write to the info bar?

The info bar is documented at:

http://www.gammon.com.au/scripts/doc.php?general=infobar

If you want someone to actually write the trigger that counts rats you will have to do what Poremenos says, and post some example MUD output, we can't do it blind.
Israel #4
I want something to count how many rats I have and how many they are worth on an info bar. The thing I would need to trigger are when I pick up the rats:
You pick up the corpse of a rat.
-----------------------------------------------------------
So now I have 1 rat which is worth 15 gold, so the info bar would change from Gold: 0 Rat: 0 to Gold: 15 Rat: 1, lets say I pick up another rat so now I have two rats which are worth 30 gold all together so the counter changes to
Gold: 30 Rat: 2. I hope this is clearer.
Israel #5
Err...forgot to add this on. What I don't know how to do is how to write the sub so it does the mathematical action and how I would I put it on the info bar (e.g Would I have to use variables?)
Greece #6
Try something like this:
Dim intGold
Dim intRats

Sub OnRat(strName, strLine, strWildcards)
intGold = Int(intGold + 15)
intRats = Int(intRats + 1)
Info "Rats: " & intRats & ". Gold: " & intGold & "."
End Sub
I would think that should work.
Israel #7
Its terrific! works great. (just as a side note, I forgot to mention there are a couple types of rats, so each time I picked it up it added it instead of changing, so I just info cleared it each time and it works great). :P. thanks
#8
Morgoth, by some chance do you play Achaea?
Anyways, how would I make a variable appear on the info bar? I mean, saw the command, but what do I do with it? And for that matter, how do I put text at all there? Can imagges be placed there?
Australia Forum Administrator #9
See this link:

http://www.gammon.com.au/scripts/doc.php?general=infobar

No, images can't be put there. The general idea would be to have a trigger that updates the info bar when required.
#10
ok, I tried this,


Dim intPinchers

Sub OnPincher(strName, strLine, strWildcards)
intPinchers = Int(intPinchers + 1)
Info "Pinchers: " & intPinchers & "."
End Sub

and I put it in a trigger
^You pick up the corpse (.*?) pincher.$

but I get nothing in my infobar, I'm sure I'm doing something wrong here....here are the lines I see that I need the counter to work off:
You pick up the corpse of a tiny pincher.
You pick up the corpse of an ugly pincher.
You pick up the corpse of a giant ugly pincher.
Russia #11
This line looks wrong:


intPinchers = Int(intPinchers + 1)


It should be instead:


intPinchers = cstr(intPinchers + 1)


And since this topic is about a rat counter, I've made one a while back that never got to be posted and I was too lazy to go and post it someplace myself. It's for Achaea (autopickup) but can serve as an example too:


<?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), retrieving 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>

<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>