World of Warcraft [CLASSIC] plugin lua 魔兽世界lua脚本插件
World of Warcraft API - Wowpedia - Your wiki guide to the World of Warcraft
D:\World of Warcraft\_classic_\Interface\AddOns
zwf.lua
function CountdownFunc()
CountdownFrame = CreateFrame("Frame")
FrameScript = function()
if GetTime() - MarkTime > 1 then
if S == 0 then
SendChatMessage(">>烟雾弹<<结束", "YELL")
FrameScript = nil
CountdownFrame:SetScript("OnUpdate",FrameScript)
else
SendChatMessage(S,"YELL")
end
MarkTime = GetTime()
S = S - 1
end
end
MarkTime = GetTime()
S = 5
CountdownFrame:SetScript("OnUpdate",FrameScript)
SendChatMessage(">>烟雾弹<<已释放", "YELL")
end
MainFrame = CreateFrame("Frame")
MainFrame:RegisterEvent("UNIT_SPELLCAST_SENT")
MainFrame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
MainFrame:SetScript("OnEvent", function(_, _, a, b, _, c)
if a == "player" and b== "烟雾弹" then
n = type(c) == "string" and c or CountdownFunc()
end
end)
zwf.toc
zwf.lua
==Console==
Console.lua
local PlayerName = GetUnitName("Player")
local _, PlayerClass = UnitClass("Player")
--print("ha")
local Console = CreateFrame("Frame", nil, UIParent)
ConsolePointer = Console
Console.isInit = false
--Console:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
Console:RegisterEvent("PLAYER_LOGIN")
Console:RegisterEvent("ADDON_LOADED")
Console:SetScript("OnEvent", function(self,e,...)
local func = self.HandleFunc[e]
func(...)
end)
--[[
Console:SetScript("OnUpdate", function(self, elapsed)
local func = self.HandleFunc["ON_UPDATE"]
func(elapsed)
end
]]--
Console.HandleFunc = {
ADDON_LOADED = function(...)
local AddonName = ...
if AddonName ~= "Console" then return end
--Initialize Saved Variables if Necessary
if ConsoleData == nil then
ConsoleData = {}
ConsoleData.Position = {X = 335, Y = 155}
if ConsoleData.CurrentText == nil then
ConsoleData.CurrentText = ""
end
end
--print("Spells:", type(ItIsReadyData["Spells"]))
end,
PLAYER_LOGIN = function (...)
Console.Main = CreateFrame("Frame", nil, UIParent)
Console.Main:SetHeight(500)
Console.Main:SetWidth(500)
Console.Main:SetBackdrop({
bgFile = "Interface\\AddOns\\Sora's Threat\\Media\\Solid", -- 背景材质路径
insets = {left = 1,right = 1,top = 1,bottom = 1}, -- 背景收缩程度,单位为像素,例如,top = 1即背景材质的上边缘向内收缩1个像素
edgeFile = "Interface\\AddOns\\Sora's Threat\\Media\\Solid", -- 边框材质路径
edgeSize = 1, -- 边框宽度
})
Console.Main:SetBackdropColor(0, 0, 0, 0.5)
Console.Main:SetBackdropBorderColor(0, 0, 0, 0.7)
Console.Main:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", ConsoleData.Position.X, ConsoleData.Position.Y)
Console.Main:SetMovable(true)
Console.Main:EnableMouse(true)
Console.Main:RegisterForDrag("LeftButton")
Console.Main:SetScript("OnDragStart", Console.Main.StartMoving)
Console.Main:SetScript("OnDragStop", function()
Console.Main:StopMovingOrSizing()
ConsoleData.Position.Y = Console.Main:GetBottom()
ConsoleData.Position.X = Console.Main:GetLeft()
end)
Console.Main.Title = Console.Main:CreateFontString(nil, "OVERLAY")
Console.Main.Title:SetFont(GameTooltipText:GetFont(), 15, "THINOUTLINE")
Console.Main.Title:SetText("Lua Console")
Console.Main.Title:SetPoint("TOP" , Console.Main, "TOP", 0, -5)
Console.ScriptFrame = CreateFrame("EditBox", nil, Console.Main)
Console.ScriptFrame:SetSize(480, 450)
--Console.ScriptFrame:SetPoint("CENTER", Console.Main, "CENTER", 0, 3)
Console.ScriptFrame:SetBackdrop({
bgFile = "Interface\\AddOns\\Sora's Threat\\Media\\Solid", -- 背景材质路径
insets = {left = 1,right = 1,top = 1,bottom = 1}, -- 背景收缩程度,单位为像素,例如,top = 1即背景材质的上边缘向内收缩1个像素
edgeFile = "Interface\\AddOns\\Sora's Threat\\Media\\Solid", -- 边框材质路径
edgeSize = 1, -- 边框宽度
})
Console.ScriptFrame:SetBackdropColor(0, 0, 0, 0.8)
Console.ScriptFrame:SetBackdropBorderColor(0, 0, 0, 0.8)
Console.ScriptFrame:ClearFocus()
Console.ScriptFrame:SetMultiLine(true)
Console.ScriptFrame:SetMaxBytes(0)
Console.ScriptFrame:SetMaxLetters(0)
Console.ScriptFrame:SetAutoFocus(false)
Console.ScriptFrame:SetFontObject(ChatFontNormal)
Console.ScriptFrame:EnableMouse(true)
Console.ScriptFrame:SetText(ConsoleData.CurrentText)
Console.ScriptScroll = CreateFrame("ScrollFrame", "ScrollHandle", Console.Main, "UIPanelScrollFrameTemplate")
Console.ScriptScroll:SetPoint("TOPLEFT", Console.Main, "TOPLEFT", 10, -22)
Console.ScriptScroll:SetPoint("BOTTOMRIGHT", Console.Main, "BOTTOMRIGHT", -30, 25)
Console.ScriptScroll:SetScrollChild(Console.ScriptFrame)
Console.HideAndShowButton = CreateFrame("Button", "ConsoleDisplayControl", UIParent, "UIPanelButtonTemplate")
Console.HideAndShowButton:SetText("Hide")
Console.HideAndShowButton:SetScript("OnClick", function()
local func = Console.HandleFunc["HIDE_SHOW_BUTTON_CLICK"]
func()
end)
Console.HideAndShowButton:SetPoint("BOTTOMLEFT", Console.Main, "BOTTOMLEFT", 5, -24)
Console.HideAndShowButton:SetSize(55, 22)
Console.RunBotton = CreateFrame("Button", "RunBotton", Console.Main, "UIPanelButtonTemplate")
Console.RunBotton:SetText("Run!")
Console.RunBotton:SetScript("OnClick", function()
local func = Console.HandleFunc["RUN_BOTTON_CLICK"]
func()
end)
Console.RunBotton:SetPoint("BOTTOMRIGHT", Console.Main, "BOTTOMRIGHT", -5, 2)
Console.RunBotton:SetSize(55, 22)
Console.ReloadUIButton = CreateFrame("Button", "ReloadUIButton", Console.Main, "UIPanelButtonTemplate")
Console.ReloadUIButton:SetText("ReloadUI")
Console.ReloadUIButton:SetScript("OnClick", function()
ConsoleData.CurrentText = Console.ScriptFrame:GetText()
ReloadUI()
end)
Console.ReloadUIButton:SetPoint("BOTTOMLEFT", Console.Main, "BOTTOMLEFT", 5, 2)
Console.ReloadUIButton:SetSize(75, 22)
print("Console has inicialized")
--print(type(ConsoleData.CurrentText))
end,
HIDE_SHOW_BUTTON_CLICK = function()
if Console.Main:IsShown() then
Console.Main:Hide()
Console.HideAndShowButton:SetText("Show")
else
Console.Main:Show()
Console.HideAndShowButton:SetText("Hide")
end
end,
RUN_BOTTON_CLICK = function()
local code = Console.ScriptFrame:GetText()
--code = string.gsub(code, "\t", "___")
print(">> "..code)
local f = assert(loadstring(code))
f()
end
}
Console.toc
## Interface: 50300
## Version: 0.0.1
## Author: Wing
## Title: lua Console
## Notes: allows you to directly type lua script and run it in WOW
## SavedVariablesPerCharacter: ConsoleData
Console.xml
Console.xml
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="Console.lua"/>
<Script file="Slash.lua"/>
</Ui>
Slash.lua
--[[SLASH_SAYSOMETHING1 = "/sayit"
SLASH_SAYSOMETHING2 = "/si"
SlashCmdList["SAYSOMETHING"] = function(...)
local msg = ...
print(msg)
ItIsReadyData.msg = msg
end
SLASH_LOADSOMETHING1 = "/loadit"
SlashCmdList["LOADSOMETHING"] = function(...)
print(ItIsReadyData.msg)
end
]]--
SLASH_RELOADUISHORT1 = "/rl"
SlashCmdList["RELOADUISHORT"] = function(...)
ReloadUI()
end
local Console = ConsolePointer
local help_info1 = "\t To add spell watch, enter /iir add {spell id}.\n To remove spell watch, enter /iir rm {spell id}.\n To list all watch, enter /iir list.\n To open/close debug, enter /iir debug.\n"
local help_info2 = "\t To add spell watch group, enter /iir addg {group name}.\n To remove spell watch group, enter /iir rmg {group name}.\n To select a group, enter /iir sel {group name}"
function Console:releaseOnUpdate()
self:SetScript("OnUpdate", function(self, elapsed) end)
end
SLASH_ITISREADY1 = "/console"
SLASH_ITISREADY2 = "/cmd"
SlashCmdList["CONSOLE"] = function (...)
local arg, var = ...
arg, var = strsplit(" ", arg)
--print(arg)
--print(var)
if arg == "add" then
end
end
Console.SlashHandleFunc = {
}
==督军战士,督军猎人==