chans 发表于 2010-7-23 22:58:19

mush高手看看。插件一加载触发,就读写错误。

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on 星期五, 五月 22, 2009, 1:43 上午 -->
<!-- MuClient version 4.40 -->

<!-- Plugin "HP_mini_Window" generated by Plugin Wizard -->

<muclient>
<plugin
   name="HP_mini_Window"
   author="ddid"
   id="03e3941e672af271ddd47ae1"
   language="Lua"
   purpose="在一个mini window中,显示玩家的HP"
   save_state="y"
   date_written="2009-05-22 01:41:54"
   requires="4.40"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Version 1.2

在一个mini widnow中,显示玩家的HP

在游戏中,输入hp
可以在右上角的mini window中,同步显示hp值。

window_on 打开窗口。
window_off 可将该窗口关闭。
window_refresh 刷新该窗口。
]]>
</description>

</plugin>


<!--Get our standard constants -->

<include name="constants.lua"/>

<!--Triggers-->

<triggers>
<trigger
   custom_colour="2"
   keep_evaluating="y"
   enabled="y"
   group="hp_mini_window"
   match="^[> ]*fystatus\:gin\:(?P<jing>\d+)\/(?P<max_jing>\d+)\/(?P<b_max_jing>\d+)$"
   name="statgin"
   regexp="y"
   send_to="12"
   sequence="200"
>
<send>draw_window()</send>
</trigger>
<trigger
   custom_colour="2"
   keep_evaluating="y"
   enabled="y"
   group="hp_mini_window"
   match="^[> ]*fystatus\:kee\:(?P<qi>\d+)\/(?P<max_qi>\d+)\/(?P<b_max_qi>\d+)$"
   name="statkee"
   regexp="y"
   send_to="12"
   sequence="202"
>
<send>draw_window()</send>
    </trigger>
<trigger
   custom_colour="2"
   keep_evaluating="y"
   enabled="y"
   group="hp_mini_window"
   match="^[> ]*fystatus\:sen\:(?P<jingli>\d+)\/(?P<max_jingli>\d+)\/(?P<b_max_jingli>\d+)$"
   name="statsen"
   regexp="y"
   send_to="12"
   sequence="204"
>
<send>draw_window()</send>
    </trigger>
<trigger
   custom_colour="2"
   keep_evaluating="y"
   enabled="y"
   group="hp_mini_window"
   match="^[> ]*fystatus\:atman\:(?P<shiwu>\d+)\/(?P<max_shiwu>\d+)$"
   name="statatman"
   sequence="208"
>
<send>draw_window()</send>
   </trigger>
<trigger
   custom_colour="2"
   keep_evaluating="y"
   enabled="y"
   group="hp_mini_window"
   match="^[> ]*fystatus\:force\:(?P<neili>\d+)\/(?P<max_neili>\d+)$"
   name="statforce"
   regexp="y"
   send_to="12"
   sequence="210"
>
<send>draw_window()</send>

</trigger>
<trigger
   custom_colour="2"
   keep_evaluating="y"
   enabled="y"
   group="hp_mini_window"
   match="^[> ]*fystatus\:mana\:(?P<yinshui>\d+)\/(?P<max_yinshui>\d+)$"
   name="statmana"
   regexp="y"
   send_to="12"
   sequence="212"
>
<send>draw_window()</send>
    </trigger>
<trigger
   custom_colour="2"
   keep_evaluating="y"
   enabled="y"
   group="hp_mini_window"
   match="^[> ]*\s*fystatus\:kee\:(?P<qi>\d+)\/(?P<max_qi>\d+)\/(?P<b_max_qi>\d+)\;gin\:(?P<jing>\d+)\/(?P<max_jin>\d+)\/(?P<b_max_jin>\d+)\;sen\:(?P<jingli>\d+)\/(?P<max_jingli>\d+)\/(?P<b_max_jingli>\d+)$"
   name="statkeeginsen"
   regexp="y"
   send_to="12"
   sequence="214"
>
<send>draw_window()</send>
    </trigger>
<trigger
   custom_colour="2"
   keep_evaluating="y"
   enabled="y"
   group="hp_mini_window"
   match="^[> ]*fystatus\:force\:(?P<neili>\d+)\/(?P<max_neili>\d+);mana\:(?P<yinshui>\d+)\/(?P<max_yinshui>\d+);atman\:(?P<shiwu>\d+)\/(?P<max_shiwu>\d+)$"
   name="statforceatmanmana"
   regexp="y"
   send_to="12"
   sequence="216"
>
<send>draw_window()</send>
</trigger>
</triggers>

<!--Aliases-->

<aliases>
<alias
   match="window_refresh"
   enabled="y"
   group="hp_mini_window"
   send_to="12"
   sequence="100"
>
<send>refresh_window()</send>
</alias>
<alias
   match="window_on"
   enabled="y"
   group="hp_mini_window"
   send_to="12"
   sequence="100"
>
<send>draw_window()</send>
</alias>
<alias
   match="window_off"
   enabled="y"
   group="hp_mini_window"
   send_to="12"
   sequence="100"
>
<send>close_window()</send>
</alias>
</aliases>

<!--Script-->


<script>
<![CDATA[
--   Script language="Lua"
-- -- -- -- -- -- -- --
-- configuration
-- window size in pixels
WINDOW_WIDTH = 360
WINDOW_HEIGHT = 170
-- font
FONT_NAME1 = "Arial"
FONT_NAME2 = "Webdings"
FONT_NAME3 = "Lucida Console"
FONT_SIZE_11 = 11
FONT_SIZE_12 = 12
-- size of border stroke
EDGE_WIDTH = 3 -- size of border stroke
-- where to put the window
WINDOW_POSITION = 6-- see below (6 is top right)
--[[
Useful positions:
4 = top left
5 = center left-right at top
6 = top right
7 = on right, center top-bottom
8 = on right, at bottom
9 = center left-right at bottom
--]]

-- colours
WINDOW_BACKGROUND_COLOUR = ColourNameToRGB ("darkgray")
BOX_COLOUR = ColourNameToRGB ("royalblue") -- Box boarder's colour
WINDOW_TEXT_COLOUR = ColourNameToRGB ("black")
-- offset of text from edge
TEXT_INSET = 5
-- get a unique name
win = GetPluginID ()-- get a unique name
-- end configuration

-- draw the window here
function draw_window (name)
-- Create the window
WindowCreate (win, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_POSITION, 0, WINDOW_BACKGROUND_COLOUR)-- create window
               
-- define the fonts
WindowFont (win, "f1", FONT_NAME1, FONT_SIZE_12)
WindowFont (win, "f2", FONT_NAME2, FONT_SIZE_11)
WindowFont (win, "f3", FONT_NAME1, FONT_SIZE_12, true)
WindowFont (win, "f4", FONT_NAME3, FONT_SIZE_11, true)
-- work out how high the font is
font_height = WindowFontInfo (win, "f1", 1)   -- height of the font
-- draw the border of the whole box
WindowCircleOp (win, 2, 0, 0, 0, 0, BOX_COLOUR, 6, EDGE_WIDTH, 0x000000, 1)
-- get variables from triggers
local jing = GetTriggerWildcard ("statgin", "jing")
local max_jing = GetTriggerWildcard ("statgin", "max_jing")
local jingli = GetTriggerWildcard ("statsen", "jingli")
local max_jingli = GetTriggerWildcard ("statsen", "max_jingli")

local qi = GetTriggerWildcard ("statkee", "qi")
local max_qi = GetTriggerWildcard ("statkee", "max_qi")

local neili = GetTriggerWildcard ("statforce", "neili")
local max_neili = GetTriggerWildcard ("statforce", "max_neili")

local shiwu = GetTriggerWildcard ("statatman", "shiwu")
local max_shiwu = GetTriggerWildcard ("statatman", "max_shiwu")
   
local yinshui = GetTriggerWildcard ("statmana", "yinshui")
local max_yinshui = GetTriggerWildcard ("statmana", "max_yinshui")



local pot = GetTriggerWildcard ("hp", "pot")
local exp = GetTriggerWildcard ("hp", "exp")

-- draw the Text
draw_line(1, "绮剧?: ", jing, max_jing, "mediumblue", "maroon","mediumblue")
draw_line(2, "绮惧姏: ", jingli, max_jingli, "mediumorchid", "maroon", "purple")
draw_line(3, "姘旇?: ", qi, max_qi, "darkgreen", "maroon", "darkgreen")
draw_line(4, "鍐呭姏: ", neili, max_neili, "gold", "maroon", "darkorange")
draw_line(5, "椋熺墿: ", shiwu, max_shiwu, "steelblue", "maroon", "steelblue")
draw_line(6, "楗?按: ", yinshui, max_yinshui, "steelblue", "maroon", "steelblue")
draw_num(7, "娼滆兘: ", pot, "yellow")
draw_num(8, "缁忛獙: ", exp, "green")
-- end draw the Text
-- ensure window visible
WindowShow (win, true)
end -- draw_window

function draw_line (iLine, sPrompt, iCurrent, iMax, sGoodColour, sBadColour, sOverColour)

-- draw the Text
local left1 = EDGE_WIDTH + 4
local left2 = left1 + 40
local left3 = left2 + 185

local top = (EDGE_WIDTH + 3) + (font_height+2)*(iLine-1)

local text_colour = WINDOW_TEXT_COLOUR

local text1 = sPrompt
WindowText (win, "f1", text1, left1, top, 0, 0, text_colour, true)
-- adjust different font height in one line
local top1 = top - 1

--draw the background colour of the bar
local back_colour =ColourNameToRGB("dimgray")
WindowText (win, "f2", "gggggggggggg", left2, top1, 0, 0, back_colour, true)

if iCurrent == "" or iMax == "" then
iCurrent = 0
iMax = 0
end -- if
percent = math.floor(iCurrent/(iMax/12))

--Below 25% warn by using different colour, or above 100% using another different colour
if percent < 3 then
active_colour= ColourNameToRGB(sBadColour)
elseif percent > 12 then
percent = 12
   active_colour = ColourNameToRGB(sOverColour)
else
   active_colour = ColourNameToRGB(sGoodColour)
end -- if
--Draw active part of gauge
for count = 0,percent do
   if count == 0 then
    bar = ""
   else
    bar = bar.. "g"
end -- if
end -- for

if bar == nil then
   bar = ""
end -- if

WindowText (win, "f2", bar, left2, top1, 0, 0, active_colour, true)
local text3 = iCurrent.. "/".. iMax
WindowText (win, "f3", text3, left3, top, 0, 0, active_colour, true)
-- end draw the Text Line

end -- draw line

-- draw number
function draw_num (iLine, sPrompt, iNumber, sColour)

local left1 = EDGE_WIDTH + 4
local left2 = left1 + 40
local top = (EDGE_WIDTH + 3) + (font_height+2)*(iLine-1)
local text_colour = WINDOW_TEXT_COLOUR
local text1 = sPrompt
WindowText (win, "f1", text1, left1, top, 0, 0, text_colour, true)

local active_colour = ColourNameToRGB (sColour)
local top1 = top + 3
local text2 = iNumber
WindowText (win, "f4", text2, left2, top1, 0, 0, active_colour, true)
end -- end draw number

-- hide window on close
function close_window ()
local win_visible = WindowInfo (win, 6) --> get is it hidden now.

if win_visible == false then
   WindowShow (win,false)-- hide it
   Note ("The mini Window closed now.")
end -- if

end -- close window

-- refresh window
function refresh_window ()
local win_visible = WindowInfo (win, 6) --> get is it hidden now.

if win_visible == false then
    WindowShow (win,false)-- hide it
    Note ("The mini Window closed now.")
   DoAfterSpecial (0.1, 'draw_window()', 12)
    DoAfterNote (0.2, "The mini window refreshed now.")
   else
    DoAfterSpecial (0.1, 'draw_window()', 12)
    DoAfterNote (0.2, "The mini window refreshed now.")
   end -- if
end -- refresh window

]]>
</script>


<!--Plugin help-->

<aliases>
<alias
   script="OnHelp"
   match="HP_mini_Window:help"
   enabled="y"
>
</alias>
</aliases>

<script>
<![CDATA[
function OnHelp ()
world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script>

</muclient>

chans 发表于 2010-7-23 22:59:30

这个是别人做的hp显示miniwindwos的程序。我在移植到其他mud上.但是不成功

chans 发表于 2010-7-23 23:03:28

下面这个是触发条件

fystatus:kee:9273/9273/9273;gin:5590/5590/5590;sen:5396/5396/5396
fystatus:force:2950/1475;mana:630/315;atman:824/412
上面是合并在一起的。不过也会分开来出现,显示如下。可以做一个正则全部包括这些情况不?还是要分2+6这么多情况触发?

fystatus:kee:9273/9273/9273
fystatus:gin:5590/5590/5590
fystatus:sen:5396/5396/5396
fystatus:force:2950/1475
fystatus:mana:630/315
fystatus:atman:824/412

还有,不是一下子就出这么多行,有时候1行,有时候2行,有时候3行。这个可以做得到一个表达式全部包括不?

chans 发表于 2010-7-23 23:26:51

找到哪里怎么出错了。但是不知道为什么
如果触发哪里。只触发一次。就没问题。如果向我一样。做了超过1个
tr
tr

那就会报错。直接关闭

chans 发表于 2010-7-23 23:27:22

哪位高手。帮我看看。怎么解决。
要买则个正则可以全部情况包括,要不就要可以触发多几次

dinglf 发表于 2010-7-24 10:06:58

zmud4.62的飘过

killunix 发表于 2010-7-24 10:48:35

楼主老兄,看你最近发了不少关于mush的帖子,其实这些问题都很简单,我建议你好好看看教程和论坛的mush机器或者mush的官网,其实都有写,好好看看,从最基本的来吧。言语不妥之处,敬请谅解。

lzkd 发表于 2010-7-24 11:15:13

同意killunix的观点,给我感觉,楼主太急了,老是要一口吃成个胖子,或者一下子找到合适用的代码.哪里可能有这么容易的事情.任何复杂的功能,都是从无数个细小功能搭起来的.

如果基础的东西不打好,就算是代码跑出来了,你想修改或者增加功能,也会无处下手的.

chans 发表于 2010-7-24 11:35:09

已经解决。感谢各位关注
页: [1]
查看完整版本: mush高手看看。插件一加载触发,就读写错误。