Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support |

• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 Load map from text editor Author Message
SCAN ME!

Posts: 3,475
Joined: Jul 2011
Reputation: 235
 Post: #1 Load map from text editor 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 /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 Code: (Select All) /',                                         '',                                         $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.');        }    }}?> Tutorials: From Noob to Pro (This post was last modified: 05-03-2012 08:10 PM by Your Computer.)
05-03-2012 10:14 AM
Cranky Old Man
Posting Freak

Posts: 989
Joined: Apr 2012
Reputation: 38
 Post: #2 RE: Load map from text editor Wow! That's a lot of work behind being able to push a button. Hopefully I have PHP installed - I can't remember. Thanks! Noob scripting tutorial: From Noob to Pro (This post was last modified: 05-03-2012 10:47 AM by Cranky Old Man.)
05-03-2012 10:47 AM
SCAN ME!

Posts: 3,475
Joined: Jul 2011
Reputation: 235
 Post: #3 RE: Load map from text editor Made a slight modification to the current script. Should fix any issues running the retail edition. Tutorials: From Noob to Pro
05-03-2012 10:48 AM
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)