Re: [心得] MushClient 聖殿技能排還原度較好的寫法
看板mud_sanc (Sanctuary - 聖殿)作者hmml (hmml)時間12年前 (2013/06/21 00:25)推噓0(0推 0噓 0→)留言0則, 0人參與討論串4/4 (看更多)
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.132.196.45
→
06/10 07:47,
06/10 07:47
→
06/10 07:47,
06/10 07:47
→
06/10 07:48,
06/10 07:48
→
06/10 07:48,
06/10 07:48
→
06/10 07:48,
06/10 07:48
Mushclient有一個函數,可以直接抓封包先修改內容再給程式處理
,利用這個先判斷移位碼的位置和內容,置換成相對應的空格,那麼就
不用對各式有移位碼的行一一去做修改,這樣就能讓Mushclient的顯示
和zMUD5.55非常接近(5.55根本是聖殿專用版本)。
不過,因為這個函數處理的是封包,所以內容會被封包的上限影響
,一個就是999個字的樣子,一旦內容超過這個限制,就會被截斷,分
成好幾個封包送出去,它截斷的位置幾乎在行的中間,什麼地方都有機
會。導致這樣的寫法幾乎不能成功,特別是它截斷了移位碼的時候...
讓封包能剛好截斷在一行的換行後方,不知可不可行?
不過我也不能保證那樣就能解決問題,也許有些只是Mushclient來
不及處理,只是問一下...
目前寫比較好的如下,分成兩部份,一個先在封包裡讀出移位碼,
並轉成一般字串,另一個判讀變成字串的移位碼,來調整位置。原來用
ColourTell 也改成可做為觸發句的 Simulate,基本上會排失敗大概都
是移位碼遭封包結尾截斷。
如果要寫成一個,只要封包截斷行,都會排失敗。
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on 星期二, 六月 11, 2013, 10:42 下午 -->
<!-- MuClient version 4.84 -->
<!-- Plugin "newtest" generated by Plugin Wizard -->
<muclient>
<plugin
name="newtest_successful"
id="e9aa08a01c2ee15248ce4675"
language="Lua"
purpose="修訂中"
date_written="2013-06-11 22:41:55"
requires="4.84"
version="1.0"
>
<description trim="y">
修訂中
</description>
</plugin>
<!-- Get our standard constants -->
<include name="constants.lua"/>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
keep_evaluating="y"
match="^.*$"
regexp="y"
script="OnPluginPacketReceived"
send_to="12"
sequence="100"
>
</trigger>
</triggers>
<!-- Script -->
<script>
<![CDATA[
-- 原本匹配用的行,目前未使用。
Tab_start_reg = rex.new("\\e\\[24;\\d+H")
-- 在被分析前,就抓到封包的函數
function OnPluginPacketReceived (sText)
-- 移位碼的格式:%c%[24;%d+H
-- %c 代表所有控制字元,如ESC。
-- [24;%d+ 座標,即Y軸和X軸,Y軸是固定數,X軸不是。
-- H 定義這個移位碼的模式,游標的位置。
if string.match(sText,'(%c%[24;)(%d+)H') ~= nil then
sText = string.gsub(sText,'(%c%[24;)(%d+)H',"∴%2∴")
end --if
return sText
end
]]>
</script>
<triggers>
<trigger
enabled="y"
keep_evaluating="y"
match="(∴(\d+)∴)"
omit_from_output="y"
script="ColorType"
regexp="y"
send_to="12"
sequence="100"
>
</trigger>
</triggers>
<!-- Script -->
<script>
<![CDATA[
local conversion = {
['black'] = ANSI(0)..ANSI (30),
['maroon'] = ANSI(0)..ANSI (31),
['green'] = ANSI(0)..ANSI (32),
['olive'] = ANSI(0)..ANSI (33),
['navy'] = ANSI(0)..ANSI (34),
['purple'] = ANSI(0)..ANSI (35),
['teal'] = ANSI(0)..ANSI (36),
['silver'] = ANSI(0)..ANSI (37),
--以下高亮
['gray'] = ANSI (30, 40,1),
['red'] = ANSI (31, 40,1),
['lime'] = ANSI (32, 40,1),
['yellow'] = ANSI (33, 40,1),
['blue'] = ANSI (34, 40,1),
['magenta'] = ANSI (35, 40,1),
['cyan'] = ANSI (36, 40,1),
['white'] = ANSI (37,40,1),
} -- end conversion table
function ColorType (name, line, wildcards, styles)
for _,v in ipairs (styles) do
if string.match(v.text,'∴(%d+)∴') ~= nil then
move_len = string.match(v.text,'∴(%d+)∴')
movelen_len = string.len(string.match(v.text,'(∴%d+∴)'))
textr = string.match(v.text,'(.*)∴%d+∴')
textl = string.match(v.text,'∴%d+∴(.*)')
if v.column ~= 1 then
Simulate(conversion[RGBColourToName (v.textcolour)],
textr,
string.rep(" ",move_len-(GetLineInfo
(GetLinesInBufferCount(),2)+1)-string.len(textr)),
textl)
else
Simulate(conversion[RGBColourToName (v.textcolour)],
vtextr,
string.rep(" ",move_len-v.column-string.len(textr)),
textl)
end -- v.column
else
Simulate(conversion[RGBColourToName (v.textcolour)],
v.text)
end --if match
end --for
Simulate('\n')
end --function
]]>
</script>
</muclient>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.233.202.51
※ 編輯: hmml 來自: 118.233.202.51 (06/21 00:25)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 4 之 4 篇):
mud_sanc 近期熱門文章
PTT遊戲區 即時熱門文章