Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="iso-8859-1"?>
- <!DOCTYPE muclient>
- <muclient>
- <plugin
- name="PennMUSHBugFix"
- author="Sora"
- id="4f3adac0d57648e14e1cdf64"
- language="Lua"
- purpose="Fix the \n lag with pennmush"
- save_state="y"
- date_written="2006-07-07 13:14:43"
- requires="3.70"
- version="1.1"
- >
- <description trim="y">
- <![CDATA[
- PennMUSH unfortunately doesn't always send the end of a line (The newline character) immediately after a line, so triggers in mushclient that modify lines will have lag time before they're applied to the line. This fixes that.
- Probably don't wanna use this on MUD's, or things that have 'prompts' that never add on a newline to the end.
- ]]>
- </description>
- </plugin>
- <!-- Get our standard constants -->
- <include name="constants.lua"/>
- <script>
- <![CDATA[
- local oldlength = 0
- local state = 0
- local oldPacket = ""
- function OnPluginPacketReceived (packet)
- -- If we got an anti-idle packet, do nothing with it
- if (packet == "\255\241") then return; end
- if (state ~= 1 and string.sub(packet,-1) == "\n") then
- packet = oldPacket .. packet
- oldPacket = ""
- state = 0
- if (string.len(packet) > 900) then
- Redraw()
- end
- return packet
- end
- local lines = utils.split(oldPacket .. packet,"\n")
- if (table.getn(lines) > 1) then
- packet = table.concat(lines,"\n",1,table.getn(lines)-1) .. "\n"
- oldPacket = table.concat(lines,"\n",table.getn(lines))
- state = 3
- if (string.len(packet) > 900) then
- Redraw()
- end
- return packet
- end
- local packetcopy = packet;
- local packetlength = string.len(packet);
- if (state == 0 and packetlength <= 999) then
- if (string.sub(packet,-1) == "\n") then return packet; end
- oldPacket = packet
- state = 3
- return ""
- elseif (state == 3) then
- if (packet == "\r\n" or (packetlength < 999 and string.sub(packet,-1) == "\n")) then
- packet = oldPacket .. packet
- oldPacket = ""
- state = 0
- if (string.len(packet) > 900) then
- Redraw()
- end
- return packet
- else
- oldPacket = oldPacket .. packet
- return ""
- end
- end
- oldPacket = ""
- if (packetlength < 999 and string.sub(packet,-1) ~= "\n" and (oldlength ~= 999 and packetlength ~= 429)) then
- state = 1;
- if (string.len(packet) > 900) then
- Redraw()
- end
- return packet .. "\r\n";
- end
- if (state == 1) then
- state = 0;
- oldlength = 0;
- if (packet == "\r\n") then
- return "";
- end
- packet = string.gsub(packet,"^\r\n","",1);
- end
- oldlength = packetlength;
- if (string.len(packet) > 900) then
- Redraw()
- end
- return packet;
- end
- ]]>
- </script>
- </muclient>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement