Your browser does not support JavaScript or its disabled!
Please turn it on, or be aware that some features on this website will not work correctly.
2K
Bot Tabs Example #69

This will allow you to add tabs to your bot. I will not be supporting this.
This is an example only. If you do not know how to use it, then you shouldn't be using it.
Its not perfect but its an example. If you are coding your own interfaces you will know what to do with it.
You do not need the loop.

File: Tabs.lua | 1.38kb | 66 lines.
--[[
  Script made by Lee (Discord: l33_) - www.trainorcreations.com
  If you want to support my work, feel free to donate at https://trainorcreations.com/donate
  PS. Stop ripping off my work and selling it as your own.
]]--
g_ui.loadUIFromString([[
tPanel < Panel
  margin: 3
  layout:
    type: verticalBox

tabMainWindow < MainWindow
  !text: tr('Tab Bars')
  size: 218 258
  @onEscape: self:hide()

  TabBar
    id: tabs
    anchors.top: parent.top
    anchors.left: parent.left
    anchors.right: parent.right

  Panel
    id: content
    anchors.top: prev.bottom
    anchors.left: parent.left
    anchors.right: parent.right
    anchors.bottom: parent.bottom
    image-source: /images/ui/panel_flat
    image-border: 5
]])

local function createTab(tabBar, tabName, tabId)
    local tmpPanel = g_ui.createWidget("tPanel")
    tmpPanel:setId("panelButtons" .. tabId) 
    tabBar:addTab(tabName, tmpPanel)

    return tmpPanel
end

local function addCustomWidgets(panel)
    local id = panel:getId()
    UI.Label(id, panel)
    UI.Separator(panel)

    local printMessage = "Print: " ..id
    UI.Button(printMessage, function()
        print(printMessage)
    end, panel)

    UI.Separator(panel)
end

local TabWindow = UI.createWindow('tabMainWindow')
local TabBar = TabWindow.tabs
TabBar:setContentWidget(TabWindow.content)

local panels = {}
local tabCount = 4

for i = 1, tabCount do
    local tabName = "Test"..i
    local panel = createTab(TabBar, tabName, i)
    panels[tabName] = panel

    addCustomWidgets(panel)
end

addCustomWidgets(panels["Test1"])
addCustomWidgets(panels["Test1"])
addCustomWidgets(panels["Test2"])

04 Oct 2024
Ads