Your First Script
Let’s create a simple script that welcomes you when you connect to a world.Step 1: Create the Script File
Create a new file in thescripts/ directory called welcome.lua:
Step 2: Start GTProxy
When you start GTProxy, you should see:Step 3: Join a World
When you join any world, you’ll see a welcome message in the game!Understanding the Script
Let’s break down what the script does:1. Initialization Message
2. Server Connection Event
3. Player Spawn Event
- Check if the context has a packet
- Get the packet data
- Create a new
LogPacketwith a welcome message - Send it to the client
The backtick syntax (
`2, “) is Growtopia’s color code system:`2= green text“ = white text
Adding a Custom Command
Let’s add a/hello command:
/hello in-game and receive a personalized greeting!
Common Patterns
Pattern 1: Packet Interception
Intercept and modify packets:Pattern 2: Scheduled Tasks
Run code periodically:Pattern 3: Item Database Lookup
Look up item information:Best Practices
Always check if data exists
Always check if data exists
Use descriptive variable names
Use descriptive variable names
Clean up periodic tasks
Clean up periodic tasks
Use formatted logging
Use formatted logging
Next Steps
Logger API
Learn about logging functions
Events API
Handle packet and connection events
Commands API
Register custom commands
Examples
Explore real-world scripts