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
➜ Bug reports
➜ ColourNote called from within OnPluginTelnetSubnegotiation
ColourNote called from within OnPluginTelnetSubnegotiation
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Kevnuke
USA (145 posts) Bio
|
Date
| Sat 07 Jan 2012 05:26 AM (UTC) |
Message
| I got a basic GMCP plugin working that simply notes the output of messages to the output window. It works as expected, except for one thing. The background color of ColourNote I use to show the GMCP messages is getting applied to some of the text that it shouldn't be.
Here is the relevant piece of the plugin..
Version 4.80
<script>
<![CDATA[
require("json")
require("tprint")
-- GMCP and Telnet Request/Subnegotiation info
local CLIENT_ID = {client="MUSHclient", version=Version()}
local codes = {
IAC_SB_GMCP = "\255\250\201", -- begins a GMCP packet
IAC_SE = "\255\240", -- ends a GMCP packet
GMCP = 201, -- GMCP protocol number
}
local SB_GMCP = codes.IAC_SB_GMCP .. "%s" .. codes.IAC_SE
-- GMCP modules supported by this plugin
local GMCP_options = {
"Core 1",
"Char 1",
"Char.Skills 1",
"Char.Items 1",
"Comm.Channel 1",
"Room 1",
"Redirect 1",
"IRE.Rift 1",
"IRE.Composer 1",
}
function SendGMCP(message, content)
if type(message) ~= "string" then
return nil, "Message name must be a string."
end
if content ~= nil then
content = json.encode({content})
if content == nil then
return nil, "Invalid input."
end
message = ("%s %s"):format(message, content:sub(2, #content-1))
end
SendPkt(SB_GMCP:format(message))
return true
end
function OnPluginTelnetRequest (opt, data)
if opt ~= 201 then
return false
end
if data == "SENT_DO" then
Note("GMCP enabled.\n")
SendGMCP("Core.Hello ", CLIENT_ID)
SendGMCP("Core.Supports.Set ", GMCP_options)
end
return true
end
function OnPluginTelnetSubnegotiation (opt, data)
if opt ~= codes.GMCP then
return
end
ColourNote ("blue", "white", data)
local msg, content = unpack(utils.split(data, " ", 1))
if not content or content:len() == 0 then
content = nil
else
-- Not every JSON parser allows any top-level value to be valid.
-- Ensuring that a non-object non-array value is at least within
-- an array makes this code parser-agnostic.
local err
content, err = json.decode(("[%s]"):format(content))
if content ~= nil then
content = content[1]
else
error("Invalid message: " .. err)
end
end
function toggle_debug()
gmcpdebug = not gmcpdebug
Note(("GMCP Debugging is %s"):format(gmcpdebug and "Enabled" or "Disabled"))
end
]]>
</script>
..how do I upload screenshots? | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #1 on Sat 07 Jan 2012 05:40 AM (UTC) |
Message
|
Kevnuke said: ..how do I upload screenshots?
Upload them to a service like imageshack.us, and post the link.
I have to ask, why are you modifying the original GMCP plugin? It's meant to emit data for other plugins to use, not to be directly modified itself. Also, there's a GMCP DEBUG alias in the original that toggles debug output, displaying GMCP data as it comes in. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Kevnuke
USA (145 posts) Bio
|
Date
| Reply #2 on Sat 07 Jan 2012 05:49 AM (UTC) |
Message
| Because I'm going to have everything done in a single plugin, it doesn't need to broadcast. I wanted to see the unmodified message from the server. It's more of a personal project to improve my Lua skills. Such as how to take the server output and put it into useable tables and other variables. I saw you do it in the plugin but I wanted to understand it well enough to recreate it myself.
I'll post screenshots when I'm on my computer. | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #3 on Sat 07 Jan 2012 08:22 AM (UTC) |
Message
|
Kevnuke said: Because I'm going to have everything done in a single plugin, it doesn't need to broadcast. I wanted to see the unmodified message from the server. It's more of a personal project to improve my Lua skills. Such as how to take the server output and put it into useable tables and other variables. I saw you do it in the plugin but I wanted to understand it well enough to recreate it myself.
Fair enough. Just keep in mind it probably won't cooperate other plugins that need GMCP, whether you release yours for other people to use, or you install other peoples' plugins. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Kevnuke
USA (145 posts) Bio
|
Date
| Reply #4 on Sun 08 Jan 2012 08:59 PM (UTC) Amended on Sun 08 Jan 2012 09:01 PM (UTC) by Kevnuke
|
Message
| Here are the screenshots for what I was talking about.
http://imageshack.us/g/502/achaea03.jpg/
What's the forum code for a hyperlink?.. I didn't see it in the link. | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #5 on Sun 08 Jan 2012 09:33 PM (UTC) |
Message
| Links and images are tags reserved for forum admins, which basically just means Nick.
I'm not really sure why ColourNote is doing that, to be honest... |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Kevnuke
USA (145 posts) Bio
|
Date
| Reply #6 on Sun 08 Jan 2012 09:42 PM (UTC) |
Message
|
Twisol said:
Links and images are tags reserved for forum admins, which basically just means Nick.
Thanks, good to know.
Twisol said:
I'm not really sure why ColourNote is doing that, to be honest...
Well if anything my little experiment maybe discovered a bug? | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #7 on Mon 09 Jan 2012 05:57 AM (UTC) |
Message
|
Kevnuke said:
I got a basic GMCP plugin working that simply notes the output of messages to the output window. It works as expected, except for one thing. The background color of ColourNote I use to show the GMCP messages is getting applied to some of the text that it shouldn't be.
Doing a ColourNote during telnet negotiation may lead to strange results. You are injecting a new line into what might be a partial line received from the MUD.
If you must do this, I would queue it up (eg. with DoAfterNote) and have it appear in a more orderly way. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Kevnuke
USA (145 posts) Bio
|
Date
| Reply #8 on Fri 17 Feb 2012 06:44 PM (UTC) |
Message
| Thanks for the explanation, Nick. I just got the memo because I forgot to subscribe to this thread lol.
Holy crap! Working on a Mac really screwed me up! I got used to using the scroll wheel on my mouse in the reverse direction in the 4 days that I couldn't use my laptop.. | 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.
26,973 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top