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.
Entire forum
➜ MUSHclient
➜ Perlscript
➜ Crashing Mushclient with a script
Crashing Mushclient with a script
|
Posting of new messages is disabled at present.
Refresh page
Posted by
| AndrewWalmsley
(4 posts) Bio
|
Date
| Sat 25 May 2002 03:58 PM (UTC) |
Message
| Trying to write a nice simple script to colour my hp on prompt line depending how many left as %.
However, replacing $world-Note with $world->Tell in follwing example crashes the client. I need to use tell to avoid colouring the rest of the line. (going to do the same to mana and move).
Anmyone spot what I've done wrong here?
I've taken out the rest as that seems to work.
prompt is
prompt : area name : hp : maxhp : mana : mv :
trigger works off ^prompt : *
sub ColourHP
{
@promptline=split(/:/,@_[1]);
$currentHP = @promptline[1];
$maxHP = @promptline[2];
$percentHP = $currentHP / $maxHP * 100;
foreach $pr (@promptline) {
$world->Note("$pr");
}
}
| Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #2 on Sun 26 May 2002 02:06 AM (UTC) |
Message
| I cannot reproduce that, either in the latest version or 3.20. Can you give the exact line you are matching on?
For example, if I get the line:
prompt : area name : 15 : 100 : 200 : 300 :
I see the following tells:
prompt area name 15 100 200 300
It seems to have done its stuff. The colons are gone, and there is no crash. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| AndrewWalmsley
(4 posts) Bio
|
Date
| Reply #3 on Sun 26 May 2002 07:37 AM (UTC) |
Message
| Just rechecked to see if reboot fixed problem, and it didn't.
The exact line I'm matching on is
prompt : Valley of the Elves : 4951 : 4951 : 1429 : 802
world Note give the output I'd expect i.e.
prompt
Valley of the Elves
4951
4951
1429
802
rest of code (all commented out is)
# if ($percentHP >= 100)
# {
# $world->NoteColourname ("lawngreen","");
# }
# elsif ($percentHP >= 50)
# {
# $world->NoteColourname ("green","");
# }
# elsif ($percentHP >= 25)
# {
# $world->NoteColourname ("crimson","");
# }
# else
# {
# $world->NoteColourname ("red","");
# }
# $world->Tell("@promptline[2]");
# $world->notecolourfore=$oldforecolour;
# $world->Note("hp @promptline[4] mn @promptline[5] mv");
| Top |
|
Posted by
| AndrewWalmsley
(4 posts) Bio
|
Date
| Reply #4 on Sun 26 May 2002 10:23 AM (UTC) |
Message
| OK, now I'm totally confused. Upreved to 3.22, script still crashed client, rewrote it to below, and this works, even if uncommenting foreach debugging bit.
<shrug>
sub ColourHP
{
@promptline=split(/:/,@_[1]);
$currentHP = @promptline[2];
$maxHP = @promptline[3];
$percentHP = $currentHP / $maxHP * 100;
# foreach $pr (@promptline) {
# $world->Tell("$pr");
# }
$world->Tell("@promptline[1]");
if ($percentHP >= 100)
{
$world->NoteColourRGB(0xCCCCCC,0x00);
}
elsif ($percentHP >= 50)
{
$world->NoteColourRGB(0xCC00,0x00);
}
elsif ($percentHP >= 25)
{
$world->NoteColourRGB(0xAA,0xFF);
}
else
{
$world->NoteColourRGB(0xFF,0x00);
}
$world->Tell("@promptline[2]");
$world->NoteColourRGB(0xCCCCCC,0x00);
$world->Tell("hp @promptline[4] mn @promptline[5] mv\n");
}
| Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #5 on Sun 26 May 2002 10:17 PM (UTC) |
Message
| Could be your version of PerlScript is faulty. :)
My version of PerlSE.dll is 5,6,0,613 (ActivePerl 5.6.0.613).
Even if yours is later that doesn't prove much - later releases can be more unreliable than earlier ones. I would try downloading a new version of Perlscript. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #6 on Sun 26 May 2002 10:21 PM (UTC) |
Message
| You say that "note" works but "tell" doesn't. Internally note and tell are almost identical. Here is the actual code for the world.note from my C++ code ...
const char ENDLINE [] = "\r\n"; // line terminator
void CMUSHclientDoc::Note(LPCTSTR Message)
{
CString strMsg = Message;
if (strMsg.Right (2) != ENDLINE)
strMsg += ENDLINE; // add a new line if necessary
Tell (strMsg);
}
You can see that note only does one extra step - adds a newline if it isn't already there, then calls Tell. Unless the newline somehow prevents a crash - something that is a bit far-fetched, the problem is not in MUSHclient. In any case, you could test that by using "tell" but adding \r\n to the text, so the Note and Tell do exactly the same thing. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
17,135 views.
Posting of new messages is disabled at present.
Refresh page
top