mythic-base resource is the foundation of Mythic Framework, providing the component proxy system, logging, database access, and essential utilities that all other resources depend on.
Core Exports
These are the four fundamental exports that power the entire framework:RegisterComponent
Register a new component or override existing
FetchComponent
Retrieve a registered component
ExtendComponent
Add methods to existing component
RequestDependencies
Asynchronously wait for dependencies
RegisterComponent
Register a new component or override an existing protected component.Syntax
Parameters
string
required
Name of the component to register (e.g., ‘Inventory’, ‘Jobs’, ‘MyComponent’)
table
required
Table containing component methods and propertiesSpecial Properties:
_protected(boolean) - If true, component cannot be overridden_required(table) - Array of method names that must exist_name(string) - Internal name for logging
Returns
boolean
Returns
true if component was registered successfullyExamples
Basic Component:Notes
Component Naming: Use PascalCase for component names (e.g., ‘Inventory’, ‘VehicleManager’, ‘MyFeature’)
FetchComponent
Retrieve a registered component for use.Syntax
Parameters
string
required
Name of the component to fetch
Returns
table|nil
The component table if found,
nil if not registeredExamples
Basic Fetch:Notes
ExtendComponent
Add new methods to an existing component without overriding it.Syntax
Parameters
string
required
Name of the component to extend
table
required
Table containing new methods to add to the component
Returns
boolean
Returns
true if extension was successfulExamples
Add Helper Methods:Notes
Non-Destructive:
ExtendComponent adds methods without removing existing ones. If a method name already exists on the component, it will be overridden with the new implementation.RequestDependencies
Asynchronously wait for component dependencies to be registered before initializing your component.Syntax
Parameters
string
required
Name of your component (for error reporting)
table
required
Array of component names that must be loaded before callback executes
function
required
Function called when all dependencies are loaded or on timeoutCallback Parameters:
errors(table) - Array of error messages (empty if all dependencies loaded)
Returns
Nothing (callback-based)Examples
Basic Dependency Management:Notes
Timeout: Dependencies have a timeout (default 30 seconds). If a dependency doesn’t load in time, it will error in the callback.
Core:Shared:Ready Event
TheCore:Shared:Ready event fires when mythic-base has finished initializing and all core components are available.
Syntax
When to Use
UseCore:Shared:Ready when you need to:
- Access core components (Logger, Database, etc.)
- Set up event handlers that use components
- Initialize features that depend on the framework
Examples
Client-Side Initialization:COMPONENTS Global
TheCOMPONENTS global table contains all registered components for easy access.
Usage
Available After
COMPONENTS is populated after the Core:Shared:Ready event fires.
Common Components
- Server
- Client
Best Practices
Use RequestDependencies
Use RequestDependencies
❌ Bad:✅ Good:
Document Your Components
Document Your Components
Use Protected Wisely
Use Protected Wisely
When to use
_protected = true:- Core framework components
- Components with complex internal state
- Components where overriding would break other resources
- Simple utility components
- Components designed to be customizable
- Resource-specific components
Next Steps
Proxy Pattern
Deep dive into the proxy system
Component System
Learn component architecture
Logger API
Logging component reference
Database API
Database component reference
Creating Resources
Build your first component