搜索
LUA

LUA

本版块未设置版块简介!请后台版块编辑添加。
  •  帖子: 115
  •  讨论: 115
  •  关注: 0

lua_npc.lua--佣兵水晶贩卖商人

GP 发表于 2025-5-10 03:15:40 | 显示全部楼层 |阅读模式
136 0
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

回复

使用道具 举报

全部评论

暂无评论,期待您打破宁静

TA的帖子
相关帖子
  • admin 2025-5-11

    Event 万能传送 0 2 0 1 1 0 1000 242 88 242 88 242 88 242 88 1 0 0 104330 0 1 0 C ...

  • admin 2025-5-11

    魔力宝贝手动架设中遇到的问题及解决方法魔力宝贝手动架设教程—魔力私服,魔力宝贝私 ...

  • admin 2025-5-12

    维诺亚村开拓于河川西边,拥有大自然气息的村庄 地图 抵达方法 由法兰城南门出发, ...

  • admin 2025-5-12

    起始地点法兰城的竞技场的贝贝(34.36)头目战╳ 必要条件---必要等级Lv1 职业限定---建 ...

  • admin 2025-5-12

    1.与里谢里雅堡的H1N1防疫宣传员(28,77)说话,取得"防疫小口罩"。 图例物品名称等级种 ...

  • admin 2025-5-12

    魅惑的哈密瓜无取得宠物「哈密瓜公主」╳╳○ 起始地点魔法大学头目战╳ 必要条件--- ...

  • admin 2025-5-12

    起始地点法兰城的里谢里雅堡头目战○ 必要条件---必要等级--- 职业限定---建议等级--- ...

  • admin 2025-5-12

    起始地点法兰城的里谢里雅堡头目战○ 必要条件---必要等级--- 职业限定---建议等级--- ...

  • admin 2025-5-12

    起始地点法兰城的冒险者旅馆头目战○ 必要条件---必要等级--- 职业限定---建议等级LV8 ...

  • admin 2025-5-12

    1.到法兰城竞技场(122,161),往左走到休息室(2,15),在白天时与迷宫入口管理员(2,2)说 ...

发布 联系QQ