LUACN论坛

 找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
热搜: YJWOW MagicStone BoL
查看: 364|回复: 11

打开商店自动购买消耗品和脱战自动吃喝

[复制链接]
发表于 2024-9-5 11:54:18 | 显示全部楼层 |阅读模式
本帖最后由 QQ_CAFE57 于 2024-9-5 11:54 AM 编辑



仅供参考,不通用(每个服的杂货商人的物品排序不一样)





[Lua] 纯文本查看 复制代码
if not AOTU_MERCHANT then
    AOTU_MERCHANT = CreateFrame("Frame")
    AOTU_MERCHANT:RegisterEvent("UNIT_MANE")
    AOTU_MERCHANT:RegisterEvent("UNIT_HEALTH")
    AOTU_MERCHANT:RegisterEvent("MERCHANT_SHOW")
	
    AOTU_MERCHANT:SetScript("OnEvent", function(self,event,arg1)
            if event == "MERCHANT_SHOW" then 
                --补充消耗品
                if GetMerchantItemInfo(1)=='魔法酪饼' and GetItemCount(43523)<1 then 
                    BuyMerchantItem(1,20) 
                end
                
                local className, classFilename, classId = UnitClass('player')
                --术士消耗品
                if className == '术士' then
                    if GetMerchantItemInfo(11)=='灵魂碎片' and GetItemCount(6265)<100 then 
                        BuyMerchantItem(11,100-GetItemCount(6265)) 
                    end
                end 
            end 
			
            if (event == "UNIT_HEALTH" or event == "UNIT_MANE") and arg1 == 'player' then
                local a = UnitMana('player')
                local b = UnitManaMax('player')
                local c = UnitHealth('player')
                local d = UnitHealthMax('player')
				
                local PN = ((a / b) * 100)
                local PX = ((c / d) * 100)
				
                local Combat = not UnitAffectingCombat('player')
				
                --自动吃喝
                if Combat and not UnitBuff('player','进食') then
                    if (PN<66 or PX<66) and GetItemCount(43523)>0 and GetItemCooldown(43523)<=0 then
                        RunMacroText('/use item:43523')
                    end
                end
            end
    end)
end 
回复

使用道具 举报

 楼主| 发表于 2024-9-5 11:56:35 | 显示全部楼层
自动吃喝部分需要解锁
[Lua] 纯文本查看 复制代码
            if (event == "UNIT_HEALTH" or event == "UNIT_MANE") and arg1 == 'player' then
                local a = UnitMana('player')
                local b = UnitManaMax('player')
                local c = UnitHealth('player')
                local d = UnitHealthMax('player')
				
                local PN = ((a / b) * 100)
                local PX = ((c / d) * 100)
				
                local Combat = not UnitAffectingCombat('player')
				
                --自动吃喝
                if Combat and not UnitBuff('player','进食') then
                    if (PN<66 or PX<66) and GetItemCount(43523)>0 and GetItemCooldown(43523)<=0 then
                        RunMacroText('/use item:43523')
                    end
                end
            end
回复 支持 反对

使用道具 举报

发表于 2024-9-5 13:27:47 | 显示全部楼层
魔蜂还是集成了很多函数的,有些不用自己写
回复 支持 反对

使用道具 举报

发表于 2024-9-5 17:09:46 | 显示全部楼层
function(self,event,arg1),这个是不是匿名函数?
用到了事件,对事件有点怕怕,怕运行多了就搞出好多表来导致内存被弄没了。
以上说没说对我也不知道,感觉这Lua就是个桑巴舞娘,风流随性,一不小心会把舞裙给弄没了。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2024-9-6 10:41:08 来自手机 | 显示全部楼层
xiaoyao1 发表于 2024-9-5 05:09 PM
function(self,event,arg1),这个是不是匿名函数?
用到了事件,对事件有点怕怕,怕运行多了就搞出好多表 ...

。。。。。。。没看懂,什么是匿名函数
回复 支持 反对

使用道具 举报

 楼主| 发表于 2024-9-6 11:07:22 来自手机 | 显示全部楼层
notveryimba 发表于 2024-9-5 01:27 PM
魔蜂还是集成了很多函数的,有些不用自己写

主要是小号多和其他原因要弄成插件,就用官方的函数换了下
回复 支持 反对

使用道具 举报

发表于 2024-9-6 20:55:02 | 显示全部楼层
看着就好,不错不错,支持一下!
回复 支持 反对

使用道具 举报

发表于 2024-9-16 14:45:06 | 显示全部楼层
看着就好,不错不错,支持一下
回复 支持 反对

使用道具 举报

发表于 2024-9-25 12:11:16 | 显示全部楼层

看着就好,不错不错,支持一下
回复 支持 反对

使用道具 举报

发表于 2024-11-10 14:27:56 | 显示全部楼层
这个好,能干很多事情
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

小黑屋|手机版|Archiver|LUACN论坛

GMT+8, 2026-11-30 09:18 AM , Processed in 0.039047 second(s), 9 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表