0% found this document useful (0 votes)
26 views6 pages

Lua Script for LinoriaLib Menu

Kamil

Uploaded by

spastileleman
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views6 pages

Lua Script for LinoriaLib Menu

Kamil

Uploaded by

spastileleman
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

-- New example script written by wally

-- You can suggest changes with a pull request or something

local repo = '[Link]

local Library =
loadstring(game:HttpGet("[Link]
refs/heads/main/[Link]"))()
local ThemeManager = loadstring(game:HttpGet(repo .. 'addons/[Link]'))()
local SaveManager = loadstring(game:HttpGet(repo .. 'addons/[Link]'))()

local Window = Library:CreateWindow({


-- Set Center to true if you want the menu to appear in the center
-- Set AutoShow to true if you want the menu to appear when it is created
-- Position and Size are also valid options here
-- but you do not need to define them unless you are changing them :)

Title = 'Example menu',


Center = true,
AutoShow = true,
})

-- You do not have to set your tabs & groups up this way, just a prefrence.
local Tabs = {
-- Creates a new tab titled Main
Main = Window:AddTab('Main'),
['Dev'] = Window:AddTab("Dev"),
['UI Settings'] = Window:AddTab('UI Settings'),
}

-- Groupbox and Tabbox inherit the same functions


-- except Tabboxes you have to call the functions on a tab (Tabbox:AddTab(name))
local DevLeftBox = [Link]:AddLeftGroupbox('Groupbox')

-- Tabboxes are a tiny bit different, but here's a basic example:


--[[

local TabBox = [Link]:AddLeftTabbox() -- Add Tabbox on left side

local Tab1 = TabBox:AddTab('Tab 1')


local Tab2 = TabBox:AddTab('Tab 2')

-- You can now call AddToggle, etc on the tabs you added to the Tabbox
]]

-- Groupbox:AddToggle
-- Arguments: Index, Options
local toggole = DevLeftBox:AddToggle('MyToggle', {
Text = 'This is a toggle',
Default = true, -- Default value (true / false)
Tooltip = 'This is a tooltip', -- Information shown when you hover over the
toggle
})

toggole:AddKeyPicker('KeyPicker', {
-- SyncToggleState only works with toggles.
-- It allows you to make a keybind which has its state synced with its parent
toggle
-- Example: Keybind which you use to toggle flyhack, etc.
-- Changing the toggle disables the keybind state and toggling the keybind
switches the toggle state

Default = 'MB2', -- String as the name of the keybind (MB1, MB2 for mouse
buttons)
SyncToggleState = false,

-- You can define custom Modes but I have never had a use for it.
Mode = 'Toggle', -- Modes: Always, Toggle, Hold

Text = 'Auto lockpick safes', -- Text to display in the keybind menu


NoUI = false, -- Set to true if you want to hide from the Keybind menu,
})

-- Fetching a toggle object for later use:


-- [Link]

-- Toggles is a table added to getgenv() by the library


-- You index Toggles with the specified index, in this case it is 'MyToggle'
-- To get the state of the toggle you do [Link]

-- Calls the passed function when the toggle is updated


[Link]:OnChanged(function()
-- here we get our toggle object & then get its value
print('MyToggle changed to:', [Link])
end)

-- This should print to the console: "My toggle state changed! New value: false"
[Link]:SetValue(false)

-- Groupbox:AddButton
-- Arguments: Text, Callback

local MyButton = DevLeftBox:AddButton('Button', function()


print('You clicked a button!')
end)

-- Button:AddButton
-- Arguments: Text, Callback
-- Adds a sub button to the side of the main button

local MyButton2 = MyButton:AddButton('Sub button', function()


print('You clicked a sub button!')
end)

-- Button:AddTooltip
-- Arguments: ToolTip

MyButton:AddTooltip('This is a button')
MyButton2:AddTooltip('This is a sub button')

-- NOTE: You can chain the button methods!


--[[
EXAMPLE:

LeftGroupBox:AddButton('Kill all', [Link]):AddTooltip('This will


kill everyone in the game!')
:AddButton('Kick all', [Link]):AddTooltip('This will kick
everyone in the game!')
]]

-- Groupbox:AddLabel
-- Arguments: Text, DoesWrap
DevLeftBox:AddLabel('This is a label')
DevLeftBox:AddLabel('This is a label\n\nwhich wraps its text!', true)

-- Groupbox:AddDivider
-- Arguments: None
DevLeftBox:AddDivider()

-- Groupbox:AddSlider
-- Arguments: Idx, Options
DevLeftBox:AddSlider('MySlider', {
Text = 'This is my slider!',

-- Text, Default, Min, Max, Rounding must be specified.


-- Rounding is the number of decimal places for precision.

-- Example:
-- Rounding 0 - 5
-- Rounding 1 - 5.1
-- Rounding 2 - 5.15
-- Rounding 3 - 5.155

Default = 0,
Min = 0,
Max = 5,
Rounding = 1,

Compact = false, -- If set to true, then it will hide the label


})

-- Options is a table added to getgenv() by the library


-- You index Options with the specified index, in this case it is 'MySlider'
-- To get the value of the slider you do [Link]

local Number = [Link]


[Link]:OnChanged(function()
print('MySlider was changed! New value:', [Link])
end)

-- This should print to the console: "MySlider was changed! New value: 3"
[Link]:SetValue(3)

-- Groupbox:AddInput
-- Arguments: Idx, Info
DevLeftBox:AddInput('MyTextbox', {
Default = 'My textbox!',
Numeric = false, -- true / false, only allows numbers
Finished = false, -- true / false, only calls callback when you press enter

Text = 'This is a textbox',


Tooltip = 'This is a tooltip', -- Information shown when you hover over the
textbox
Placeholder = 'Placeholder text', -- placeholder text when the box is empty
-- MaxLength is also an option which is the max length of the text
})

[Link]:OnChanged(function()
print('Text updated. New text:', [Link])
end)

-- Groupbox:AddDropdown
-- Arguments: Idx, Info

DevLeftBox:AddDropdown('MyDropdown', {
Values = { 'This', 'is', 'a', 'dropdown' },
Default = 1, -- number index of the value / string
Multi = false, -- true / false, allows multiple choices to be selected

Text = 'A dropdown',


Tooltip = 'This is a tooltip', -- Information shown when you hover over the
textbox
})

[Link]:OnChanged(function()
print('Dropdown got changed. New value:', [Link])
end)

[Link]:SetValue('This')

-- Multi dropdowns
DevLeftBox:AddDropdown('MyMultiDropdown', {
-- Default is the numeric index (e.g. "This" would be 1 since it if first in
the values list)
-- Default also accepts a string as well

-- Currently you can not set multiple values with a dropdown

Values = { 'This', 'is', 'a', 'dropdown' },


Default = 1,
Multi = true, -- true / false, allows multiple choices to be selected

Text = 'A dropdown',


Tooltip = 'This is a tooltip', -- Information shown when you hover over the
textbox
})

[Link]:OnChanged(function()
-- print('Dropdown got changed. New value:', )
print('Multi dropdown got changed:')
for key, value in next, [Link] do
print(key, value) -- should print something like This, true
end
end)

[Link]:SetValue({
This = true,
is = true,
})

-- Label:AddColorPicker
-- Arguments: Idx, Info
-- You can also ColorPicker & KeyPicker to a Toggle as well

DevLeftBox:AddLabel('Color'):AddColorPicker('ColorPicker', {
Default = [Link](0, 1, 0), -- Bright green
Title = 'Some color', -- Optional. Allows you to have a custom color picker
title (when you open it)
})

[Link]:OnChanged(function()
print('Color changed!', [Link])
end)

[Link]:SetValueRGB([Link](0, 255, 140))

DevLeftBox:AddLabel('Keybind'):AddKeyPicker('KeyPicker', {
-- SyncToggleState only works with toggles.
-- It allows you to make a keybind which has its state synced with its parent
toggle

-- Example: Keybind which you use to toggle flyhack, etc.


-- Changing the toggle disables the keybind state and toggling the keybind
switches the toggle state

Default = 'MB2', -- String as the name of the keybind (MB1, MB2 for mouse
buttons)
SyncToggleState = false,

-- You can define custom Modes but I have never had a use for it.
Mode = 'Toggle', -- Modes: Always, Toggle, Hold

Text = 'Auto lockpick safes', -- Text to display in the keybind menu


NoUI = false, -- Set to true if you want to hide from the Keybind menu,
})

-- OnClick is only fired when you press the keybind and the mode is Toggle
-- Otherwise, you will have to use Keybind:GetState()
[Link]:OnClick(function()
print('Keybind clicked!', [Link])
end)

[Link](function()
while true do
wait(1)

-- example for checking if a keybind is being pressed


local state = [Link]:GetState()
if state then
print('KeyPicker is being held down')
end

if [Link] then break end


end
end)

[Link]:SetValue({ 'MB2', 'Toggle' }) -- Sets keybind to MB2, mode to


Hold
-- Library functions
-- Sets the watermark visibility
Library:SetWatermarkVisibility(true)

-- Sets the watermark text


Library:SetWatermark('This is a really long watermark to text the resizing')

[Link] = true; -- todo: add a function for this

Library:OnUnload(function()
print('Unloaded!')
[Link] = true
end)

-- UI Settings
local MenuGroup = Tabs['UI Settings']:AddLeftGroupbox('Menu')

-- I set NoUI so it does not show up in the keybinds menu


MenuGroup:AddButton('Unload', function() Library:Unload() end)
MenuGroup:AddLabel('Menu bind'):AddKeyPicker('MenuKeybind', { Default = 'Insert',
NoUI = true, Text = 'Menu keybind' })

[Link] = [Link] -- Allows you to have a custom keybind


for the menu

-- Addons:
-- SaveManager (Allows you to have a configuration system)
-- ThemeManager (Allows you to have a menu theme system)

-- Hand the library over to our managers


ThemeManager:SetLibrary(Library)
SaveManager:SetLibrary(Library)

-- Ignore keys that are used by ThemeManager.


-- (we dont want configs to save themes, do we?)
SaveManager:IgnoreThemeSettings()

-- Adds our MenuKeybind to the ignore list


-- (do you want each config to have a different menu key? probably not.)
SaveManager:SetIgnoreIndexes({ 'MenuKeybind' })

-- use case for doing it this way:


-- a script hub could have themes in a global folder
-- and game configs in a separate folder per game
ThemeManager:SetFolder('MyScriptHub')
SaveManager:SetFolder('MyScriptHub/specific-game')

-- Builds our config menu on the right side of our tab


SaveManager:BuildConfigSection(Tabs['UI Settings'])

-- Builds our theme menu (with plenty of built in themes) on the left side
-- NOTE: you can also call ThemeManager:ApplyToGroupbox to add it to a specific
groupbox
ThemeManager:ApplyToTab(Tabs['UI Settings'])

-- You can use the SaveManager:LoadAutoloadConfig() to load a config


-- which has been marked to be one that auto loads!

You might also like