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
➜ DeleteVariable on input/send
DeleteVariable on input/send
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| 1of10
Canada (54 posts) Bio
|
Date
| Tue 05 Nov 2002 05:07 AM (UTC) |
Message
| I'm wondering if anyone has a script or knows of a way to delete a variable upon sending something to a server from the input box?
I have an anti-idle script that sends an input to a server when an idle warning string is received. The trick here is it only sends an input so many times. It keeps track of how many times it has sent with a variable. What I would like is have the number of inputs automatically deleted when I send text myself, instead of having to remember to execute the $world->deletevariable function myself.
I'd prefer to have such a script written in PerlScript, but I can convert from VBScript or JScript. |
One of Ten
Secondary Adjunct of Unimatrix Z03 | Top |
|
Posted by
| Meerclar
USA (733 posts) Bio
|
Date
| Reply #1 on Tue 05 Nov 2002 09:58 AM (UTC) |
Message
| Cant honestly say I know enough about perl to help revise the script there but something like what follows should do the trick nicely. (Please note, I did say *should* :P)
Inside whatever script you're using insert a loop similar to this:
send_to_world <anti_idle text here>
idle_counter=idle_counter + 1
if $world->deletevariable
idle_counter=0
granted, that particular loop probly wouldnt work even in my wildest dreams but it should give you an decent idea how to setup what you were asking about. I know for fact it can be done in VB because Ive done similar functions and Im guessing its doable in Perl with some minor tweaking. |
Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org | Top |
|
Posted by
| 1of10
Canada (54 posts) Bio
|
Date
| Reply #2 on Tue 05 Nov 2002 09:17 PM (UTC) |
Message
| Thanks for the input on the subject, however, that doesn't quite look like it'll work at all.
Currently my script looks for an idle warning text:
*** WARNING: Input within 1 minute or you will be disconnected. ***
It then sends an anti-idle input:
.emote inputs.
A counter variable is set/incremented which contains the number of times the above text has been sent by the script.
What I'm looking for is something that will read when I send something myself (not something sent from within the script), perhaps a "Hello everyone, I'm back!", but could be anything, and delete the variable mentioned above so that I don't have to remember to do it myself.
Yeah, I'm trying to be lazy... :) |
One of Ten
Secondary Adjunct of Unimatrix Z03 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Tue 05 Nov 2002 09:41 PM (UTC) |
Message
| Let's assume you have put the anti-idle into a plugin, and if not, that is easy to do. Then you just need to add the following lines into the plugin script, and it will do what you want ...
sub OnPluginCommand
{
$world->DeleteVariable ("counter");
$retval = 1;
}
What this does, is on every command typed (ie. when you type something) delete the variable counter (or you might use "SetVariable" to set it to zero), and then return "1" which tells MUSHclient to go ahead and process the command.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| 1of10
Canada (54 posts) Bio
|
Date
| Reply #4 on Tue 05 Nov 2002 10:47 PM (UTC) |
Message
| That sounds like exactly what I need! :)
However, I have two triggers that trigger on the same line of text. One for the anti-idle and another for when I'm AFK. The anti-idle trigger is always enabled, except when AFK. When I use my custom AFK script, the anti-idle trigger is disabled so that the AFK-specific anti-idle trigger can be enabled.
If I put the anti-idle into a plugin, would that cause problems with the other trigger, which would still be in the world file? Would it work to make the AFK-specific trigger a temporary one? I think if the anti-idle were to be converted to a plugin, I'd have to make the plugin check to see if another trigger of the same text is already enabled. Is this all possible? Is there a non-plugin OnCommand function planned for a future release? Am I still making sence? Am I becoming a pain yet? |
One of Ten
Secondary Adjunct of Unimatrix Z03 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #5 on Tue 05 Nov 2002 11:50 PM (UTC) |
Message
| *boggles*
First, why not put both into the same plugin? They sound like they are doing a related job.
Failing that, yes you can check from inside the plugin if a non-plugin trigger is enabled. See the script routine world.GetPluginTriggerInfo. The plugin ID is empty for global triggers, and the enabled flag is selector 8. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| 1of10
Canada (54 posts) Bio
|
Date
| Reply #6 on Wed 06 Nov 2002 12:01 AM (UTC) |
Message
| Yes, they are doing the same thing. But, one is for an anti-idle while just idling. The other is an anti-idle while AFK (Away From Keyboard). I can't quite merge them as the two subroutines are quite different, even though they have the same exact triggers. So, I'll have to do the check from within a plugin.
Thanks for the help! :) |
One of Ten
Secondary Adjunct of Unimatrix Z03 | 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.
22,280 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top