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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Triggers, Variables and Scripts
|
Triggers, Variables and Scripts
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Ankka
Finland (3 posts) Bio
|
| Date
| Fri 15 Jun 2001 02:18 PM (UTC) |
| Message
| In this mud I play there is a guild based on reputation. Players can check their reputation with command which produces text something like this:
Reputation bar:
[@####:::::::::....]
All dots meaning one piece of reputation,
colons meaning 10 pieces,
#'s meaning 100 and @'s meaning 1000 pieces of reputation.
So I want to change this bar into numbers. What is the best way to do this? I think I should make a trigger which whenever finds eg. a dot, adds one to my reputation variable but I don't know how to do it.
Sorry for bad english ;) |
++ Ankka | | Top |
|
| Posted by
| Dubthach
(47 posts) Bio
|
| Date
| Reply #1 on Fri 15 Jun 2001 05:08 PM (UTC) |
| Message
| In perlscript the code would look something like the following...you'd have to change it to interface with mushclient a bit. Replace $raw_string with whatever you pass to the script from your trigger.
$raw_string = "[@#:::....]";
@individual_chars = split(//, $raw_string);
$atsign = 0;
$hash = 0;
$colon = 0;
$period = 0;
foreach (@individual_chars)
{
if (/@/)
{
$atsign++;
}
elsif (/\#/)
{
$hash++;
}
elsif (/:/)
{
$colon++;
}
elsif (/\./)
{
$period++;
}
}
$reputation = (1000 * $atsign) +
(100 * $hash) +
(10 * $colon) +
$period;
$world->send($reputation); | | Top |
|
| Posted by
| Dubthach
(47 posts) Bio
|
| Date
| Reply #2 on Fri 15 Jun 2001 05:24 PM (UTC) |
| Message
| Upon a bit of testing, I realize I made a mistake. Apparently @@ is a special magic thing in Perl. So...before you split the string, replace @'s with ^'s with this line:
$raw_string =~ s/\@/\^/g;
And change the line in the foreach that matches on @'s to match on ^'s with:
if (/\^/)
Sorry bout that, it worked with my initial (only 1 @) test. | | Top |
|
| Posted by
| Ankka
Finland (3 posts) Bio
|
| Date
| Reply #3 on Mon 18 Jun 2001 08:19 AM (UTC) |
| Message
| Never used PerlScript before and it contained some bugs but finally got it to work right.
Thanks very much, couldn't do it without you.
|
++ Ankka | | Top |
|
| Posted by
| Ankka
Finland (3 posts) Bio
|
| Date
| Reply #4 on Mon 18 Jun 2001 08:20 AM (UTC) |
| Message
| | Oh, just noticed that there weren't any bugs i just typoed part of the script :) |
++ Ankka | | 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.
20,418 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top