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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Aardwolf telnet negotiation plugin helper

Aardwolf telnet negotiation plugin helper

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


Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Sat 12 Jul 2008 10:01 PM (UTC)

Amended on Sat 12 Jul 2008 10:04 PM (UTC) by Nick Gammon

Message
The Lua file below is used by various Aardwolf plugins I will be describing.

It provides an interface with the Aardwolf server, as described in this post:

http://www.gammon.com.au/forum/?id=8771

More information is at:

http://www.aardwolf.com/blog/2008/07/10/telnet-negotiation-control-mud-client-interaction


To use it, download the code below and save as telnet_options.lua in the Aardwolf subdirectory below your Plugins directory. If you haven't used any Aardwolf plugins before you may need to make the Aardwolf directory.

Alternatively, RH click the link below and choose "Save Link As" (or "Save Linked File As") to save the linked file.

http://www.gammon.com.au/mushclient/plugins/Aardwolf/telnet_options.lua

Once installed, a plugin can turn an option on or off like this:


-- pull in telnet option handling
dofile (GetPluginInfo (GetPluginID (), 20) .. "telnet_options.lua")  --> get this file
  
function OnPluginConnect ()
  TelnetOptionOn (TELOPT_STATMON)   --> tell server to send stats
end -- function OnPluginConnect

function OnPluginClose ()
  TelnetOptionOff (TELOPT_STATMON)   --> tell server to stop sending stats
end -- OnPluginClose



The call to GetPluginInfo (GetPluginID (), 20) returns the directory in which the current plugin resides, so the file telnet_options.lua should be in the same directory as your plugins.


Module code follows:



-- well-known options


TELOPT_STATMON = 1
TELOPT_BIGMAP = 2
TELOPT_HELPS = 3
TELOPT_MAP = 4
TELOPT_CHANNELS = 5
TELOPT_TELLS = 6
TELOPT_SPELLUP = 7
TELOPT_SKILLGAINS = 8
TELOPT_SAYS = 9
TELOPT_SCORE = 11
TELOPT_ROOM_NAMES = 12
TELOPT_EXIT_NAMES = 14
TELOPT_EDITOR_TAGS = 15
TELOPT_EQUIPMENT = 16
TELOPT_INVENTORY = 17
            
TELOPT_QUIET = 50
TELOPT_AUTOTICK = 51
TELOPT_PROMPT = 52
TELOPT_PAGING = 53
TELOPT_AUTOMAP = 54
TELOPT_SHORTMAP = 55


TELOPT_REQUEST_STATUS = 100



local function TelnetOption (which, on)
  -- Telnet Negotiation Options
  local IAC, SB, SE = 0xFF, 0xFA, 0xF0
  local TELOPT_WILL, TELOPT_WONT, TELOPT_DO, TELOPT_DONT = 0xFB,0xFC, 0xFD, 0xFE       
  
  -- Telnet subnegotiation for Aardwolf
  local AARDWOLF_TELOPT = 102
  
  local TELOPT_ON, TELOPT_OFF = 1, 2  -- turn on or off
  


  if on then
    SendPkt (string.char (IAC, SB, AARDWOLF_TELOPT, which, TELOPT_ON, IAC, SE)) 
  else
    SendPkt (string.char (IAC, SB, AARDWOLF_TELOPT, which, TELOPT_OFF, IAC, SE)) 
  end -- if
  
end -- TelnetOption


function TelnetOptionOn (which)
  TelnetOption (which, true)
end -- TelnetOptionOn


function TelnetOptionOff (which)
  TelnetOption (which, false)
end -- TelnetOptionOff


if GetOption ("enable_triggers") ~= 1 then
  ColourNote ("white", "red", "Warning: Triggers not enabled")
end -- if no triggers


if GetOption ("enable_aliases") ~= 1 then
  ColourNote ("white", "red", "Warning: Aliases not enabled")
end -- if no triggers


if GetOption ("enable_timers") ~= 1 then
  ColourNote ("white", "red", "Warning: Timers not enabled")
end -- if no triggers



- Nick Gammon

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

Posted by Habot   (1 post)  [Biography] bio
Date Reply #1 on Mon 21 Jul 2008 12:33 PM (UTC)
Message
At the risk of sounding stupid (a risk I often take), how do you install the lua file? Does it automatically take effect if it is downloaded to the correct folder, or is it necessary to somehow get Mushclient to access it?

Thanks for all the time and effort.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Mon 21 Jul 2008 09:29 PM (UTC)

Amended on Mon 21 Jul 2008 09:30 PM (UTC) by Nick Gammon

Message
The first line in my example does that:


dofile (GetPluginInfo (GetPluginID (), 20) .. "telnet_options.lua")  --> get this file


The function "dofile" in Lua reads Lua code into memory and executes it. The call to GetPluginInfo (GetPluginID (), 20) returns the directory in which the plugin that you are currently executing, resides in, so that is why you put the file into that directory.


http://www.gammon.com.au/scripts/doc.php?lua=dofile


- 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.


12,986 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]