-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs.lua
More file actions
179 lines (159 loc) · 4.72 KB
/
docs.lua
File metadata and controls
179 lines (159 loc) · 4.72 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
Hello, and welcome to this documentation document! This will briefly cover all the necessary steps, you need to create a nice UI. :)
The main variable you will be using is called ("library").
Function Map:
library: {
AddWindow(<string> title, <table> options [optional])
-> {
AddTab(<string> title)
-> {
AddLabel(<string> text)
AddButton(<string> title, <function> callback)
AddTextBox(<string> title, <function> callback, <table> options [clear = true]) -- callback args: <string> text
AddSwitch(<string> title, <function> callback) -- callback args: <boolean> statement
-> {
Set(<boolean> statement)
}
AddSlider(<string> title, <function> callback, <table> options [min = 0, max = 100, readonly = false]) -- callback args: <number> number selected
-> {
Set(<number> number)
}
AddKeybind(<string> title, <function> callback, <table> options [standard = Enum.KeyCode.RightShift])
-> {
SetKeybind(<Enum> keycode object)
}
AddDropdown(<string> title, <function> callback) -- callback args: <string> selected object name
-> {
Add(<string> title) -- adds object with ("title") to the dropdown list
-> {
Remove() -- removes the object from the dropdown list
}
}
AddColorPicker(<function> callback) -- callback args: <Color3> color selected
-> {
Set(<Color3> color)
}
AddConsole(<table> options [y = 200 (height of the console), full = false (fills out entire tab), source = "Lua" (or "Logs"), readonly = true])
-> {
Get() -- returns input
Set(<string> input) -- sets input
Log(<string> message) -- adds a message to the console
}
AddHorizontalAlignment() -- creates empty ui-element, will align elements horizontally (buttons only)
-> {
AddButton(...) -- same as other AddButton, except it will be placed horizontally
}
AddFolder(<string> title)
-> {
-- returns the same as AddTab, except functions used from this return will be added into the folder.
}
Show() -- function to open tab
}
}
FormatWindows() -- will place the current windows nicely. this function is recommended to use after UI setup.
}
To create a new window, simply use the following function:
local window = library:AddWindow(<string> title, <table> options) -- Keep in mind that the options argument is not necessary, if you just leave it nil, it will use the default ui_options table, which is located at the top.
Notice how I assign the window to a variable ("window"). This is because the function returns a table consisting of more functions, which you can use on this window.
To add a tab to our window, we can use the following function:
local tab = window:AddTab()
This function will also return a table with functions.
To make this tab *show* as first thing, we will add this:
tab:Show()
Now we can begin adding stuff to this tab!
[Examples]:
AddLabel:
```
tab:AddLabel("Hello World!")
```
AddButton:
```
tab:AddButton("Give ...", function()
print("Gave ... !")
end)
```
AddTextBox:
```
tab:AddTextBox("Teleport to Player", function(text)
teleport_to(game:GetService("Players"):FindFirstChild("text") or game:GetService("Players").LocalPlayer)
end)
```
AddSwitch:
```
local switch = tab:AddSwitch("God Mode", function(bool)
toggle_god_mode(bool)
end)
switch:Set(true)
```
AddSlider:
```
local slider = tab:AddSlider("WalkSpeed", function(p)
setwalkspeed(p)
end, {
["min"] = 16,
["max"] = 100,
})
slider:Set(16)
```
AddKeybind:
```
local keybind = tab:AddKeybind("Toggle", function(obj)
ui_options.toggle_key = obj
end, {
["standard"] = Enum.KeyCode.RightShift,
})
```
AddDropdown:
```
local dropdown = tab:AddDropdown("Teleport to Location", function(text)
if text == "Mars" then
teleport(CFrame.new(...))
elseif ...
end
end)
local mars = dropdown:Add("Mars")
local earth = dropdown:Add("Earth")
local not_a_planet = dropdown:Add("Iridocyclitis")
not_a_planet:Remove()
```
AddColorPicker:
```
tab:AddLabel("Theme color")
local cp = tab:AddColorPicker(function(color)
ui_options.main_color = color
end)
```
AddFolder:
```
local folder = tab:AddFolder()
folder:AddSwitch()
folder:AddLabel("Woo! I'm inside a folder!")
local folder2 = folder:AddFolder()
folder2:AddLabel("I'm inside *two* folders :smirk:")
```
[Adding Options]:
The only two element-functions taking options right now is "AddSlider" and "AddTextBox".
To set options, simply add a table as the last argument, like this:
```
tab:AddSlider("WalkSpeed", function(x)
setwalkspeed(x)
end, {
["min"] = 16, -- default : 0
["max"] = 100, -- default : 100
})
```
Now for AddTextBox example:
```
tab:AddTextBox("Epic", function(text)
print("TextBox : " .. text)
end, {
["clear"] = false, -- default : true
})
```
AddConsole example:
```
tab:AddConsole({
["y"] = 210,
["readonly"] = false,
["source"] = "Lua",
})
```