add module functionality, untested

This commit is contained in:
Deckard
2025-10-04 20:44:07 -04:00
parent f51d8554ab
commit 8b2eeff3fd
10 changed files with 1588 additions and 1488 deletions

View File

@@ -1,35 +1,76 @@
# Scripts Directory
This directory contains deployment and validation scripts for the AzerothCore Docker deployment.
This directory contains deployment, configuration, and management scripts for the AzerothCore Docker deployment.
## Contents
## Core Scripts
### 🚀 Setup & Deployment
- **`setup-server.sh`** - Interactive server setup wizard (recommended for new users)
- **`deploy-and-check.sh`** - Automated deployment and comprehensive health check script
- **`auto-post-install.sh`** - Automated post-installation configuration
### 🔧 Configuration & Management
- **`configure-modules.sh`** - Module configuration analysis and guidance tool
- **`setup-eluna.sh`** - Lua scripting environment setup
- **`update-realmlist.sh`** - Update server address in realmlist configuration
- **`update-config.sh`** - Configuration file updates and management
### 💾 Backup & Restore
- **`backup.sh`** - Manual database backup
- **`backup-hourly.sh`** - Hourly automated backup script
- **`backup-daily.sh`** - Daily automated backup script
- **`restore.sh`** - Database restoration from backup
### 🧹 Maintenance
- **`cleanup.sh`** - Resource cleanup script with multiple cleanup levels
- **`DEPLOYMENT.md`** - Complete documentation for the deployment script
- **`CLEANUP.md`** - Complete documentation for the cleanup script
- **`rebuild-with-modules.sh`** - Rebuild containers with module compilation
- **`test-local-worldserver.sh`** - Local worldserver testing
### 📚 Documentation
- **`DEPLOYMENT.md`** - Complete documentation for deployment scripts
- **`CLEANUP.md`** - Complete documentation for cleanup scripts
## Quick Usage
### Run Health Check on Current Deployment
### 🆕 First-Time Setup (Recommended)
```bash
# Interactive setup wizard
./scripts/setup-server.sh
```
### 🔧 Module Configuration Analysis
```bash
# Check module configuration requirements
./scripts/configure-modules.sh
```
### 🎮 Lua Scripting Setup
```bash
# Setup Eluna scripting environment
./scripts/setup-eluna.sh
```
### 🩺 Health Checks & Deployment
**Run Health Check on Current Deployment**
```bash
cd scripts
./deploy-and-check.sh --skip-deploy
```
### Full Deployment with Health Checks
**Full Deployment with Health Checks**
```bash
cd scripts
./deploy-and-check.sh
```
### Quick Health Check (Basic Tests Only)
**Quick Health Check (Basic Tests Only)**
```bash
cd scripts
./deploy-and-check.sh --skip-deploy --quick-check
```
### Cleanup Resources
### 🧹 Cleanup Resources
```bash
cd scripts
@@ -46,22 +87,94 @@ cd scripts
./cleanup.sh --hard --dry-run
```
### 💾 Backup & Restore Operations
```bash
# Manual backup
./scripts/backup.sh
# Restore from backup
./scripts/restore.sh backup_filename.sql
# Setup automated backups (already configured in containers)
# Hourly: ./scripts/backup-hourly.sh
# Daily: ./scripts/backup-daily.sh
```
## Features
**Container Health Validation**: Checks all 8 core containers
### 🚀 Setup & Deployment Features
**Interactive Setup Wizard**: Guided configuration for new users
**Automated Server Deployment**: Complete three-layer deployment system
**Module Management**: Automated installation and configuration of 13 enhanced modules
**Post-Install Automation**: Automatic database setup, realmlist configuration, and service restart
### 🔧 Configuration Features
**Module Analysis**: Identifies missing configurations and requirements
**Lua Scripting Setup**: Automated Eluna environment with example scripts
**Realmlist Management**: Dynamic server address configuration
**Config File Management**: Automated .conf file generation from .conf.dist templates
### 🩺 Health & Monitoring Features
**Container Health Validation**: Checks all core containers
**Port Connectivity Tests**: Validates all external ports
**Web Service Verification**: HTTP response and content validation
**Database Validation**: Schema and realm configuration checks
**Automated Deployment**: Three-layer deployment (database → services → tools)
**Comprehensive Reporting**: Color-coded status with detailed results
## Variable Names Verified
### 💾 Backup & Maintenance Features
**Automated Backups**: Scheduled hourly and daily database backups
**Manual Backup/Restore**: On-demand backup and restoration tools
**Multi-Level Cleanup**: Safe, hard, and nuclear cleanup options
**Container Rebuilding**: Module compilation and container rebuilding support
The scripts validate the updated variable names:
- `MYSQL_EXTERNAL_PORT` (was `DOCKER_DB_EXTERNAL_PORT`)
- `AUTH_EXTERNAL_PORT` (was `DOCKER_AUTH_EXTERNAL_PORT`)
- `WORLD_EXTERNAL_PORT` (was `DOCKER_WORLD_EXTERNAL_PORT`)
- `SOAP_EXTERNAL_PORT` (was `DOCKER_SOAP_EXTERNAL_PORT`)
- `MYSQL_ROOT_PASSWORD` (was `DOCKER_DB_ROOT_PASSWORD`)
## Script Usage Examples
For complete documentation, see `DEPLOYMENT.md`.
### First-Time Server Setup
```bash
# Complete guided setup (recommended)
./scripts/setup-server.sh
# Follow the interactive prompts to configure:
# - Server network settings
# - Storage locations
# - Database passwords
# - Module selections
```
### Post-Installation Configuration
```bash
# Analyze and configure modules
./scripts/configure-modules.sh
# Setup Lua scripting environment
./scripts/setup-eluna.sh
# Update server address after IP changes
./scripts/update-realmlist.sh new.server.address
```
### Maintenance Operations
```bash
# Health check existing deployment
./scripts/deploy-and-check.sh --skip-deploy
# Clean restart (preserves data)
./scripts/cleanup.sh --hard
./scripts/deploy-and-check.sh
# Backup before major changes
./scripts/backup.sh
```
## Configuration Variables
The scripts work with the updated environment variable names:
- `MYSQL_EXTERNAL_PORT` (database port)
- `AUTH_EXTERNAL_PORT` (authentication server port)
- `WORLD_EXTERNAL_PORT` (world server port)
- `SOAP_EXTERNAL_PORT` (SOAP API port)
- `MYSQL_ROOT_PASSWORD` (database root password)
- `SERVER_ADDRESS` (external server address)
- `STORAGE_ROOT` (data storage location)
For complete documentation, see `DEPLOYMENT.md` and `CLEANUP.md`.

290
scripts/configure-modules.sh Executable file
View File

@@ -0,0 +1,290 @@
#!/bin/bash
# ==============================================
# AzerothCore Module Configuration Script
# ==============================================
# Handles post-installation configuration that requires manual setup beyond Docker automation
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
local status=$1
local message=$2
case $status in
"INFO")
echo -e "${BLUE} ${message}${NC}"
;;
"SUCCESS")
echo -e "${GREEN}${message}${NC}"
;;
"WARNING")
echo -e "${YELLOW}⚠️ ${message}${NC}"
;;
"ERROR")
echo -e "${RED}${message}${NC}"
;;
"HEADER")
echo -e "\n${MAGENTA}=== ${message} ===${NC}"
;;
"CRITICAL")
echo -e "${RED}🚨 CRITICAL: ${message}${NC}"
;;
esac
}
# Load environment variables
if [ -f "docker-compose-azerothcore-services.env" ]; then
source docker-compose-azerothcore-services.env
else
print_status "ERROR" "Environment file not found. Run from acore-compose directory."
exit 1
fi
print_status "HEADER" "AZEROTHCORE MODULE CONFIGURATION ANALYSIS"
echo "This script analyzes your enabled modules and identifies manual configuration requirements."
echo ""
# Check which modules are enabled
ENABLED_MODULES=()
[ "$MODULE_PLAYERBOTS" = "1" ] && ENABLED_MODULES+=("PLAYERBOTS")
[ "$MODULE_AOE_LOOT" = "1" ] && ENABLED_MODULES+=("AOE_LOOT")
[ "$MODULE_LEARN_SPELLS" = "1" ] && ENABLED_MODULES+=("LEARN_SPELLS")
[ "$MODULE_FIREWORKS" = "1" ] && ENABLED_MODULES+=("FIREWORKS")
[ "$MODULE_INDIVIDUAL_PROGRESSION" = "1" ] && ENABLED_MODULES+=("INDIVIDUAL_PROGRESSION")
[ "$MODULE_TRANSMOG" = "1" ] && ENABLED_MODULES+=("TRANSMOG")
[ "$MODULE_SOLO_LFG" = "1" ] && ENABLED_MODULES+=("SOLO_LFG")
[ "$MODULE_ELUNA" = "1" ] && ENABLED_MODULES+=("ELUNA")
[ "$MODULE_ARAC" = "1" ] && ENABLED_MODULES+=("ARAC")
[ "$MODULE_NPC_ENCHANTER" = "1" ] && ENABLED_MODULES+=("NPC_ENCHANTER")
[ "$MODULE_ASSISTANT" = "1" ] && ENABLED_MODULES+=("ASSISTANT")
[ "$MODULE_REAGENT_BANK" = "1" ] && ENABLED_MODULES+=("REAGENT_BANK")
[ "$MODULE_BLACK_MARKET_AUCTION_HOUSE" = "1" ] && ENABLED_MODULES+=("BLACK_MARKET")
print_status "INFO" "Found ${#ENABLED_MODULES[@]} enabled modules: ${ENABLED_MODULES[*]}"
echo ""
# Critical Compatibility Issues
print_status "HEADER" "CRITICAL COMPATIBILITY ISSUES"
if [[ " ${ENABLED_MODULES[*]} " =~ " PLAYERBOTS " ]]; then
print_status "CRITICAL" "mod-playerbots REQUIRES CUSTOM AZEROTHCORE BRANCH"
echo " 🔗 Required: liyunfan1223/azerothcore-wotlk/tree/Playerbot"
echo " ❌ Current: Standard AzerothCore (INCOMPATIBLE)"
echo " 📋 Action: Switch to Playerbot branch OR disable MODULE_PLAYERBOTS"
echo ""
fi
# Client-Side Requirements
print_status "HEADER" "CLIENT-SIDE PATCH REQUIREMENTS"
CLIENT_PATCHES_NEEDED=false
if [[ " ${ENABLED_MODULES[*]} " =~ " INDIVIDUAL_PROGRESSION " ]]; then
print_status "WARNING" "mod-individual-progression requires CLIENT PATCHES"
echo " 📁 Location: ${STORAGE_PATH}/modules/mod-individual-progression/optional/"
echo " 📦 Required: patch-V.mpq (Vanilla crafting/recipes)"
echo " 📦 Optional: patch-J.mpq (Vanilla login screen)"
echo " 📦 Optional: patch-U.mpq (Vanilla loading screens)"
echo " 🎯 Install: Copy to client WoW/Data/ directory"
CLIENT_PATCHES_NEEDED=true
echo ""
fi
if [[ " ${ENABLED_MODULES[*]} " =~ " ARAC " ]]; then
print_status "WARNING" "mod-arac requires CLIENT PATCHES"
echo " 📦 Required: Patch-A.MPQ"
echo " 📁 Location: ${STORAGE_PATH}/modules/mod-arac/patch-contents/"
echo " 🎯 Install: Copy Patch-A.MPQ to client WoW/Data/ directory"
echo " 🔧 Server: DBC files automatically applied during module setup"
CLIENT_PATCHES_NEEDED=true
echo ""
fi
if [ "$CLIENT_PATCHES_NEEDED" = true ]; then
print_status "INFO" "Client patches must be distributed manually to all players"
fi
# Critical Server Configuration Requirements
print_status "HEADER" "CRITICAL SERVER CONFIGURATION"
CONFIG_CHANGES_NEEDED=false
if [[ " ${ENABLED_MODULES[*]} " =~ " INDIVIDUAL_PROGRESSION " ]]; then
print_status "CRITICAL" "mod-individual-progression requires worldserver.conf changes"
echo " ⚙️ Required: EnablePlayerSettings = 1"
echo " ⚙️ Required: DBC.EnforceItemAttributes = 0"
echo " 📁 File: ${STORAGE_PATH}/config/worldserver.conf"
CONFIG_CHANGES_NEEDED=true
echo ""
fi
if [[ " ${ENABLED_MODULES[*]} " =~ " AOE_LOOT " ]]; then
print_status "WARNING" "mod-aoe-loot requires worldserver.conf optimization"
echo " ⚙️ Required: Rate.Corpse.Decay.Looted = 0.01 (default: 0.5)"
echo " 📁 File: ${STORAGE_PATH}/config/worldserver.conf"
CONFIG_CHANGES_NEEDED=true
echo ""
fi
# Manual NPC Spawning Requirements
print_status "HEADER" "MANUAL NPC SPAWNING REQUIRED"
NPC_SPAWNING_NEEDED=false
if [[ " ${ENABLED_MODULES[*]} " =~ " TRANSMOG " ]]; then
print_status "INFO" "mod-transmog requires NPC spawning"
echo " 🤖 Command: .npc add 190010"
echo " 📍 Location: Spawn in major cities (Stormwind, Orgrimmar, etc.)"
NPC_SPAWNING_NEEDED=true
echo ""
fi
if [[ " ${ENABLED_MODULES[*]} " =~ " NPC_ENCHANTER " ]]; then
print_status "INFO" "mod-npc-enchanter requires NPC spawning"
echo " 🤖 Command: .npc add [enchanter_id]"
echo " 📍 Location: Spawn in major cities"
NPC_SPAWNING_NEEDED=true
echo ""
fi
if [[ " ${ENABLED_MODULES[*]} " =~ " REAGENT_BANK " ]]; then
print_status "INFO" "mod-reagent-bank requires NPC spawning"
echo " 🤖 Command: .npc add 290011"
echo " 📍 Location: Spawn in major cities"
NPC_SPAWNING_NEEDED=true
echo ""
fi
if [ "$NPC_SPAWNING_NEEDED" = true ]; then
print_status "INFO" "Use GM account with level 3 permissions to spawn NPCs"
fi
# Configuration File Management
print_status "HEADER" "CONFIGURATION FILE SETUP"
echo "Module configuration files are automatically copied during container startup:"
echo ""
for module in "${ENABLED_MODULES[@]}"; do
case $module in
"PLAYERBOTS")
echo " 📝 playerbots.conf - Bot behavior, RandomBot settings"
;;
"AOE_LOOT")
echo " 📝 mod_aoe_loot.conf - Loot range, group settings"
;;
"LEARN_SPELLS")
echo " 📝 mod_learnspells.conf - Auto-learn behavior"
;;
"FIREWORKS")
echo " 📝 mod_fireworks.conf - Level-up effects"
;;
"INDIVIDUAL_PROGRESSION")
echo " 📝 individual_progression.conf - Era progression settings"
;;
"TRANSMOG")
echo " 📝 transmog.conf - Transmogrification rules"
;;
"SOLO_LFG")
echo " 📝 SoloLfg.conf - Solo dungeon finder settings"
;;
"ELUNA")
echo " 📝 mod_LuaEngine.conf - Lua scripting engine"
;;
*)
;;
esac
done
# Database Backup Recommendation
print_status "HEADER" "DATABASE BACKUP RECOMMENDATION"
if [[ " ${ENABLED_MODULES[*]} " =~ " ARAC " ]] || [[ " ${ENABLED_MODULES[*]} " =~ " INDIVIDUAL_PROGRESSION " ]]; then
print_status "CRITICAL" "Database backup STRONGLY RECOMMENDED"
echo " 💾 Modules modify core database tables"
echo " 🔄 Backup command: docker exec ac-mysql mysqldump -u root -p\${MYSQL_ROOT_PASSWORD} --all-databases > backup.sql"
echo ""
fi
# Performance Considerations
print_status "HEADER" "PERFORMANCE CONSIDERATIONS"
if [[ " ${ENABLED_MODULES[*]} " =~ " PLAYERBOTS " ]]; then
print_status "WARNING" "mod-playerbots can significantly impact server performance"
echo " 🤖 Default: 500 RandomBots (MinRandomBots/MaxRandomBots)"
echo " 💡 Recommendation: Start with lower numbers and scale up"
echo " 📊 Monitor: CPU usage, memory consumption, database load"
echo ""
fi
if [[ " ${ENABLED_MODULES[*]} " =~ " ELUNA " ]]; then
print_status "INFO" "mod-eluna performance depends on Lua script complexity"
echo " 📜 Complex scripts can impact server performance"
echo " 🔍 Monitor script execution times"
echo ""
fi
# Eluna Lua Scripting Setup
if [[ " ${ENABLED_MODULES[*]} " =~ " ELUNA " ]]; then
print_status "HEADER" "ELUNA LUA SCRIPTING REQUIREMENTS"
if [ -d "${STORAGE_PATH}/lua_scripts" ]; then
print_status "SUCCESS" "Lua scripts directory exists: ${STORAGE_PATH}/lua_scripts"
SCRIPT_COUNT=$(find "${STORAGE_PATH}/lua_scripts" -name "*.lua" 2>/dev/null | wc -l)
print_status "INFO" "Found $SCRIPT_COUNT Lua script(s)"
else
print_status "WARNING" "Lua scripts directory missing: ${STORAGE_PATH}/lua_scripts"
print_status "INFO" "Run ./scripts/setup-eluna.sh to create directory and example scripts"
fi
print_status "INFO" "Eluna Script Management:"
echo " 🔄 Reload scripts: .reload eluna"
echo " 📁 Script location: ${STORAGE_PATH}/lua_scripts"
echo " ⚠️ Compatibility: AzerothCore mod-eluna only (NOT standard Eluna)"
echo " 📋 Requirements: English DBC files recommended"
echo ""
fi
# Summary and Next Steps
print_status "HEADER" "SUMMARY AND NEXT STEPS"
echo "📋 REQUIRED MANUAL ACTIONS:"
echo ""
if [[ " ${ENABLED_MODULES[*]} " =~ " PLAYERBOTS " ]]; then
echo "1. 🔧 CRITICAL: Switch to Playerbot AzerothCore branch OR disable MODULE_PLAYERBOTS"
fi
if [ "$CONFIG_CHANGES_NEEDED" = true ]; then
echo "2. ⚙️ Edit worldserver.conf with required settings (see above)"
fi
if [ "$CLIENT_PATCHES_NEEDED" = true ]; then
echo "3. 📦 Distribute client patches to all players"
fi
if [ "$NPC_SPAWNING_NEEDED" = true ]; then
echo "4. 🤖 Spawn required NPCs using GM commands"
fi
echo ""
echo "📖 RECOMMENDED ORDER:"
echo " 1. Complete server configuration changes"
echo " 2. Rebuild containers with: ./scripts/rebuild-with-modules.sh"
echo " 3. Test in development environment first"
echo " 4. Create GM account and spawn NPCs"
echo " 5. Distribute client patches to players"
echo " 6. Monitor performance and adjust settings as needed"
echo ""
print_status "SUCCESS" "Module configuration analysis complete!"
print_status "INFO" "Review all CRITICAL and WARNING items before deploying to production"

347
scripts/setup-eluna.sh Executable file
View File

@@ -0,0 +1,347 @@
#!/bin/bash
# ==============================================
# AzerothCore Eluna Lua Scripting Setup
# ==============================================
# Sets up Lua scripting environment for mod-eluna
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
local status=$1
local message=$2
case $status in
"INFO")
echo -e "${BLUE} ${message}${NC}"
;;
"SUCCESS")
echo -e "${GREEN}${message}${NC}"
;;
"WARNING")
echo -e "${YELLOW}⚠️ ${message}${NC}"
;;
"ERROR")
echo -e "${RED}${message}${NC}"
;;
"HEADER")
echo -e "\n${MAGENTA}=== ${message} ===${NC}"
;;
esac
}
# Load environment variables
if [ -f "docker-compose-azerothcore-services.env" ]; then
source docker-compose-azerothcore-services.env
else
print_status "ERROR" "Environment file not found. Run from acore-compose directory."
exit 1
fi
print_status "HEADER" "AZEROTHCORE ELUNA LUA SCRIPTING SETUP"
# Check if Eluna is enabled
if [ "$MODULE_ELUNA" != "1" ]; then
print_status "ERROR" "MODULE_ELUNA is not enabled. Set MODULE_ELUNA=1 in environment file."
exit 1
fi
print_status "SUCCESS" "mod-eluna is enabled"
# Create lua_scripts directory
LUA_SCRIPTS_DIR="${STORAGE_PATH}/lua_scripts"
print_status "INFO" "Creating Lua scripts directory: $LUA_SCRIPTS_DIR"
if [ ! -d "$LUA_SCRIPTS_DIR" ]; then
mkdir -p "$LUA_SCRIPTS_DIR"
print_status "SUCCESS" "Created lua_scripts directory"
else
print_status "INFO" "lua_scripts directory already exists"
fi
# Create example scripts
print_status "HEADER" "CREATING EXAMPLE LUA SCRIPTS"
# Welcome script
cat > "$LUA_SCRIPTS_DIR/welcome.lua" << 'EOF'
-- ==============================================
-- Welcome Script for AzerothCore mod-eluna
-- ==============================================
-- Sends welcome message to players on login
local PLAYER_EVENT_ON_LOGIN = 3
local function OnPlayerLogin(event, player)
local playerName = player:GetName()
local accountId = player:GetAccountId()
-- Send welcome message
player:SendBroadcastMessage("|cff00ff00Welcome to the AzerothCore server, " .. playerName .. "!|r")
player:SendBroadcastMessage("|cffyellow🎮 This server features custom modules and Lua scripting!|r")
-- Log the login
print("Player " .. playerName .. " (Account: " .. accountId .. ") has logged in")
end
-- Register the event
RegisterPlayerEvent(PLAYER_EVENT_ON_LOGIN, OnPlayerLogin)
print("✅ Welcome script loaded successfully")
EOF
print_status "SUCCESS" "Created example welcome.lua script"
# Server info script
cat > "$LUA_SCRIPTS_DIR/server_info.lua" << 'EOF'
-- ==============================================
-- Server Info Commands for AzerothCore mod-eluna
-- ==============================================
-- Provides custom server information commands
local function ServerInfoCommand(player, command)
if command == "info" or command == "serverinfo" then
player:SendBroadcastMessage("|cff00ffffServer Information:|r")
player:SendBroadcastMessage("• Core: AzerothCore with mod-eluna")
player:SendBroadcastMessage("• Lua Scripting: Enabled")
player:SendBroadcastMessage("• Active Modules: 13 gameplay enhancing modules")
player:SendBroadcastMessage("• Features: Playerbots, Transmog, Solo LFG, and more!")
return false -- Command handled
end
return true -- Command not handled, continue processing
end
-- Register the command handler
local PLAYER_EVENT_ON_COMMAND = 42
RegisterPlayerEvent(PLAYER_EVENT_ON_COMMAND, ServerInfoCommand)
print("✅ Server info commands loaded successfully")
print(" Usage: .info or .serverinfo")
EOF
print_status "SUCCESS" "Created example server_info.lua script"
# Level reward script
cat > "$LUA_SCRIPTS_DIR/level_rewards.lua" << 'EOF'
-- ==============================================
-- Level Reward Script for AzerothCore mod-eluna
-- ==============================================
-- Gives rewards to players when they level up
local PLAYER_EVENT_ON_LEVEL_CHANGE = 13
local function OnPlayerLevelUp(event, player, oldLevel)
local newLevel = player:GetLevel()
local playerName = player:GetName()
-- Skip if level decreased (rare edge case)
if newLevel <= oldLevel then
return
end
-- Congratulate the player
player:SendBroadcastMessage("|cffff6600Congratulations on reaching level " .. newLevel .. "!|r")
-- Give rewards for milestone levels
local milestoneRewards = {
[10] = {item = 6948, count = 1, message = "Hearthstone for your travels!"},
[20] = {gold = 100, message = "1 gold to help with expenses!"},
[30] = {gold = 500, message = "5 gold for your dedication!"},
[40] = {gold = 1000, message = "10 gold for reaching level 40!"},
[50] = {gold = 2000, message = "20 gold for reaching level 50!"},
[60] = {gold = 5000, message = "50 gold for reaching the original level cap!"},
[70] = {gold = 10000, message = "100 gold for reaching the Burning Crusade cap!"},
[80] = {gold = 20000, message = "200 gold for reaching max level!"}
}
local reward = milestoneRewards[newLevel]
if reward then
if reward.item then
player:AddItem(reward.item, reward.count or 1)
end
if reward.gold then
player:ModifyMoney(reward.gold * 10000) -- Convert gold to copper
end
player:SendBroadcastMessage("|cffff0000Milestone Reward: " .. reward.message .. "|r")
-- Announce to server for major milestones
if newLevel >= 60 then
SendWorldMessage("|cffff6600" .. playerName .. " has reached level " .. newLevel .. "! Congratulations!|r")
end
end
print("Player " .. playerName .. " leveled from " .. oldLevel .. " to " .. newLevel)
end
-- Register the event
RegisterPlayerEvent(PLAYER_EVENT_ON_LEVEL_CHANGE, OnPlayerLevelUp)
print("✅ Level rewards script loaded successfully")
EOF
print_status "SUCCESS" "Created example level_rewards.lua script"
# Create a main loader script
cat > "$LUA_SCRIPTS_DIR/init.lua" << 'EOF'
-- ==============================================
-- Main Loader Script for AzerothCore mod-eluna
-- ==============================================
-- This script loads all other Lua scripts
print("🚀 Loading AzerothCore Lua Scripts...")
-- Load all scripts in this directory
-- Note: Individual scripts are loaded automatically by mod-eluna
-- This file serves as documentation for loaded scripts
local loadedScripts = {
"welcome.lua - Player welcome messages on login",
"server_info.lua - Custom server information commands",
"level_rewards.lua - Milestone rewards for leveling"
}
print("📜 Available Lua Scripts:")
for i, script in ipairs(loadedScripts) do
print(" " .. i .. ". " .. script)
end
print("✅ Lua script initialization complete")
print("🔧 To reload scripts: .reload eluna")
EOF
print_status "SUCCESS" "Created init.lua loader script"
# Create Eluna configuration documentation
cat > "$LUA_SCRIPTS_DIR/README.md" << 'EOF'
# AzerothCore Eluna Lua Scripts
This directory contains Lua scripts for the AzerothCore mod-eluna engine.
## Available Scripts
### welcome.lua
- Sends welcome messages to players on login
- Logs player login events
- Demonstrates basic player event handling
### server_info.lua
- Provides `.info` and `.serverinfo` commands
- Shows server configuration and features
- Demonstrates custom command registration
### level_rewards.lua
- Gives rewards to players at milestone levels (10, 20, 30, etc.)
- Announces major level achievements to the server
- Demonstrates player level change events and item/gold rewards
### init.lua
- Documentation script listing all available scripts
- Serves as a reference for loaded functionality
## Script Management
### Reloading Scripts
```
.reload eluna
```
### Adding New Scripts
1. Create `.lua` file in this directory
2. Use RegisterPlayerEvent, RegisterCreatureEvent, etc. to register events
3. Reload scripts with `.reload eluna` command
### Configuration
Eluna configuration is managed in `/azerothcore/config/mod_LuaEngine.conf`:
- Script path: `lua_scripts` (this directory)
- Auto-reload: Disabled by default (enable for development)
- Bytecode cache: Enabled for performance
## Event Types
Common event types for script development:
- `PLAYER_EVENT_ON_LOGIN = 3`
- `PLAYER_EVENT_ON_LOGOUT = 4`
- `PLAYER_EVENT_ON_LEVEL_CHANGE = 13`
- `PLAYER_EVENT_ON_COMMAND = 42`
- `CREATURE_EVENT_ON_SPAWN = 5`
- `SPELL_EVENT_ON_CAST = 1`
## API Reference
### Player Methods
- `player:GetName()` - Get player name
- `player:GetLevel()` - Get player level
- `player:SendBroadcastMessage(msg)` - Send message to player
- `player:AddItem(itemId, count)` - Add item to player
- `player:ModifyMoney(copper)` - Add/remove money (in copper)
### Global Functions
- `print(message)` - Log to server console
- `SendWorldMessage(message)` - Send message to all players
- `RegisterPlayerEvent(eventId, function)` - Register player event handler
## Development Tips
1. **Test in Development**: Enable auto-reload during development
2. **Error Handling**: Use pcall() for error-safe script execution
3. **Performance**: Avoid heavy operations in frequently called events
4. **Debugging**: Use print() statements for debugging output
## Compatibility Notes
- **AzerothCore Specific**: These scripts are for AzerothCore's mod-eluna
- **Not Compatible**: Standard Eluna scripts will NOT work
- **API Differences**: AzerothCore mod-eluna has different API than standard Eluna
EOF
print_status "SUCCESS" "Created comprehensive README.md documentation"
# Check if volume mount exists in docker-compose
print_status "HEADER" "CHECKING DOCKER COMPOSE CONFIGURATION"
if grep -q "lua_scripts" docker-compose-azerothcore-services.yml; then
print_status "SUCCESS" "lua_scripts volume mount already configured"
else
print_status "WARNING" "lua_scripts volume mount not found in docker-compose-azerothcore-services.yml"
print_status "INFO" "You may need to add volume mount to worldserver service:"
echo " volumes:"
echo " - \${STORAGE_PATH}/lua_scripts:/azerothcore/lua_scripts"
fi
# Check if Eluna container is configured
if grep -q "ac-eluna:" docker-compose-azerothcore-services.yml; then
print_status "SUCCESS" "Eluna container (ac-eluna) is configured"
else
print_status "INFO" "No separate Eluna container found (using embedded mod-eluna)"
fi
# Summary
print_status "HEADER" "SETUP COMPLETE"
echo "📁 Lua Scripts Directory: $LUA_SCRIPTS_DIR"
echo "📜 Example Scripts Created:"
echo " • welcome.lua - Player login messages"
echo " • server_info.lua - Custom info commands"
echo " • level_rewards.lua - Milestone rewards"
echo " • init.lua - Script loader documentation"
echo " • README.md - Complete documentation"
echo ""
print_status "INFO" "Next Steps:"
echo "1. Start/restart your worldserver container"
echo "2. Test scripts with GM commands:"
echo " • .reload eluna"
echo " • .info (test server_info.lua)"
echo "3. Login with a character to test welcome.lua"
echo "4. Level up a character to test level_rewards.lua"
echo ""
print_status "SUCCESS" "Eluna Lua scripting environment setup complete!"
print_status "WARNING" "Remember: AzerothCore mod-eluna is NOT compatible with standard Eluna scripts"