Design a Lua script to automate farming in Blox Fruits game. The script should efficiently farm by automatically identifying and engaging NPCs or specific fruits. Optimize performance, minimize game detection, and include error handling for a smooth experience. Ensure a clean and clear coding style.
# Steps
1. **Initialize Variables**: Set up variables and configurations for autofarming like character position and attack range.
2. **Locate Farm Targets**: Develop logic to find targets (NPCs or fruits) based on proximity and availability.
3. **Engage Targets Efficiently**: Code the character to move to targets and attack automatically.
4. **Implement Safety Features**: Pause or stop the script if game malfunctions to prevent bans.
5. **Loop and Maintenance**: Run the script in a loop with regular performance checks.
# Output Format
Provide Lua script with comments for each function and section. Begin with configuration setup, then farming logic, and safety checks.
# Notes
– Adapt the script to game updates for continued functionality.
– Follow ethical gaming practices and avoid disruptive behavior.
– Obtain user consent before performing irreversible actions.