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
➜ Perlscript
➜ Using $world->doafter in if()
|
Using $world->doafter in if()
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Nid
Sweden (9 posts) Bio
|
| Date
| Tue 29 Aug 2006 05:12 PM (UTC) |
| Message
| Hey again, newbie speaking.
I'm trying to do this:
sub testing
{
if ($world->getvariable("test") =~ 1)
{
$world->doafter(10, $world->setvariable("testing", "1") );
$world->note($world->getvariable("testing"));
}
}
The problem here is that it sets the variable testing to 1 immediately, it doesn't wait 10 seconds. hence, the $world->note will show "1" instead of 0.
Any way to correct this?
Thanks in advance. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Tue 29 Aug 2006 08:52 PM (UTC) |
| Message
| You have a couple of problems here. For one thing, DoAfter is supposed to have a string as its second argument, eg.
$world->DoAfter(10, "eat fish" )
You haven't quoted the argument, so it will be done immediately.
The second problem is that even if you do that, it will send the script command to the MUD: eg.
$world->DoAfter(10, '$world->SetVariable("testing", "1")' );
This at least quotes the command, but it will send '$world->SetVariable("testing", "1")' to the MUD after 10 seconds. So what you want is DoAfterSpecial, and send to the script engine, like this:
$world->DoAfterSpecial(10, '$world->SetVariable("testing", "1")' , 12);
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Nid
Sweden (9 posts) Bio
|
| Date
| Reply #2 on Tue 29 Aug 2006 10:07 PM (UTC) |
| Message
| | Worked perfectly, thanks Nick! | | 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.
15,791 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top