-
Notifications
You must be signed in to change notification settings - Fork 0
/
Roll_Number.lua
157 lines (133 loc) · 4.6 KB
/
Roll_Number.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
local AceGUI = LibStub("AceGUI-3.0")
Stop_Random_Roll = true
-- function that draws the widgets for the first tab
local function DrawGroup1(container)
local desc = AceGUI:Create("Label")
desc:SetText("This is Tab 1")
desc:SetFullWidth(true)
container:AddChild(desc)
local button = AceGUI:Create("Button")
button:SetText("停止Roll点")
button:SetWidth(200)
button:SetCallback("OnClick", function() Stop_Random_Roll = true end)
container:AddChild(button)
end
local function Start_Random()
Stop_Random_Roll = false
RandomRoll(1, 100)
end
-- function that draws the widgets for the second tab
local function DrawGroup2(container)
local desc = AceGUI:Create("Label")
desc:SetText("This is Tab 2")
desc:SetFullWidth(true)
container:AddChild(desc)
local button = AceGUI:Create("Button")
button:SetText("开始Roll点")
button:SetWidth(200)
button:SetCallback("OnClick", Start_Random)
container:AddChild(button)
end
-- function that draws the widgets for the second tab
local function DrawGroup3(container)
local desc = AceGUI:Create("Label")
desc:SetText("This is Tab 3")
desc:SetFullWidth(true)
container:AddChild(desc)
-- Create a button
local btn = AceGUI:Create("Button")
btn:SetWidth(170)
btn:SetText("roll币")
btn:SetCallback("OnClick", say_hello)
-- Add the button to the container
container:AddChild(btn)
local editbox = AceGUI:Create("EditBox")
editbox:SetLabel("Insert text:")
editbox:SetWidth(200)
editbox:SetCallback("OnEnterPressed", function(widget, event, text) textStore = text end)
container:AddChild(editbox)
end
-- Callback function for OnGroupSelected
local function SelectGroup(container, event, group)
container:ReleaseChildren()
if group == "tab1" then
DrawGroup1(container)
elseif group == "tab2" then
DrawGroup2(container)
elseif group == "tab3" then
DrawGroup3(container)
end
end
-- Create
RollNumber = LibStub("AceAddon-3.0"):NewAddon("RollNumber", "AceConsole-3.0", "AceEvent-3.0")
RollNumber:RegisterChatCommand("rn", "MySlashProcessorFunc")
local function say_hello()
-- CHAT_MSG_LOOT
end
function RollNumber:ZONE_CHANGED()
self:Print("You have changed zones!")
end
function RollNumber:OnInitialize()
-- Code that you want to run when the addon is first loaded goes here.
self:Print("RollNumber:OnInitialize()")
end
function RollNumber:OnEnable()
-- Called when the addon is enabled
self:Print("RollNumber:OnEnable()")
RollNumber:RegisterEvent("CHAT_MSG_SYSTEM")
end
function RollNumber:OnDisable()
-- Called when the addon is disabled
self:Print("RollNumber:OnDisable()")
end
function RollNumber:CHAT_MSG_SYSTEM(event, arg1, arg2)
--self:Print("event:".. event.. " arg1:" .. arg1)
local player_name, RealmName = UnitFullName("player")
--print(player_name)
-- self:Print("..["..RANDOM_ROLL_RESULT.."]")
-- self:Print("..["..RANDOM_ROLL_RESULT_X.."]")
local RANDOM_ROLL_RESULT_X = player_name .. "掷出(%d+)((%d+)-(%d+))"
local format = RANDOM_ROLL_RESULT_X
local num1, low, high = strmatch(arg1, format)
if num1 ~= nil and low ~= nil and high ~= nil then
-- self:Print(num1)
-- self:Print("Stop_Random_Roll:" .. tostring(Stop_Random_Roll))
-- self:Print(low .. "," .. high)
if tonumber(num1) == 99 then
self:Print("Stop Random Roll!")
Stop_Random_Roll = true
elseif not(Stop_Random_Roll) then
RandomRoll(1, 100)
--self:Print(" call RandomRoll")
end
end
end
function RollNumber:MySlashProcessorFunc(input)
-- Process the slash command ('input' contains whatever follows the slash command)
self:CreateWindow()
end
function RollNumber:CreateWindow()
-- body
-- Create a container frame
local f = AceGUI:Create("Frame")
f:SetCallback("OnClose", function(widget) AceGUI:Release(widget) end)
f:SetTitle("AceGUI-3.0 Example")
f:SetStatusText("Status Bar")
f:SetLayout("Fill")
-- Create the TabGroup
local tab = AceGUI:Create("TabGroup")
local tab_text_tables = {
{text = "Tab 1", value = "tab1"},
{text = "Tab 2", value = "tab2"},
{text = "Tab 3", value = "tab3"}
}
tab:SetLayout("Flow")
-- Setup which tabs to show
tab:SetTabs(tab_text_tables)
-- Register callback
tab:SetCallback("OnGroupSelected", SelectGroup)
-- Set initial Tab (this will fire the OnGroupSelected callback)
tab:SelectTab("tab1")
-- add to the frame container
f:AddChild(tab)
end