Configuration
B2Lib provides extensive configuration options to customize the appearance, behavior, and functionality of all UI components. This guide covers every aspect of the configuration system, from basic settings to advanced customization.
Overview
The B2Lib configuration system is centralized in the Config.lua file, which contains all settings for:
Theme System - Colors, typography, spacing, and visual styles
Component Settings - Individual UI component configurations
Performance Options - Optimization settings for better performance
Feature Toggles - Enable/disable specific components
Styling Configurations - Detailed appearance customization
Quick Start
Basic Configuration
-- Enable/disable components
Config.EnabledComponents = {
notifications = true,
progress = true,
menus = true,
textui = true,
input = true,
alert = true,
contextMenu = true,
skillcheck = true,
lockpicking = true,
hacking = true
}
-- Set default theme
Config.Theme.mode = 'dark' -- 'light', 'dark', 'transparent'
-- Configure notifications
Config.Notifications = {
defaultDuration = 5000,
defaultPosition = 'top-right',
maxVisible = 5,
showIcon = true,
playSound = true
}Performance Optimization
Position System
B2Lib uses a comprehensive 9-position grid system for consistent UI placement across all screen resolutions.
Grid Layout
Valid Positions
Primary Positions:
top-left,top-center,top-rightcenter-left,center,center-rightbottom-left,bottom-center,bottom-right
Legacy Aliases:
left(center-left)right(center-right)center-top,center-bottom,bottom
Best Practices
top-right
Notifications
Non-intrusive, natural reading flow
bottom-center
Interaction prompts
Natural eye focus area
center
Important dialogs
Maximum attention
center-left
Menus
Easy access, doesn't block gameplay
Avoid: top-left and bottom-left due to potential conflicts with other UI elements.
Usage Examples
Theme System
The theme system provides comprehensive visual customization with three built-in themes and extensive customization options.
Theme Modes
Dark Theme (Default)
Professional dark theme optimized for low-light environments.
Features:
Dark backgrounds with light text
High contrast for readability
Reduced eye strain in low-light conditions
Professional appearance
Light Theme
Clean, bright theme optimized for well-lit environments.
Features:
Light backgrounds with dark text
Clean, modern appearance
Excellent readability in bright conditions
Familiar interface patterns
Transparent Theme
Semi-transparent theme for immersive gameplay.
Features:
Transparent backgrounds
High contrast text for readability
Minimal visual interference
Immersive gaming experience
Color System
The color system is based on TailwindCSS neutral palette for consistency and accessibility.
Semantic Colors
Background Hierarchy
Text Hierarchy
Border Colors
Typography System
Consistent typography scale based on modern design principles.
Spacing System
Consistent spacing scale based on 4px base unit for pixel-perfect alignment.
Border Radius System
Shadow System
Layered shadow system for depth and elevation.
Animation System
Consistent animation timing and easing for smooth interactions.
Component Configuration
Feature Toggles
Enable or disable specific UI components for performance optimization or to prevent conflicts.
Notifications
Configure the toast-style notification system.
Usage Example:
Progress Bars
Configure progress bars for loading states and timed actions.
Usage Example:
Text UI
Configure contextual text displays with optional keybind hints.
Usage Example:
Menu System
Configure hierarchical navigation menus with search and dynamic content.
Input Dialogs
Configure input dialogs for collecting user data.
Alert Dialogs
Configure alert and confirmation dialogs.
Context Menus
Configure position-based context menus for right-click interactions.
Skillcheck Minigame
Configure the timing-based skillcheck minigame system with single-zone design.
Component Styling
Detailed styling configurations for each UI component. These settings control the visual appearance and layout.
Notification Styling
Progress Bar Styling
Menu Styling
Skillcheck Styling
Lockpicking Styling
Radial Menu Configuration
Comprehensive configuration for the radial menu system.
Basic Settings
Menu Structure
The radial menu uses a hierarchical structure with nested items:
Menu Item Properties:
id- Unique identifier for the menu itemtitle- Display text for the itemicon- Icon to display (emoji or icon name)items- Submenu items (for nested menus)type- Event type ('client' or 'server')event- Event name to triggershouldClose- Whether to close menu after selectiondata- Additional data to pass with the event
Performance Configuration
Optimize B2Lib performance based on your server's requirements.
Performance Tips
Reduce maxNotifications for lower-end clients
Increase updateInterval to 33ms (30 FPS) for better performance
Disable fadeAnimations on servers with many players
Lower raycastDistance to reduce CPU usage
Adjust maxCacheSize based on available memory
Debug Configuration
Configure debugging and logging options for development and troubleshooting.
Log Levels
error
Only critical errors
warn
Warnings and errors
info
General information, warnings, and errors
debug
All messages including detailed debugging information
Custom Themes
Create custom themes by modifying the color palette:
Best Practices
Configuration Management
Backup Configuration - Always backup
Config.luabefore making changesTest Changes - Test configuration changes on a development server first
Document Modifications - Keep track of custom changes for future updates
Use Version Control - Store configuration in version control for team collaboration
Performance Optimization
Monitor Performance - Enable performance metrics during testing
Optimize for Your Server - Adjust settings based on player count and hardware
Disable Unused Components - Turn off components you don't use
Regular Maintenance - Review and optimize settings periodically
Theme Customization
Maintain Contrast - Ensure sufficient contrast for accessibility
Test All Components - Verify theme changes work across all UI components
Consider Use Cases - Different themes for different times of day or events
User Preferences - Allow players to choose their preferred theme
Troubleshooting
Common Issues
UI Components Not Showing:
Check
Config.EnabledComponentssettingsVerify position values are valid
Check console for error messages
Ensure resource is properly started
Performance Issues:
Reduce
maxNotificationsandmaxCacheSizeIncrease
updateIntervalto 33msDisable
fadeAnimationsLower
raycastDistanceandentityCheckDistance
Theme Issues:
Verify color values are valid CSS colors
Check theme mode is set correctly
Ensure all required color properties are defined
Test with default theme first
Styling Problems:
Check CSS unit values (px, rem, %)
Verify theme references are correct
Test with default styling first
Check browser developer tools for CSS errors
Last updated