community_scripts.lua
community_scripts.lua
local libraryList = {
'https://raw.githubusercontent.com/mrlthebest/Community-Scripts/refs/heads/
main/library.lua',
'https://raw.githubusercontent.com/mrlthebest/Community-Scripts/refs/heads/
main/script_list.lua'
}
-- Load libraries
for _, library in ipairs(libraryList) do
modules._G.HTTP.get(library, function(content, error)
if content then
loadstring(content)()
if not error then
if script_manager then
-- Global functions and initializations
local _G = modules._G;
local context = _G.getfenv();
local g_resources = _G.g_resources;
local listDirectoryFiles = g_resources.listDirectoryFiles;
local readFileContents = g_resources.readFileContents;
local fileExists = g_resources.fileExists;
$focus:
background-color: #00000055
Label
id: textToSet
font: terminus-14px-bold
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
]];
script_bot.widget = setupUI([[
MainWindow
!text: tr('Community Scripts')
font: terminus-14px-bold
color: #d2cac5
size: 300 400
TabBar
id: macrosOptions
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
width: 180
ScrollablePanel
id: scriptList
layout:
type: verticalBox
anchors.fill: parent
margin-top: 25
margin-left: 2
margin-right: 15
margin-bottom: 30
vertical-scrollbar: scriptListScrollBar
VerticalScrollBar
id: scriptListScrollBar
anchors.top: scriptList.top
anchors.bottom: scriptList.bottom
anchors.right: scriptList.right
step: 14
pixels-scroll: true
margin-right: -10
HorizontalSeparator
id: sep
anchors.top: enemyList.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: prev.right
margin-left: 10
margin-top: 6
TextEdit
id: searchBar
anchors.left: parent.left
anchors.bottom: parent.bottom
margin-right: 5
width: 130
Button
id: closeButton
!text: tr('Close')
font: cipsoftFont
anchors.right: parent.right
anchors.left: searchBar.right
anchors.bottom: parent.bottom
size: 45 21
margin-bottom: 1
margin-right: 5
margin-left: 5
]], g_ui.getRootWidget())
-- Update label
local updateLabel = UI.Label('Community Scripts. \n New
version available, click "Update Files". \nVersion: ' .. actualVersion);
updateLabel:setColor('yellow');
updateLabel:hide();
-- Define buttons
script_bot.buttonWidget = UI.Button('Script Manager',
function()
if script_bot.widget:isVisible() then
reload();
else
script_bot.widget:show();
script_bot.widget.macrosOptions:selectPrevTab()
end
end, tabName);
script_bot.buttonWidget:setColor('#d2cac5');
script_bot.buttonRemoveJson = UI.Button('Update Files',
function()
script_bot.restartStorage()
end,tabName);
script_bot.buttonRemoveJson:setColor('#d2cac5');
script_bot.buttonRemoveJson:setTooltip('Click here only
when there is an update.');
script_bot.buttonRemoveJson:hide();
script_bot.restartStorage = function()
g_resources.deleteFile(script_path_json);
reload();
end
if macrosCategory then
for key, value in pairs(macrosCategory) do
local label = setupUI(script_add,
script_bot.widget.scriptList);
label.textToSet:setText(key);
label.textToSet:setColor('#bdbdbd');
label:setTooltip('Description: ' ..
value.description .. '\nAuthor: ' .. value.author);
label.onClick = function(widget)
value.enabled = not value.enabled;
script_bot.saveScripts();
label.textToSet:setColor(value.enabled and
'green' or '#bdbdbd');
if value.enabled then
-- loadRemoteScript(value.url);
end
end
if value.enabled then
label.textToSet:setColor('green');
end
label:setId(key);
end
end
end
local numSteps = 6;
local numCategories = #categories;
local numLoops = math.ceil(numCategories / numSteps);
for i = 1, numLoops do
for j = 1, numSteps do
local index = (i - 1) * numSteps + j;
if index <= numCategories then
local categoryName = categories[index];
local tab =
script_bot.widget.macrosOptions:addTab(categoryName);
tab:setId(categoryName);
tab:setTooltip(categoryName .. ' Macros');
tab.onStyleApply = function(widget)
if
script_bot.widget.macrosOptions:getCurrentTab() == widget then
widget:setColor('green');
else
widget:setColor('white');
end
end
end
end
end
local currentTab =
script_bot.widget.macrosOptions:getCurrentTab().text;
script_bot.updateScriptList(currentTab);
script_bot.widget.macrosOptions.onTabChange =
function(widget, tabName)
script_bot.updateScriptList(tabName:getText());
script_bot.filterScripts(script_bot.widget.searchBar:getText());
end
end