作者hmml (hmml)
看板mud_sanc
标题[心得] MUSHclient - ob trade 自制介面
时间Sun Dec 15 12:18:22 2013
让 ob trade 指令比较方便使用的触发...大概
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
当下指令:"obtrd playerID"时,开始取得交易对象ID,并送出指令:ob。
这一系列触发唯有变数 a 不为 nil 时,才会触发。
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
<aliases>
<alias
match="
obtrd(.*)"
enabled="y"
group="obtrading"
regexp="y"
send_to="12"
sequence="100"
>
<send>
if '%1' == "" then
Note (" 你要跟谁交易?<obtrd playerID>")
else
--将交易对象ID赋值於 a
a = Trim('%1')
--送出指令 ob 到 MUD。
Send('ob')
end
</send>
</alias>
</aliases>
<triggers>
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
清空 OB_list 用!
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
<trigger
enabled="y"
group="obtrading"
match="
^你的物..栏带着 \d+\/99 种物..:$"
regexp="y"
send_to="12"
sequence="100"
>
<send>OB_list = nil</send>
</trigger>
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
停止收集 ob 内容,并开始作业
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
<trigger
enabled="y"
group="obtrading"
match="
^╚═════╩═══════════════════════════
═════╝$"
regexp="y"
send_to="12"
sequence="100"
>
<send>
--移除变数。
b,Sell_list ,k_h = nil, nil,nil
--判断 a 值是否存在。
if a ~= nil then
--对话框1:设定出售的清单。
result = utils.multilistbox("请选择要出售的物品:",
"OB交易",
OB_list,
default)
--如果按下 cancel 或 未选择项目就按下 OK 时
if result == nil or table.maxn(result) == 0 then
Note ('交易已经中止!')
--
else
SellALL = {}
table.foreach(result, function(i) table.insert(SellALL,OB_list[i]) end)
--为下一个对话框建立已选择物品清单
for k,y in pairs(SellALL) do
if Sell_list == nil then Sell_list = "" end
k_h = 12*k
--下一个对话框的尺寸变动值(高)
Sell_list = Sell_list
.."║
"..string.format("%%02d",k)
.."║
"..
string.format("%%02d",string.match(y,"(%d+)"))
.."║
"..
string.match(y," (%S+)")
.."\\n
"
end --for SellALL to Sell_list
--对话框2:修改出售的数量。
result = utils.inputbox ([[请输入各物品出售的数量:\n]]..
[[1.各项数量以","分隔!\n]]..
[[2.欲全数卖出单品,输入"a"。\n]]..
[[3.单品卖量大於持有量时,视为该项全数卖出。\n]]..
[[4.不输入内容直接按下确定,则整批全数出清。\n]]..
[[╔═╦═╦═════════════════\n]]..
[[║项║量║名 称\n]]..
[[╠═╬═╬═════════════════\n]]..
Sell_list..
[[╚═╩═╩═════════════════]],
"OB交易",
nil,
nil,
'14',
--对话框尺寸调整
{box_width = 320,
box_height = 230
+
k_h,
prompt_width = 310,
prompt_height = 115
+
k_h,
reply_width = 310,
reply_height = 25,
})
--按下 cancel 钮时,
if result == nil then
Note ('交易已经中止!')
--输入框未输入内容并按下OK,直接送出内容。
elseif result == "" then
Send ('ob trade ',table.concat(SellALL,","),' with ',a)
--输入框有内容并按下OK,
else
--取出result的值到v并遍历
for v in string.gmatch(result,"(%w+)") do
--gmatch不存在索引值,必须自行设定
if b == nil then b = 1 end
--v为0就清空出售清单对应品项
if v == '0' then
SellALL[b] = ""
--v值不为a也不大於持有数,才修改出售数量
elseif v ~= "a" and v > string.match(SellALL[b],"(%d+)") then
SellALL[b] = string.gsub(SellALL[b],'%d+',v)
end
b = b + 1
end -- for
--整理格式,连续","改为一个","。
SellALL =
string.gsub(table.concat(SellALL
,",
"),',+
',',
')
--移除开头的","。
SellALL =
string.gsub(SellALL
,'^,
','')
--移除末尾的","。
SellALL =
string.gsub(SellALL
,',$
','')
--送出内容。
Send ('ob trade
',SellALL
,' with
',a
)
end
end
end
--移除用毕的变数
a, b, SellALL, OB_list = nil,nil,nil,nil
</send>
</trigger>
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
收集 ob 的资料,并存到OB_list。
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
<trigger
enabled="y"
group="obtrading"
match="
^║( *\d+\.\S+\s+\( +\d+\)║[^\n]+║[^\n]+)║"
regexp="y"
send_to="12"
sequence="100"
>
<send>
if OB_list == nil then OB_list = {} end
if a ~= nil then
for k,
v,
i in string.gmatch('%1
',"(%d+)%.
(%S+)%s+%( +
(%d+)%)
") do
table.insert(OB_list,k,i.." "..v)
end
end --if
</send>
</trigger>
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
</triggers>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.132.196.45
※ 编辑: hmml 来自: 220.132.196.45 (12/15 12:19)