The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Archive::SCS::GameDir - Find the game dir and mount its archives

SYNOPSIS

my $scs = Archive::SCS::GameDir->new->mounted;
# $scs isa Archive::SCS

my $path = Archive::SCS::GameDir->new(game => 'ATS')->path;
# $path isa Path:Tiny

my $gd = Archive::SCS::GameDir->new;
my @files = grep !/^dlc_/, $gd->archives;
my $scs = $gd->mounted( @files, 'dlc_ks.scs', 'dlc_ok.scs' );

# Custom paths
$gd->set_library_paths( @steam_library_paths );
my $path = $gd->find('ATS')->path;
my $scs = $gd->find('/path/to/gamedir')->mounted;

DESCRIPTION

Finds the game install directory inside your home directory.

A number of default locations for the Steam library will be searched first. If your Steam library is in a non-standard location, there are four different ways in which you can supply additional paths to search:

  • Specify the list of search paths for an individual GameDir object using the set_library_paths() object method. Call find() afterwards.

  • Manipulate the existing default list of search paths in the @Archive::SCS::GameDir::LIBRARY_PATHS global variable.

  • Install a custom Archive::SCS::GameDir::Steam module that sets the global variable @library_paths.

  • Set the STEAM_LIBRARY environment variable.

METHODS

archives

@files = $gamedir->archives;

Returns the list of filenames found in the game directory.

find

$gamedir = $gamedir->find;
$gamedir = $gamedir->find('ATS');
$gamedir = $gamedir->find('/path/to/gamedir');

Tries to find the game directory for the given game in the current Steam library paths. Will modify the object state. Use game() / game_short() / path() to read the result.

If there are multiple game directories in the paths, the search stops at the first one found.

game

$full_name = $gamedir->game;

Returns the full name of the game directory, or undef if the search was unsuccessful.

game_short

$abbreviation = $gamedir->game_short;

Returns an abbreviation for the game name (like ATS), or undef if the search was unsuccessful.

library_paths

@steam_paths = $gamedir->library_paths;

Returns the current list of paths to search for the Steam library.

mounted

$scs = $gamedir->mounted;
$scs = $gamedir->mounted(@files);

Returns a new Archive::SCS object with all files found in the game directory already mounted. If a list of filenames is given, only those files will be mounted.

new

$gamedir = Archive::SCS::GameDir->new;
$gamedir = Archive::SCS::GameDir->new(game => 'ATS');
$gamedir = Archive::SCS::GameDir->new(game => '/path/to/gamedir');

Creates a new Archive::SCS::GameDir object. Will call find() with the given game as argument.

path

$path_tiny = $gamedir->path;

Returns a Path::Tiny object for the game directory, or undef if the search was unsuccessful.

set_library_paths

$gamedir = $gamedir->set_library_paths(@steam_paths);

Sets the list of paths to search for the Steam library. The Steam library is the directory containing the steamapps directory.

version

$installed_version = $gamedir->version;

Reads the game directory and reports the installed game version.

AUTHOR

nautofon

COPYRIGHT

This software is copyright (c) 2024 by nautofon.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.