|
论坛好像有教怎么改出这样的菜单,但我记得是dos下的,不是lua版
所以我练习完顺便发上来了,如果回锅了就无视吧
呵呵~
代码是在JYModify.lua里面的,具体在附件中,直接复制可用
附件还整合了我今天早上发布的队友相互吃药系统~
如果不想花银子的,看代码如下:
function SetModify()
SelectThing=SelectThing_new; --强化菜单
Menu_Thing_old=Menu_Thing; --备份
Menu_Thing=Menu_Thing_new; --仿苍龙菜单
end
--强化物品菜单,仿苍龙逐日
function Menu_Thing_new() --物品菜单
local menu={ {"全部物品",Menu_Thing_old,1},
{"剧情物品",Menu_type0,1},
{"神兵宝甲",Menu_type1,1},
{"武功秘笈",Menu_type2,1},
{"灵丹妙药",Menu_type3,1},
{"伤人暗器",Menu_type4,1} };
local r=ShowMenu(menu,6,0,80,10,0,0,1,1,24,C_ORANGE, C_WHITE);
if r == 0 then
Cls(80,10,CC.ScreenW,CC.ScreenH);
return 0;
elseif r<0 then --要退出全部菜单,
Cls();
return 1;
end
end
function Menu_type0()
local thing={};
local thingnum={};
local num=0;
for i = 0,CC.MyThingNum-1 do
thing[i]=-1;
thingnum[i]=0;
end
for i = 0,CC.MyThingNum-1 do
local id=JY.Base["物品" .. i+1];
if id>=0 then
if JY.Thing[id]["类型"]==0 then
thing[num]=id;
thingnum[num]=JY.Base["物品数量" ..i+1];
num=num+1;
end
end
end
local rr=SelectThing(thing,thingnum);
if rr>=0 then
if UseThing(rr)==1 then --使用物品
return 1;
else
return 0;
end
else
return 0;
end
end
function Menu_type1()
local thing={};
local thingnum={};
local num=0;
for i = 0,CC.MyThingNum-1 do
thing[i]=-1;
thingnum[i]=0;
end
for i = 0,CC.MyThingNum-1 do
local id=JY.Base["物品" .. i+1];
if id>=0 then
if JY.Thing[id]["类型"]==1 then
thing[num]=id;
thingnum[num]=JY.Base["物品数量" ..i+1];
num=num+1;
end
end
end
local rr=SelectThing(thing,thingnum);
if rr>=0 then
if UseThing(rr)==1 then --使用物品
return 1;
else
return 0;
end
else
return 0;
end
end
function Menu_type2()
local thing={};
local thingnum={};
local num=0;
for i = 0,CC.MyThingNum-1 do
thing[i]=-1;
thingnum[i]=0;
end
for i = 0,CC.MyThingNum-1 do
local id=JY.Base["物品" .. i+1];
if id>=0 then
if JY.Thing[id]["类型"]==2 then
thing[num]=id;
thingnum[num]=JY.Base["物品数量" ..i+1];
num=num+1;
end
end
end
local rr=SelectThing(thing,thingnum);
if rr>=0 then
if UseThing(rr)==1 then --使用物品
return 1;
else
return 0;
end
else
return 0;
end
end
function Menu_type3()
local thing={};
local thingnum={};
local num=0;
for i = 0,CC.MyThingNum-1 do
thing[i]=-1;
thingnum[i]=0;
end
for i = 0,CC.MyThingNum-1 do
local id=JY.Base["物品" .. i+1];
if id>=0 then
if JY.Thing[id]["类型"]==3 then
thing[num]=id;
thingnum[num]=JY.Base["物品数量" ..i+1];
num=num+1;
end
end
end
local rr=SelectThing(thing,thingnum);
if rr>=0 then
if UseThing(rr)==1 then --使用物品
return 1;
else
return 0;
end
else
return 0;
end
end
function Menu_type4()
local thing={};
local thingnum={};
local num=0;
for i = 0,CC.MyThingNum-1 do
thing[i]=-1;
thingnum[i]=0;
end
for i = 0,CC.MyThingNum-1 do
local id=JY.Base["物品" .. i+1];
if id>=0 then
if JY.Thing[id]["类型"]==4 then
thing[num]=id;
thingnum[num]=JY.Base["物品数量" ..i+1];
num=num+1;
end
end
end
local rr=SelectThing(thing,thingnum);
if rr>=0 then
if UseThing(rr)==1 then --使用物品
return 1;
else
return 0;
end
else
return 0;
end
end
--显示物品菜单
--返回选择的物品编号, -1表示没有选择
function SelectThing_new(thing,thingnum) --显示物品供选择
local xnum,ynum=8,5;
local dx,dy=90,20;
local w,h=60,60;
local cur_line=0;
local cur_x=0;
local cur_y=0;
local cur_thing=-1;
while true do
Cls(80,10,CC.ScreenW,CC.ScreenH);
for y=0,ynum-1 do
for x=0,xnum-1 do
local id=y*xnum+x+xnum*cur_line ; --当前待选择物品
if x==cur_x and y==cur_y then
lib.Background(dx-10,dy,dx+(xnum)*w-10,dy+30,128);
lib.DrawRect(dx-10,dy,dx+(xnum)*w-10,dy+30,C_WHITE);
if thing[id]>=0 then
cur_thing=thing[id];
local str=JY.Thing[thing[id]]["名称"];
if JY.Thing[thing[id]]["类型"]==1 or JY.Thing[thing[id]]["类型"]==2 then
if JY.Thing[thing[id]]["使用人"] >=0 then
str=str .. "(" .. JY.Person[JY.Thing[thing[id]]["使用人"]]["姓名"] .. ")";
end
end
str=str .. " X " .. tostring(thingnum[id]) .. ": " .. JY.Thing[thing[id]]["物品说明"];
DrawString(dx-10+5,dy+5,str,C_GOLD,16);
local str2="";
str2=str2 .. get_thing_detail1(cur_thing);
DrawString(dx,dy+(ynum)*h+50,str2,C_GOLD,16);
local str3="";
str3=str3 .. get_thing_detail2(cur_thing);
DrawString(dx,dy+(ynum)*h+70,str3,C_GOLD,16);
else
cur_thing=-1;
end
lib.Background(dx+x*w-10,dy+y*h+30,dx+(x+1)*w-10,dy+(y+1)*h+30,64);
lib.DrawRect(dx+x*w-1,dy+y*h+40-1,dx+(x)*w+40,dy+(y)*h+80,C_WHITE);
else
lib.Background(dx+x*w-10,dy+y*h+30,dx+(x+1)*w-10,dy+(y+1)*h+30,192);
end
lib.DrawRect(dx+x*w-10,dy+y*h+30,dx+(x+1)*w-10,dy+(y+1)*h+30,C_WHITE);
if thing[id]>=0 then
lib.PicLoadCache(2,thing[id]*2,dx+x*w,dy+y*h+40,1,1);
end
end
end
lib.Background(dx-10,dy+(ynum)*h+40,dx+(xnum)*w-10,dy+(ynum)*h+130,192);
lib.DrawRect(dx-10,dy+(ynum)*h+40,dx+(xnum)*w-10,dy+(ynum)*h+130,C_WHITE);
ShowScreen();
local keypress=WaitKey();
lib.Delay(100);
if keypress==VK_ESCAPE then
cur_thing=-1;
break;
elseif keypress==VK_RETURN or keypress==VK_SPACE then
break;
elseif keypress==VK_UP then
if cur_y == 0 then
if cur_line > 0 then
cur_line = cur_line - 1;
end
else
cur_y = cur_y - 1;
end
elseif keypress==VK_DOWN then
if cur_y ==ynum-1 then
if cur_line < (math.modf(200/xnum)-ynum) then
cur_line = cur_line + 1;
end
else
cur_y = cur_y + 1;
end
elseif keypress==VK_LEFT then
if cur_x > 0 then
cur_x=cur_x-1;
else
cur_x=xnum-1;
end
elseif keypress==VK_RIGHT then
if cur_x ==xnum-1 then
cur_x=0;
else
cur_x=cur_x+1;
end
end
end
Cls(80,10,CC.ScreenW,CC.ScreenH);
ShowScreen();
return cur_thing;
end
function get_thing_detail1(thingid)
local str="";
if JY.Thing[thingid]["类型"]==0 then
str="剧情物品";
elseif JY.Thing[thingid]["类型"]>0 then
str=get_thing_detail_type1(thingid);
else
return 0;
end
return str;
end
function get_thing_detail_type1(thingid)
local str="";
if JY.Thing[thingid]["类型"]==1 then
if JY.Thing[thingid]["加攻击力"]>0 then
str=str .. "攻击 + " .. JY.Thing[thingid]["加攻击力"] .. " ";
end
if JY.Thing[thingid]["加防御力"]>0 then
str=str .. "防御 + " .. JY.Thing[thingid]["加防御力"] .. " ";
end
if JY.Thing[thingid]["加轻功"]>0 then
str=str .. "轻功 + " .. JY.Thing[thingid]["加轻功"] .. " ";
end
if JY.Thing[thingid]["加攻击带毒"]>0 then
str=str .. "带毒 + " .. JY.Thing[thingid]["加攻击带毒"] .. " ";
end
elseif JY.Thing[thingid]["类型"]==2 then
if JY.Thing[thingid]["改变内力性质"]==2 then
str=str .. "阴阳调和" .. " ";
end
if JY.Thing[thingid]["加攻击力"]>0 then
str=str .. "攻击 + " .. JY.Thing[thingid]["加攻击力"] .. " ";
end
if JY.Thing[thingid]["加防御力"]>0 then
str=str .. "防御 + " .. JY.Thing[thingid]["加防御力"] .. " ";
end
if JY.Thing[thingid]["加轻功"]>0 then
str=str .. "轻功 + " .. JY.Thing[thingid]["加轻功"] .. " ";
end
if JY.Thing[thingid]["加攻击带毒"]>0 then
str=str .. "带毒 + " .. JY.Thing[thingid]["加攻击带毒"] .. " ";
end
if JY.Thing[thingid]["加生命最大值"]>0 then
str=str .. "最大生命 + " .. JY.Thing[thingid]["加生命最大值"] .. " ";
end
if JY.Thing[thingid]["加内力最大值"]>0 then
str=str .. "最大内力 + " .. JY.Thing[thingid]["加内力最大值"] .. " ";
end
if JY.Thing[thingid]["加医疗能力"]>0 then
str=str .. "医疗 + " .. JY.Thing[thingid]["加医疗能力"] .. " ";
end
if JY.Thing[thingid]["加用毒能力"]>0 then
str=str .. "用毒 + " .. JY.Thing[thingid]["加用毒能力"] .. " ";
end
if JY.Thing[thingid]["加解毒能力"]>0 then
str=str .. "解毒 + " .. JY.Thing[thingid]["加解毒能力"] .. " ";
end
if JY.Thing[thingid]["加抗毒能力"]>0 then
str=str .. "抗毒 + " .. JY.Thing[thingid]["加抗毒能力"] .. " ";
end
if JY.Thing[thingid]["加拳掌功夫"]>0 then
str=str .. "拳掌 + " .. JY.Thing[thingid]["加拳掌功夫"] .. " ";
end
if JY.Thing[thingid]["加御剑能力"]>0 then
str=str .. "御剑 + " .. JY.Thing[thingid]["加御剑能力"] .. " ";
end
if JY.Thing[thingid]["加耍刀技巧"]>0 then
str=str .. "耍刀 + " .. JY.Thing[thingid]["加耍刀技巧"] .. " ";
end
if JY.Thing[thingid]["加特殊兵器"]>0 then
str=str .. "特殊 + " .. JY.Thing[thingid]["加特殊兵器"] .. " ";
end
if JY.Thing[thingid]["加暗器技巧"]>0 then
str=str .. "暗器 + " .. JY.Thing[thingid]["加暗器技巧"] .. " ";
end
if JY.Thing[thingid]["加武学常识"]>0 then
str=str .. "武学常识 + " .. JY.Thing[thingid]["加武学常识"] .. " ";
end
elseif JY.Thing[thingid]["类型"]==3 then
if JY.Thing[thingid]["加生命"]>0 then
str=str .. "生命 + " .. JY.Thing[thingid]["加生命"] .. " ";
end
if JY.Thing[thingid]["加生命最大值"]>0 then
str=str .. "最大生命 + " .. JY.Thing[thingid]["加生命最大值"] .. " ";
end
if JY.Thing[thingid]["加内力"]>0 then
str=str .. "内力 + " .. JY.Thing[thingid]["加内力"] .. " ";
end
if JY.Thing[thingid]["加内力最大值"]>0 then
str=str .. "最大内力 + " .. JY.Thing[thingid]["加内力最大值"] .. " ";
end
if JY.Thing[thingid]["加中毒解毒"]<0 then
str=str .. "解毒 + " .. -JY.Thing[thingid]["加中毒解毒"] .. " ";
end
if JY.Thing[thingid]["加体力"]>0 then
str=str .. "体力 + " .. JY.Thing[thingid]["加体力"] .. " ";
end
if JY.Thing[thingid]["加抗毒能力"]>0 then
str=str .. "抗毒 + " .. JY.Thing[thingid]["加抗毒能力"] .. " ";
end
if JY.Thing[thingid]["加武学常识"]>0 then
str=str .. "武学常识 + " .. JY.Thing[thingid]["加武学常识"] .. " ";
end
elseif JY.Thing[thingid]["类型"]==4 then
if JY.Thing[thingid]["加生命"]<0 then
str=str .. "杀伤力: " .. -JY.Thing[thingid]["加生命"] .. " ";
end
if JY.Thing[thingid]["加中毒解毒"]>0 then
str=str .. "带毒: " .. JY.Thing[thingid]["加中毒解毒"] .. " ";
end
else
return 0;
end
return str;
end
function get_thing_detail2(thingid)
local str="";
if JY.Thing[thingid]["需内力"]>0 then
str=str .. "内力需求:" .. JY.Thing[thingid]["需内力"] .. " ";
end
if JY.Thing[thingid]["需攻击力"]>0 then
str=str .. "攻击需求:" .. JY.Thing[thingid]["需攻击力"] .. " ";
end
if JY.Thing[thingid]["需轻功"]>0 then
str=str .. "轻功需求:" .. JY.Thing[thingid]["需轻功"] .. " ";
end
if JY.Thing[thingid]["需用毒能力"]>0 then
str=str .. "用毒需求:" .. JY.Thing[thingid]["需用毒能力"] .. " ";
end
if JY.Thing[thingid]["需医疗能力"]>0 then
str=str .. "医疗需求:" .. JY.Thing[thingid]["需医疗能力"] .. " ";
end
if JY.Thing[thingid]["需解毒能力"]>0 then
str=str .. "解毒需求:" .. JY.Thing[thingid]["需解毒能力"] .. " ";
end
if JY.Thing[thingid]["需拳掌功夫"]>0 then
str=str .. "拳掌需求:" .. JY.Thing[thingid]["需拳掌功夫"] .. " ";
end
if JY.Thing[thingid]["需御剑能力"]>0 then
str=str .. "御剑需求:" .. JY.Thing[thingid]["需御剑能力"] .. " ";
end
if JY.Thing[thingid]["需耍刀技巧"]>0 then
str=str .. "耍刀需求:" .. JY.Thing[thingid]["需耍刀技巧"] .. " ";
end
if JY.Thing[thingid]["需特殊兵器"]>0 then
str=str .. "特殊需求:" .. JY.Thing[thingid]["需特殊兵器"] .. " ";
end
if JY.Thing[thingid]["需暗器技巧"]>0 then
str=str .. "暗器需求:" .. JY.Thing[thingid]["需暗器技巧"] .. " ";
end
if JY.Thing[thingid]["需资质"]>0 then
str=str .. "资质需求:" .. JY.Thing[thingid]["需资质"] .. " ";
end
if JY.Thing[thingid]["需经验"]>0 then
str=str .. "经验需求:" .. JY.Thing[thingid]["需经验"] .. " ";
end
return str;
end
好长~~~~~~~~~~~~但其实东西不多,欢迎指正~
[table=100%,#cbb48a][tr][td][size=9pt][发帖际遇]: [url=http://www.txdx.net/event.php]winson7891暑假期间在洛阳绿竹巷参加《任盈盈琴箫兴趣班》,恭喜你学会了《笑傲江湖》,增加声望13。
[/url][/font][/td][/tr][/table]
[[i] 本帖最后由 weyl 于 2009-3-23 23:20 编辑 [/i]] |
评分
-
查看全部评分
|