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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Rat Counter - Info Bar
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Rat Counter - Info Bar

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


Posted by Morgoth   Israel  (38 posts)  [Biography] bio
Date Thu 31 Jul 2003 10:15 AM (UTC)
Message
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.
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #1 on Thu 31 Jul 2003 11:44 AM (UTC)
Message
Could you paste the exact text, and tell us how your gold changes each time you pick up a rat?

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

Posted by Morgoth   Israel  (38 posts)  [Biography] bio
Date Reply #2 on Thu 31 Jul 2003 11:50 AM (UTC)
Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Thu 31 Jul 2003 09:57 PM (UTC)
Message
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.

- Nick Gammon

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

Posted by Morgoth   Israel  (38 posts)  [Biography] bio
Date Reply #4 on Sun 03 Aug 2003 10:59 AM (UTC)
Message
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.
[Go to top] top

Posted by Morgoth   Israel  (38 posts)  [Biography] bio
Date Reply #5 on Sun 03 Aug 2003 11:02 AM (UTC)
Message
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?)
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #6 on Mon 04 Aug 2003 07:32 AM (UTC)
Message
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.

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

Posted by Morgoth   Israel  (38 posts)  [Biography] bio
Date Reply #7 on Mon 04 Aug 2003 11:20 AM (UTC)
Message
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
[Go to top] top

Posted by Matthias   (28 posts)  [Biography] bio
Date Reply #8 on Wed 06 Aug 2003 11:59 PM (UTC)
Message
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?

Give a man a fire and you warm him for a day.
Set a man on fire and you warm him for the rest of his life.
[Go to top] top

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Thu 07 Aug 2003 04:56 AM (UTC)
Message
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.

- Nick Gammon

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

Posted by Hathcock   (49 posts)  [Biography] bio
Date Reply #10 on Thu 22 Apr 2004 03:04 PM (UTC)
Message
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.
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #11 on Thu 22 Apr 2004 07:59 PM (UTC)
Message
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>
[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.


7,834 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 FutureQuest]