Модератор раздела "Создание скриптов для читов"
-
Автор темы
- #1
сама библиотека
пример использования
code_language.lua:
local wrapper = {}
local refs = {}
local DEFAULT_TAB = 'LUA'
local DEFAULT_CONTAINER = 'A'
local function create_base_object()
local obj = {}
function obj:get()
return ui.get(self.reference)
end
function obj:set(value)
ui.set(self.reference, value)
end
function obj:set_callback(callback)
ui.set_callback(self.reference, callback)
end
function obj:get_type()
return ui.type(self.reference)
end
function obj:visibility(visible)
ui.set_visible(self.reference, visible)
end
function obj:update(value, ...)
ui.update(self.reference, value, ...)
end
return obj
end
function wrapper.create(name, container)
local group = {
name = name,
container = container or DEFAULT_CONTAINER,
switch = function(self, name, default)
local obj = create_base_object()
obj.reference = ui.new_checkbox(DEFAULT_TAB, self.container, name)
if default ~= nil then
ui.set(obj.reference, default)
end
return obj
end,
combo = function(self, name, ...)
local obj = create_base_object()
local options = {...}
if type(options[1]) == 'table' then
options = options[1]
end
obj.reference = ui.new_combobox(DEFAULT_TAB, self.container, name, unpack(options))
return obj
end,
selectable = function(self, name, ...)
local obj = create_base_object()
local options = {...}
if type(options[1]) == 'table' then
options = options[1]
end
obj.reference = ui.new_multiselect(DEFAULT_TAB, self.container, name, unpack(options))
return obj
end,
list = function(self, name, options)
local obj = create_base_object()
obj.reference = ui.new_listbox(DEFAULT_TAB, self.container, name, options)
return obj
end,
slider = function(self, name, min, max, default)
local obj = create_base_object()
obj.reference = ui.new_slider(DEFAULT_TAB, self.container, name, min, max, default or min)
return obj
end,
color_picker = function(self, name, default_color)
local obj = create_base_object()
obj.reference = ui.new_color_picker(DEFAULT_TAB, self.container, name,
default_color.r or 255,
default_color.g or 255,
default_color.b or 255,
default_color.a or 255)
return obj
end,
label = function(self, text)
local obj = create_base_object()
obj.reference = ui.new_label(DEFAULT_TAB, self.container, text)
return obj
end,
input = function(self, name)
local obj = create_base_object()
obj.reference = ui.new_textbox(DEFAULT_TAB, self.container, name)
return obj
end,
button = function(self, name, callback)
local obj = create_base_object()
obj.reference = ui.new_button(DEFAULT_TAB, self.container, name, callback)
return obj
end,
hotkey = function(self, name, ecx, edx)
local obj = create_base_object()
obj.reference = ui.new_hotkey(DEFAULT_TAB, self.container, name, ecx, edx)
return obj
end
}
return group
end
function wrapper.find(tab, container, name)
local obj = create_base_object()
obj.reference = ui.reference(tab, container, name)
return obj
end
function wrapper.color(r, g, b, a)
return {r = r, g = g, b = b, a = a}
end
return wrapper
code_language.lua:
local ui = require 'wrapper' -- самый быстрый способ
--local c_ui = require 'wrapper'-- рекомендуется
local general = ui.create('general', 'A')
local other = ui.create('other', 'B')
local text = general:label('text')
local checkbox = general:switch('switch')
print(checkbox:get())