I wrote a PHP script that could allow you to load the map (in Amnesia) of the script that you're currently working on from an editor that supports executing external programs where the absolute path of the directory that the HPS is stored in and the file name of the HPS file can be passed as arguments to the external program, like Geany or Notepad++. Since this script is written in PHP, you'll need to install the PHP package on your system if it's not already on there.
Information on the script
Currently the script only works on Vista-like operating systems and possibly Linux (i.e. i've only tested it in Windows 7, though it has code that supports Linux). Also, you require to have a "dev_user" Amnesia profile for this script to work. This script modifies the dev_user's user_settings.cfg file in order to specify map folder, file and start position. This script also modifies the main campaign's main_settings.cfg file, forcing ShowMenu to equal "false".
Following the description of the Map element of user_settings.cfg from the wiki, this script creates a new folder (if it doesn't already exist) called "CustomStoryTests" under <Amnesia>/maps. Upon launching the script it'll copy over the map and hps file to that folder, which the game will then load. Files in this folder can be safely deleted or edited; if the script (i.e. PHP) finds a file with the same name, it'll get overwritten anyway when this PHP script is executed again. Do note, though, that you should have the custom_stories folder listed in the resources.cfg file, or else your custom resources may not load when the map is loaded.
This script uses the path provided to it to determine the location of the Amnesia binary executable. Therefore it
should work regardless of the edition of Amnesia you have.
Argument flags
-f: (Required) Filename + extension of the HPS file.
-d: (Required) Absolute directory path of the HPS file.
-p: (Optional) PlayerStart area name. (The script will assume "PlayerStartArea_1" if none is passed.)
Geany command example (Windows):
Command: php "Drive_Letter:\full\path\to\name_of_script.php" -f "%f" -d "%d"
Current working directoy: Drive_Letter:\full\path\to\PHP
Note: Geany normally stores commands per file. Creating a project in Geany might distribute the command for all the files in the project, but i've never created a project in Geany before, so i'm not sure on that.
Notepad++ command example (Windows):
Run command: "Drive_Letter:\full\path\to\php.exe" "Drive_Letter:\full\path\to\name_of_script.php" -f "$(FILE_NAME)" -d "$(CURRENT_DIRECTORY)"
The script
<?php
$opts = getopt("f:d:p::");
if (!$opts['f'] || !$opts['d'])
{
exit("Both file and directory must be provided.\n");
}
function get_home_path()
{
// Windows
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
{
define('ACTIVE_OS', 'WIN');
return getenv('HOMEDRIVE').getenv('HOMEPATH');
}
// Mac
else if (strtoupper(substr(PHP_OS, 0, 6)) == 'DARWIN' ||
strtoupper(substr(PHP_OS, 0, 3)) == 'MAC')
{
define('ACTIVE_OS', 'MAC');
return getenv('HOME');
}
// *nix
else
{
define('ACTIVE_OS', 'OTHER');
return getenv('HOME');
}
}
define("MAP_FILE", str_replace('.hps', '.map', $opts['f']));
define("HOME", get_home_path());
define("CUSTOM_STORY_MAPS", "CustomStoryTests");
define("PLAYER_START_AREA", ($opts['p']) ? $opts['p'] : "PlayerStartArea_1");
if (ACTIVE_OS == "WIN")
{
$dev_user_path = HOME . "\\Documents\\Amnesia\\Main\\dev_user\\";
$main_path = HOME . "\\Documents\\Amnesia\\Main\\";
}
else
{
$dev_user_path = HOME . "/.frictionalgames/Amnesia/Main/dev_user/";
$main_path = HOME . "/.frictionalgames/Amnesia/Main/";
}
if (file_exists($dev_user_path))
{
define('DEV_USER', $dev_user_path);
define('MAIN_DIR', $main_path);
}
if (!defined('DEV_USER'))
{
exit('Could not find dev_user directory.');
}
$pos = strpos($opts['d'], DIRECTORY_SEPARATOR . 'custom_stories');
if ($pos == false)
{
exit('Could not parse directory ' . $opts['d'] . "\n");
}
$root = substr($opts['d'], 0, $pos);
if (!file_exists($root))
{
exit("Could not find Amnesia's root folder.\n" . $opts['d']."\n");
}
define('ROOT_DIR', $root);
$cs = ROOT_DIR . DIRECTORY_SEPARATOR . 'maps' . DIRECTORY_SEPARATOR . CUSTOM_STORY_MAPS;
// Create CUSTOM_STORY_MAPS folder.
if (!file_exists($cs))
{
if (!mkdir($cs, 0644, true))
{
exit('Could not create '. CUSTOM_STORY_MAPS .' directory.');
}
}
// Make ShowMenu = "false"
if (file_exists(MAIN_DIR . 'main_settings.cfg'))
{
if ($contents = file_get_contents(MAIN_DIR . 'main_settings.cfg'))
{
file_put_contents(MAIN_DIR . 'main_settings.cfg', str_replace('ShowMenu="true"', 'ShowMenu="false"', $contents));
}
}
if (!file_exists(DEV_USER . 'user_settings.cfg'))
{
exit('The file "user_settings.cfg" does not exist for user "dev_user".');
}
$user_settings = file_get_contents(DEV_USER . 'user_settings.cfg');
$user_settings = preg_replace('/<Map File="[^"]*" Folder="[^"]*" StartPos="[^"]*" \/>/',
'<Map File="'. MAP_FILE .'" Folder="'. CUSTOM_STORY_MAPS .'/" StartPos="'. PLAYER_START_AREA .'" />',
$user_settings);
if (file_put_contents(DEV_USER . 'user_settings.cfg', $user_settings) == false)
{
exit('Could not write to user_settings.cfg');
}
// Copy over the HPS file.
file_put_contents($cs . DIRECTORY_SEPARATOR . $opts['f'], file_get_contents($opts['d'] . DIRECTORY_SEPARATOR . $opts['f']));
// Copy over the MAP file.
file_put_contents($cs . DIRECTORY_SEPARATOR . MAP_FILE, file_get_contents($opts['d'] . DIRECTORY_SEPARATOR . MAP_FILE));
chdir(ROOT_DIR);
if (ACTIVE_OS == "WIN")
{
if (file_exists(ROOT_DIR . "\\Amnesia.exe"))
{
passthru(ROOT_DIR . "\\Amnesia.exe");
}
else
{
exit("Amnesia could not be executed.");
}
}
else if (ACTIVE_OS == "OTHER")
{
if (file_exists(ROOT_DIR . "/Amnesia.bin"))
{
passthru(ROOT_DIR . "/Amnesia.bin");
}
else
{
if (file_exists(ROOT_DIR . "/Amnesia.bin64"))
{
passthru(ROOT_DIR . "/Amnesia.bin64");
}
else
{
exit('Amnesia could not be executed.');
}
}
}
?>