Traps
Version History
Build Version | Change Date | Change Type | Description |
---|---|---|---|
676042 | 2025-06-21 | stable | Current version |
Overview
The traps.lua
file serves as a legacy redirection file that indicates trap functionality has been relocated to the scenarios system. This file contains only a comment directing developers to the scenarios folder where trap-related content is now maintained.
File Contents
--These are all in the "scenarios" folder now!
Migration Information
Historical Context
Previously, trap definitions and configurations were maintained in the traps.lua
file as part of the core systems. The functionality has been reorganized and moved to a more appropriate location within the scenarios system for better organization and modularity.
Current Location
Trap-related functionality can now be found in:
Primary Location: scripts/scenarios/
Available Trap Scenarios:
- Chest scenarios with trap mechanisms
- Environmental trap configurations
- Interactive trap behaviors
- Trap-related world generation logic
Scenarios Integration
Accessing Trap Functionality
Instead of referencing traps.lua
, developers should now look to the scenarios system:
-- Legacy approach (deprecated)
-- require "traps"
-- Current approach
-- Trap functionality is now integrated into specific scenario files
-- Example: scripts/scenarios/chest_abandonedboat.lua contains trapped chest logic
Scenario-Based Trap Examples
The scenarios folder contains various trap implementations:
-- Example of trap functionality in scenarios
-- Located in scripts/scenarios/[specific_scenario].lua
local function SetupTrappedChest(inst)
-- Trap logic now embedded in scenario-specific context
inst:AddComponent("trap")
inst.components.trap:SetSpringRadius(2)
-- ... additional trap configuration
end
Migration Guide
For Developers
If you were previously referencing or modifying traps.lua
:
- Identify the specific trap functionality you need
- Search the scenarios folder for relevant trap implementations
- Reference scenario-specific files instead of the legacy traps module
- Follow scenario conventions for implementing new trap behaviors
For Modders
When creating mods that involve traps:
-- Instead of modifying traps.lua, create scenario-based implementations
local function AddCustomTrap()
-- Use scenario system for trap logic
local scenario_data = {
trap_type = "custom_trap",
trigger_radius = 3,
effects = {"damage", "stun"}
}
return scenario_data
end
Finding Trap Content
Scenarios Directory Structure
scripts/scenarios/
├── chest_abandonedboat.lua -- Trapped chest scenarios
├── camera_maxwellthrone.lua -- Camera-based trap triggers
├── [scenario_name].lua -- Other scenario files with trap logic
└── ...
Search Strategy
To locate specific trap functionality:
- Browse scenarios folder for files containing trap-related names
- Search for "trap" keyword within scenario files
- Check scenario documentation for trap-specific behaviors
- Reference scenario index for organized trap listings
Related Modules
- Scenarios: Main scenarios system documentation
- Components: Trap component implementations
- World Generation: Trap placement in world generation
Development Notes
Why the Migration Occurred
The relocation of trap functionality to scenarios provides:
- Better Organization: Traps are now contextualized within their usage scenarios
- Improved Modularity: Scenario-specific trap behavior is isolated and maintainable
- Enhanced Flexibility: Traps can be customized per scenario without affecting global systems
- Clearer Dependencies: Trap logic is coupled with the scenarios that use them
Best Practices
When working with trap functionality:
- Use scenario-based approach for implementing new traps
- Reference existing scenarios for established trap patterns
- Maintain scenario conventions for consistency
- Document trap behaviors within their specific scenario contexts
Source Reference
File Location: scripts/traps.lua
Content Type: Legacy redirection comment
Current Implementation: See scripts/scenarios/
directory
Global Access: No longer provides global trap functionality - use scenario-specific implementations instead