Managing Sven Co-op Maps with Custom Scripts

https://sbmesh.com/delete_map.ps1

https://sbmesh.com/delete_map.sh

Sven Co-op players often download custom maps, but managing them can be tedious. To simplify map cleanup, I’ve created two scripts—one for Windows (PowerShell) and one for Linux (Bash)—that delete specific maps and optionally their series counterparts, including associated .res and .cfg files. These scripts work in the default Sven Co-op map download folders and handle map names with leading zeros or trailing text (e.g., mapname01.bsp, othermap2etc.bsp).

Windows PowerShell Script

The PowerShell script operates in C:\Program Files (x86)\Steam\steamapps\common\Sven Co-op\svencoop_downloads\maps. It prompts for a map name (without needing .bsp), deletes the specified map, and offers to delete all maps in the same series.

Features

  • Deletes .bsp, .res, and .cfg files for the specified map.
  • Recognizes series maps (e.g., a_jungle_01, a_jungle_2etc) and deletes all in the series if confirmed.
  • No need to type .bsp extension.

Usage

  1. Save the script as delete_map.ps1 in the maps folder.
  2. Run it in PowerShell.
  3. Enter a map name (e.g., a_jungle_1).
  4. Confirm if you want to delete series maps (e.g., a_jungle_*.bsp, .res, .cfg).

Linux Bash Script

The Bash script works in ~/.local/share/Steam/steamapps/common/Sven Co-op/svencoop_downloads/maps. It mirrors the PowerShell script’s functionality for Linux users.

Features

  • Deletes .bsp, .res, and .cfg files for the entered map.
  • Handles series maps with leading zeros or trailing text.
  • .bsp extension is optional.

Usage

  1. Save the script as delete_map.sh in the maps folder.
  2. Make it executable: chmod +x delete_map.sh.
  3. Run it: ./delete_map.sh.
  4. Enter a map name and confirm series deletion if prompted.

Why Use These Scripts?

Both scripts streamline map management by:

  • Automating deletion of related files.
  • Handling complex map naming conventions.
  • Offering series deletion for quick cleanup.

Place the scripts in their respective map folders, and enjoy a clutter-free Sven Co-op experience!

Exploring the Ozon3 Perl Module for Air Quality Data

https://sbmesh.com/Ozon3.pm

The Ozon3 Perl module is a lightweight interface to the World Air Quality Index (WAQI) API, designed to fetch real-time air quality data based on geographic coordinates. Modeled after the Python Ozon3 library, it provides a robust way to retrieve Air Quality Index (AQI) and pollutant metrics with optional rate limiting.

Key Features

  • WAQI API Integration: Connects to https://api.waqi.info/ to retrieve air quality data.
  • Rate Limiting: Supports up to 1000 API calls per second using Schedule::RateLimiter (optional).
  • Error Handling: Comprehensive checks for invalid tokens, rate limits, and API errors.
  • Data Extraction: Returns detailed AQI, pollutant levels (e.g., PM2.5, PM10, NO2), and health implications.

Core Components

Initialization (new)

  • Requires a WAQI API token.
  • Sets up LWP::UserAgent for HTTP requests and Schedule::RateLimiter for throttling.
  • Validates the token by querying the API with a test request for London.

Fetching Data (get_air_quality)

  • Takes latitude and longitude as inputs.
  • Constructs a URL with escaped parameters and the API token.
  • Returns a hashref containing AQI, pollutant concentrations, station details, and health implications.

Data Processing (_extract_live_data)

  • Extracts metrics like AQI, PM2.5, PM10, CO, and meteorological data (e.g., temperature, humidity).
  • Normalizes pollutant names (e.g., pm25 to pm2.5).
  • Converts AQI into human-readable meanings and health implications.

Utility Methods

  • _check_token_validity: Verifies the API token.
  • _check_and_get_data_obj: Handles HTTP responses and API errors.
  • _aqi_meaning: Maps AQI values to categories (e.g., “Good,” “Unhealthy”) and health risks.
  • _as_float: Ensures numeric values are properly formatted.

Usage Example

use Ozon3;
my $ozon3 = Ozon3->new(token => 'your_waqi_token');
my $aq = $ozon3->get_air_quality(37.7749, -122.4194); # San Francisco
if ($aq) {
    print "AQI: $aq->{aqi} ($aq->{aqi_meaning})\n";
    print "PM2.5: $aq->{pm2.5} µg/m³\n";
}

Dependencies

  • LWP::UserAgent: For HTTP requests.
  • JSON::MaybeXS: For parsing API responses.
  • URI::Escape: For URL encoding.
  • Schedule::RateLimiter: Optional, for rate limiting.

Notes

  • The module gracefully handles missing dependencies or failed initializations.
  • Rate limiting is optional; if Schedule::RateLimiter fails, the module proceeds without it.
  • Comprehensive error messages aid debugging (e.g., invalid tokens, unknown stations).

Conclusion

The Ozon3 module is a reliable tool for developers needing air quality data in Perl applications. Its robust error handling and flexible design make it suitable for both small scripts and large systems.

Source: Adapted from the Ozon3 Python library by Ozon3Org.

Auto