lua啊lua 发表于 2020-11-18 11:14:54

龙族Lua使用问题交流贴(龙族官方lua技术镇楼)

不一定及时回复,看见就会回复
目的是为了把所有常见的问题,归纳在一起,方便遇到相同问题的其他GM解决问题

此贴仅限Lua相关主题讨论
Lua模块使用中,遇到的问题
Lua大众急需的好的功能
引擎事件触发优化,增加
等等............

94579790 发表于 2020-11-18 20:39:53

local actorList = Client.getActorList(0); -- 获取当前视野范围内的怪物列表

只能获取到尸体.

lua啊lua 发表于 2020-11-24 13:40:38

94579790 发表于 2020-11-18 20:39
local actorList = Client.getActorList(0); -- 获取当前视野范围内的怪物列表

只能获取到尸体. ...
经过测试,没有这个问题
这个是客户端的接口
返回的列表里面会存在nil值非连续,要做判断
local actorList = Client.getActorList(0); -- 获取当前视野范围内的怪物列表
      print(actorList)
      for i = 1 ,#actorList do
          local monster = actorList;
          if monster then
               print(string.format("%s 坐标为 (%d,%d).", monster.name, monster.x, monster.y))
                end
      end;

94579790 发表于 2020-11-25 09:26:42

lua啊lua 发表于 2020-11-24 13:40
经过测试,没有这个问题
这个是客户端的接口
返回的列表里面会存在nil值非连续,要做判断


大佬,应该怎么获取到啊,哪里写错了啊,不砍死不输出名字坐标呢?

lua啊lua 发表于 2020-11-25 10:01:20

94579790 发表于 2020-11-25 09:26
大佬,应该怎么获取到啊,哪里写错了啊,不砍死不输出名字坐标呢?

等修复,这个部分版本客户端可以,一般都是先有杀死怪物后,才会获取的到

lua啊lua 发表于 2020-12-21 17:03:47

lua 获取物品db,技能
function printstditems()
        local StdItems = LuaExecSQL("select * from StdItems")
        local StdItemsDB = {}
        for record in string.gmatch(StdItems,"(.-)\r\n")
        do
                StdItemsDB[#StdItemsDB+1] = string.split(record,"|")
        end
        printDebug(StdItemsDB)
end

function printmagic()
        local Magic = LuaExecSQL("select * from Magic")
        local MagicDB = {}
        for record in string.gmatch(Magic,"(.-)\r\n")
        do
                MagicDB[#MagicDB+1] = string.split(record,"|")
        end
        printDebug(MagicDB)
end

function printmonster()
        local Monster = LuaExecSQL("select * from Monster")
        local MonsterDB = {}
        for record in string.gmatch(Monster,"(.-)\r\n")
        do
                MonsterDB[#MonsterDB+1] = string.split(record,"|")
        end
        printDebug(MonsterDB)
end
db,怪物db

lua啊lua 发表于 2020-12-21 17:35:06

最终显示

lua啊lua 发表于 2020-12-24 15:05:20

lua操作传奇变量
-- 获取传奇数值变量N1的值
local n1 = GETMIRVAL("<$STR(n1)>")
n1 = n1 + 1
-- 修改N1的值比原来的大1
MOV("n1 "..n1)

lua啊lua 发表于 2021-1-29 11:57:19

-------------------------
        Itemshow.showText((" 0"):rep(20),0)
        local hintItem = Itemshow.showText((" "):rep(8).."<$Item.Name>",151,18,1)
        hintItem.setBackImage("ItemClient.Pak",25,0,-6,3,500,0,0,0,0,0,0)
        Itemshow.showText("-")
        Itemshow.showText("[首充获得=佩戴激活]",222)
        Itemshow.showText((" 0"):rep(5),0)
        Itemshow.showItemIcon(" ",255,9,0,0,1)
        Itemshow.showText("重量 <$Item.Weight>",230,10,0,50,80,-35)
--        Itemshow.showText("持久 <$Item.Dura> - <$Item.DuraMax>",230,10,0,50,80,-20)
        Itemshow.showText( ("持久 %d   - %d"):format(item.dura/1000,item.duramax/1000),230,10,0,50,80,-30)
        Itemshow.showText("[基础属性]",230)
        Itemshow.showText("攻击:    <$Item.DC> - <$Item.MaxDC>",223,10)
        Itemshow.showText("魔法:    <$Item.MC> - <$Item.MaxMC>",223,10)
        Itemshow.showText("道术:    <$Item.SC> - <$Item.MaxSC>",223,10)
        Itemshow.showText("准确:       +<$Item.MaxAC> ",223,10)
        Itemshow.showText("需要等级:    <$Item.NeedLevel> ",223,10)
        Itemshow.showText("-")
       
        -------------------------

lua啊lua 发表于 2021-1-29 11:58:50

-------------------------
        Itemshow.showText((" 0"):rep(20),0)
        local hintItem = Itemshow.showText((" "):rep(8).."<$Item.Name>",151,18,1)
        hintItem.setBackImage("ItemClient.Pak",25,0,-6,3,500,0,0,0,0,0,0)
        Itemshow.showText("-")
        Itemshow.showText("[首充获得=佩戴激活]",222)
        Itemshow.showText((" 0"):rep(5),0)
        Itemshow.showItemIcon(" ",255,9,0,0,1)
        Itemshow.showText("重量 <$Item.Weight>",230,10,0,50,80,-35)
--        Itemshow.showText("持久 <$Item.Dura> - <$Item.DuraMax>",230,10,0,50,80,-20)
        Itemshow.showText( ("持久 %d   - %d"):format(item.dura/1000,item.duramax/1000),230,10,0,50,80,-30)
        Itemshow.showText("[基础属性]",230)
        Itemshow.showText("攻击:    <$Item.DC> - <$Item.MaxDC>",223,10)
        Itemshow.showText("魔法:    <$Item.MC> - <$Item.MaxMC>",223,10)
        Itemshow.showText("道术:    <$Item.SC> - <$Item.MaxSC>",223,10)
        Itemshow.showText("准确:       +<$Item.MaxAC> ",223,10)
        Itemshow.showText("需要等级:    <$Item.NeedLevel> ",223,10)
        Itemshow.showText("-")
       
        -------------------------
要在模块初始化使用
SETITEMSHOW(0)                                                                 
过滤客户端默认显示
页: [1] 2
查看完整版本: 龙族Lua使用问题交流贴(龙族官方lua技术镇楼)