ddid 发表于 2009-12-28 23:40:47

do_prompt的脚本呢?一并发上来看看吧。

vase 发表于 2009-12-29 00:03:31

那個哦..function do_prompt (name, line, wildcards)

local hpString = wildcards ;
local hp , max_hp = tonumber (wildcards ), tonumber (wildcards )
local ginString = wildcards ;
local gin , max_gin = tonumber (wildcards ), tonumber (wildcards )
local keeString = wildcards ;
local kee , max_kee = tonumber (wildcards ), tonumber (wildcards )
local senString = wildcards ;
local sen , max_sen = tonumber (wildcards ), tonumber (wildcards )
local foodString = wildcards ;
local food , max_food = tonumber (wildcards ), tonumber (wildcards )
local waterString = wildcards ;
local water , max_water = tonumber (wildcards ), tonumber (wildcards )
local tireString = wildcards ;
local tire , max_tire = tonumber (wildcards ), tonumber (wildcards )

if max_kee == 0 then max_kee = 9999999 end
local hp_th = tonumber (GetVariable ("hp_threshold"))
local gin_th = tonumber (GetVariable("gin_threshold"))
local kee_th = tonumber (GetVariable("kee_threshold"))
local sen_th = tonumber (GetVariable("sen_threshold"))

--Note(hp_th .. " " .. gin_th .. " " .. kee_th .. " " .. sen_th)

if hp_th == nil then hp_th = max_hp end
if gin_th == nil then gin_th = max_gin end
if kee_th == nil then kee_th = max_kee end
if sen_th == nil then sen_th = max_sen end

local hp_percent = hp / hp_th
local hp_max_percent = max_hp / hp_th
local gin_percent = gin / gin_th
local gin_max_percent = max_gin / gin_th
local kee_percent = kee / kee_th
local kee_max_percent = max_kee / kee_th
local sen_percent = sen / sen_th
local sen_max_percent = max_sen / sen_th
local food_percent = food / max_food
if max_food == 0 then food_percent = 1 end
local water_percent = water / max_water
local tire_percent = tire / 100



-- fill entire box to clear it
check (WindowRectOp (win, 2, 0, 0, 0, 0, BACKGROUND_COLOUR))-- fill entire box

-- Edge around box rectangle
check (WindowCircleOp (win, 3, 0, 0, 0, 0, BORDER_COLOUR, 0, 2, 0, 1))

vertical = 0-- pixel to start at

DoGauge (string.format("%s%12s",hpString .. ": " , "<" .. hp .. "/ " .. max_hp .. ">") , hp_percent, hp_max_percent,HP_COLOUR ,HP_COLOUR2)
DoGauge (string.format("%s%12s",ginString..": " , "<" .. gin .. "/ " .. max_gin.. ">") , gin_percent ,gin_max_percent, GIN_COLOUR , GIN_COLOUR2)
DoGauge (string.format("%s%12s",keeString..": " , "<" .. kee .. "/ " .. max_kee.. ">") , kee_percent ,kee_max_percent, KEE_COLOUR, KEE_COLOUR2)
DoGauge (string.format("%s%12s",senString..": " , "<" .. sen .. "/ " .. max_sen.. ">") , sen_percent ,sen_max_percent, SEN_COLOUR,SEN_COLOUR2)
DoGauge (string.format("%s%12s",foodString..": " , "<" .. food .. "/ " .. max_food.. ">") , food_percent ,1, FOOD_COLOUR, FOOD_COLOUR2)
DoGauge (string.format("%s%12s",waterString..": " , "<" .. water .. "/ " .. max_water.. ">") , water_percent ,1, WATER_COLOUR, WATER_COLOUR2)
DoGauge (string.format("%s%12s",tireString..": " , "<" .. tire .. "/ 100>") , tire_percent ,1, TIRE_COLOUR , TIRE_COLOUR2)

WindowShow (win, true)

end -- draw_bar其實我不會用Lua. 這些全是改自Nick 在4.40 裏的.. 我連function 名字都沒改.ttk_13

[ 本帖最后由 vase 于 2009-12-29 12:04 AM 编辑 ]

vase 发表于 2009-12-29 00:07:41

local hp_th = tonumber (GetVariable ("hp_threshold"))
local gin_th = tonumber (GetVariable("gin_threshold"))
local kee_th = tonumber (GetVariable("kee_threshold"))
local sen_th = tonumber (GetVariable("sen_threshold"))

這幾個值是按score 時觸發得到的..

北俠裏應該也一樣..

ddid 发表于 2009-12-29 00:18:22

oh

呵呵,还以为是perl的……

这样子的话,写在脚本里应该不会有什么问题,不过导出成插件好像就不行了,不过这个没有真正测试过,还不能完全确定。

[ 本帖最后由 ddid 于 2009-12-29 12:21 AM 编辑 ]

vase 发表于 2009-12-29 00:23:51

我這個是插件版的 ttk_05

這樣弄沒有問題

vase 发表于 2009-12-29 00:30:23

呵呵. 我只有這一個插件是lua 版的..

其它的全是perl 版的了.

因為全是自己寫的.. 用起來比較爽ttk_12

ddid 发表于 2009-12-29 00:42:29

对perl呢,我是门外汉,一无所知,只是好奇,想看看;

对lua呢,基本上是现学现用,学到那算哪,也算不上精通……

对这个LUA的脚本,有点奇怪,DoGauge()是怎么实现的?

vase 发表于 2009-12-29 00:48:23

function DoGauge (sPrompt, Percent, Percent2 , Colour, Colour2)
local Fraction = tonumber (Percent)
local Fraction2 = tonumber (Percent2)

if Fraction > 1 then Fraction = 1 end
if Fraction < 0 then Fraction = 0 end
if Fraction2 > 1 then Fraction2 = 1 end
if Fraction2 < 0 then Fraction2 = 0 end

local width = WindowTextWidth (win, font_id, sPrompt);
local orgVertical = vertical;


WindowText (win, font_id, sPrompt, GAUGE_LEFT - width, vertical, 0, 0, FONT_COLOUR)
vertical = orgVertical + (font_height - GAUGE_HEIGHT) / 2; -- adjust entire box
WindowRectOp (win, 2, GAUGE_LEFT, vertical, WINDOW_WIDTH - 5, vertical + GAUGE_HEIGHT,BACKGROUND_COLOUR)-- fill entire box

local gauge_width = (WINDOW_WIDTH - GAUGE_LEFT - 5) * Fraction
-- box size must be > 0 or WindowGradient fills the whole thing
if math.floor (gauge_width) > 0 then
    -- top half   
    WindowGradient (win, GAUGE_LEFT, vertical, GAUGE_LEFT + gauge_width,
                  vertical + GAUGE_HEIGHT / 2, 0x000000, Colour, 2)
    -- bottom half   
    WindowGradient (win, GAUGE_LEFT, vertical + GAUGE_HEIGHT / 2,
                  GAUGE_LEFT + gauge_width, vertical +GAUGE_HEIGHT, Colour, 0x000000, 2)
end -- non-zero
local gauge_width2 = (WINDOW_WIDTH - GAUGE_LEFT - 5) * Fraction2
-- box size must be > 0 or WindowGradient fills the whole thing
if math.floor (gauge_width2) > 0 then
    -- top half   
    WindowGradient (win, GAUGE_LEFT + gauge_width, vertical, GAUGE_LEFT + gauge_width2,
                  vertical + GAUGE_HEIGHT / 2, 0x000000, Colour2, 2)
    -- bottom half
    WindowGradient (win, GAUGE_LEFT + gauge_width, vertical + GAUGE_HEIGHT / 2,
                  GAUGE_LEFT + gauge_width2, vertical +GAUGE_HEIGHT, Colour2, 0x000000, 2)
end -- non-zero

-- show tickslocal ticks_at = (WINDOW_WIDTH - GAUGE_LEFT - 5) / (NUMBER_OF_TICKS + 1)
-- ticks
for i = 1, NUMBER_OF_TICKS do   
    WindowLine (win, GAUGE_LEFT + (i * ticks_at), vertical,
                GAUGE_LEFT + (i * ticks_at), vertical + GAUGE_HEIGHT, ColourNameToRGB ("silver"), 0, 1)
end -- for
-- draw a box around it
check (WindowRectOp (win, 1, GAUGE_LEFT, vertical, WINDOW_WIDTH - 5, vertical + GAUGE_HEIGHT,
         ColourNameToRGB ("lightgrey")))-- frame entire box
vertical = orgVertical + font_height + 2
end -- function

[ 本帖最后由 vase 于 2009-12-29 12:58 AM 编辑 ]

vase 发表于 2009-12-29 01:02:58

傳個完整的吧..

ddid 发表于 2009-12-29 01:05:29

WindowText (win, font_id, sPrompt, GAUGE_LEFT - width, vertical, 0, 0, FONT_COLOUR)

没有对是否使用UTF-8做设定,默认的话应该是false。
页: 1 [2] 3
查看完整版本: 根据DDID的插件改写的HP mini_windows 无法显示中文,请教DDID