Global_Reg.RegInit("lua_npc_Init");
local crystal_info = crystal_info or {}
crystal_info[1]={}--1代表_Seqno编号
crystal_info[1][0]={512009,600}--0代表返回的_Data的前一个字符串的栏位→栏位|数量
crystal_info[1][1]={512018,600}
crystal_info[1][2]={512027,600}
crystal_info[1][3]={512036,600}
crystal_info[2]={}
crystal_info[2][0]={512008,800}
crystal_info[2][1]={512010,800}
crystal_info[2][2]={512017,800}
crystal_info[2][3]={512019,800}
crystal_info[2][4]={512026,800}
crystal_info[2][5]={512028,800}
crystal_info[2][6]={512035,800}
crystal_info[2][7]={512037,800}
crystal_info[3]={}
crystal_info[3][0]={512007,1000}
crystal_info[3][1]={512011,1000}
crystal_info[3][2]={512016,1000}
crystal_info[3][3]={512020,1000}
crystal_info[3][4]={512025,1000}
crystal_info[3][5]={512029,1000}
crystal_info[3][6]={512034,1000}
crystal_info[3][7]={512038,1000}
function lua_npc_Init()
lua_npc_InitA();
return 0;
end
function lua_npc_InitA(npc)
if npc == nil or npc < 0 then
npc = NL.CreateNpc(nil,"lua_npc_InitB")
end
Char.SetData(npc,%对象_形象%,100058)
Char.SetData(npc,%对象_原形%,100058)
Char.SetData(npc,%对象_地图%,777)
Char.SetData(npc,%对象_X%,35)
Char.SetData(npc,%对象_Y%,37)
Char.SetData(npc,%对象_方向%,4)
Char.SetData(npc,%对象_原名%,"伙伴水晶商人")
LuaNpcIndex["lua_npc_Init"]=npc;
InstallNpc("lua_npc_Init",npc);
Char.SetWindowTalkedEvent(nil,"lua_npcWindowCallBack",npc)
NLG.UpChar(npc)
return true
end
function lua_npc_InitB(index)
return true;
end
function lua_npcWindowCallBack(npc,player,_Seqno,_Select,_Data)
--print("\n _Seqno是:"..(_Seqno or "空").."它的类型是"..type(_Seqno).."\n _Select是:".. (_Select or "空").."它的类型是"..type(_Select).."\n _Data是:"..(_Data or "空").."它的类型是"..type(_Data))
if _Select~=2 then
if _Seqno==0 then
if _Data=="1" then
local msg = "14502|水晶商人拜伦|您需要买什么呢?|\n你的钱不够!|您的道具栏放不下了\n\n请检查$4当页背包$0是否有足够空位"..lua_itemshop_msg(512009,600)..lua_itemshop_msg(512018,600)..lua_itemshop_msg(512027,600)..lua_itemshop_msg(512036,600)
NLG.ShowWindowTalked(player,6,2,1,msg,npc)
elseif _Data=="2" then
local msg = "14502|水晶商人拜伦|您需要买什么呢?|\n你的钱不够!|您的道具栏放不下了\n\n请检查$4当页背包$0是否有足够空位"..lua_itemshop_msg(512008,800)..lua_itemshop_msg(512010,800)..lua_itemshop_msg(512017,800)..lua_itemshop_msg(512019,800)..lua_itemshop_msg(512026,800)..lua_itemshop_msg(512028,800)..lua_itemshop_msg(512035,800)..lua_itemshop_msg(512037,800)
NLG.ShowWindowTalked(player,6,2,2,msg,npc)
elseif _Data=="3" then
local msg = "14502|水晶商人拜伦|您需要买什么呢?|\n你的钱不够!|您的道具栏放不下了\n\n请检查$4当页背包$0是否有足够空位"..lua_itemshop_msg(512007,1000)..lua_itemshop_msg(512011,1000)..lua_itemshop_msg(512016,1000)..lua_itemshop_msg(512020,1000)..lua_itemshop_msg(512025,1000)..lua_itemshop_msg(512029,1000)..lua_itemshop_msg(512034,1000)..lua_itemshop_msg(512038,1000)
NLG.ShowWindowTalked(player,6,2,3,msg,npc)
end
elseif _Seqno>0 and _Seqno<4 then
local playergold = Char.GetData(player,53)
local newinfo = Split(_Data,"|")
local lanwei = tonumber(newinfo[1])
local shuliang = tonumber(newinfo[2])
local itemid = crystal_info[_Seqno][lanwei][1]
local cost = crystal_info[_Seqno][lanwei][2]*shuliang
if playergold>=cost then
NLG.GiveItem(player,itemid,shuliang);
local gold = NLG.AddGold(player, -cost);
else
NLG.SystemMessage(player,"你的钱不够了")
end
end
end
end
function lua_itemshop_msg(itemid,gold)
if gold==nil then
gold=1
end
local msg = "|"
local iteminfo = Item.MakeItemStatusDateString(itemid)
local newinfo = Split(iteminfo,"|")
local name = newinfo[1]
local itemmsg = newinfo[3]
itemmsg = string.gsub(itemmsg,"\\S"," ")
itemmsg = string.gsub(itemmsg,"\\\\","\\")
local img = newinfo[4]
msg = msg..name.."|"..img.."|"..gold.."|"..itemmsg.."|1|1"
return msg
end
|
|