[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Reconnecter Plugin

Reconnecter Plugin

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Invictus84   USA  (6 posts)  [Biography] bio
Date Tue 11 Dec 2007 07:31 PM (UTC)
Message
So, recently I decided to take the plunge, give MS Windows the axe and put Ubuntu 7.10 on my system as its only OS. Everything has been smooth up to this point, except I can't get non-Lua scripts/plugins to work, at all. Just crashes MUSHclient every time. After spending 3 days trying to find out what all .dll's might be required for running VBscript (as the only non-Lua plugin I really care about is written in VBscript) other than vbscript.dll (which I managed to find a download for, but it didn't help at all), I've given up and just went looking for a Lua version of the Reconnecter plugin.

Well, I didn't find one... and my ability to script is severly lacking. So, has anyone managed to rewrite the reconnecter plugin for Lua? Or is Lua even capable of performing those functions in the plugin?

Any help is greatly appreciated :)
[Go to top] top

Posted by Shaun Biggs   USA  (644 posts)  [Biography] bio
Date Reply #1 on Tue 11 Dec 2007 08:07 PM (UTC)
Message
If no one has jumped on this by the end of tomorrow (New York time), I'll convert it for you. I won't have access to MUSHclient to test it out at all until then, but it should not take long at all to get this little plugin converted to Lua.

It is much easier to fight for one's ideals than to live up to them.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Tue 11 Dec 2007 11:43 PM (UTC)

Amended on Tue 11 Dec 2007 11:45 PM (UTC) by Nick Gammon

Message
Quote:

Or is Lua even capable of performing those functions in the plugin?


Yes, Lua is capable of most feats. :)

Here is a Lua version of the reconnector plugin:


<?xml Version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient [
  <!ENTITY interval "10" >
  <!ENTITY quit_command "quit" >
  <!ENTITY connect_command "connect" >
  <!ENTITY noconnect_command "NOCONNECT" >
]>

<!-- Plugin "Reconnecter" generated by Plugin Wizard -->

<!--
1. Change the entity above "interval" to be the number of seconds
between retries.

2. Change the entity above "quit_command" to be the command you
type to quit (eg. quit, QUIT, @quit or whatever)

3. Change the entity above "connect_command" to be the command you
type to enable connection checking.

4. Change the entity above "noconnect_command" to be the command you
type to disable connection checking.

-->

<muclient>
<plugin
   name="Reconnecter"
   author="Nick Gammon"
   id="dc8cb4a314674db813c12c90"
   language="Lua"
   purpose="Reconnects when disconnected"
   date_written="2007-12-12 11:30:00"
   requires="3.80"
   version="2.0"
   >
<description Trim="y">
<![CDATA[
This plugin will automatically reconnect you when you are disconnected, 
at a user-configurable interval (say, every 5 seconds)
]]>

Reconnecter:Help - this Help screen

&connect_command;  - enable recconnection (eg. after using &noconnect_command;)

&noconnect_command; - disable reconnection (eg. if you are leaving the PC)

</description>

</plugin>


<!--  Timers  -->

<timers>
  <timer name="ConnectCheckTimer" 
         script="OnConnectCheckTimer" 
         second="&interval;" 
         active_closed="y" 
         enabled="y">

  </timer>
</timers>

<!--  Aliases  -->

<aliases>
  <alias
   script="OnQuit"
   match="&quit_command;"
   enabled="y"
  >
  </alias>

  <alias
   script="OnConnect"
   match="&connect_command;"
   enabled="y"
  >
  </alias>
  <alias
   script="OnNoConnect"
   match="&noconnect_command;"
   enabled="y"
  >
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[
local retry, did_quit

retry = 0  -- retry count
did_quit = false

function OnConnectCheckTimer (sName)
  
  --
  --  If currently connecting, leave it to do that ...
  --
  
  if GetInfo (107) then 
    return
  end -- if
  
  
  --
  --  If currently connected, we don't need to check any more
  --
  
  if IsConnected () then
    Note "World is connected, disabling disconnection check"
    EnableTimer (sName, false)
    return
  end -- if
  
  --
  --  If deliberate quit, we don't need to check any more
  --
  if did_quit then
    Note "Deliberate quit, disabling disconnection check"
    EnableTimer (sName, false)
    return
  end -- if
  
  --
  --  OK, we need to Connect now ...
  --
  
  retry = retry + 1
  
  Note ("Connecting to world, attempt # " .. retry)
  Connect ()

end -- function

function OnPluginDisconnect ()
  --
  --  If deliberate quit, we don't need to enable the connection check
  --
  
  if did_quit then  
    return
  end -- if
  
  --
  --  We have been disconnected, we need to try connecting again
  --

  Note "Connection checker enabled"
  EnableTimer ("ConnectCheckTimer", true)
  
end -- function

function OnPluginConnect ()
  
  --
  --  Now we are connected, no need to keep trying to Connect
  --
  
  retry = 0
  EnableTimer ("ConnectCheckTimer", false)
  
  --
  --  No deliberate quit yet
  --
  
  did_quit = false
    
end -- function

function OnPluginInstall ()
  DoAfterNote (1, "Connection checker installed.")
end -- function

]]>

function OnQuit (sName, sLine, wildcards)
  did_quit = true
  Send ("&quit_command;") --  Send to world so it does it
  Note "Deliberate quit (&quit_command;), reconnect disabled"
end -- function

function OnConnect (sName, sLine, wildcards)
  Note "Connection checker enabled"
  EnableTimer ("ConnectCheckTimer", true)
  did_quit = false
end -- function

function OnNoConnect (sName, sLine, wildcards)
  Note "Connection checker disabled"
  EnableTimer ("ConnectCheckTimer", false)
  did_quit = true
end -- function


</script>


<!--  Plugin Help  -->

<aliases>
  <alias
   script="OnHelp"
   match="Reconnecter:Help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
function OnHelp (sName, sLine, wildcards)
  Note (GetPluginInfo (GetPluginID, 3))
end -- function
]]>
</script> 

</muclient>

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Invictus84   USA  (6 posts)  [Biography] bio
Date Reply #3 on Wed 12 Dec 2007 12:09 AM (UTC)

Amended on Wed 12 Dec 2007 12:32 AM (UTC) by Invictus84

Message
Oh, man, you guys rock :)

Now I can return to my regularly scheduled idling for days on end... :P

Thanks a heap :)

[EDIT]: That should seriously be added to the list of Plugins... I'm sure there's plenty of people running Linux who would love to use that plugin, due to the possible problems with VBscript (though they could easily just copy/paste from this thread :P).
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Wed 12 Dec 2007 02:21 AM (UTC)
Message
I have uploaded the amended version as the "official" one for this web site.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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,639 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]