DeleteVariable on input/send

Posted by 1of10 on Tue 05 Nov 2002 05:07 AM — 7 posts, 28,937 views.

Canada #0
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.
USA #1
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.
Canada #2
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... :)
Australia Forum Administrator #3
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.

Canada #4
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?
Australia Forum Administrator #5
*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.
Canada #6
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! :)