Jump to content

Compiling papyrus in namespaces


Recommended Posts

Used papyrus namespaces long time ago, but stopped because ... can't remember.

 

I need to edit some DLC scripts to add debug tracing and also can't remember how to get the compiler to work with namespaces. Yeah, memory issues.

 

Script File Name: Data\Scripts\Source\DLC01\DLC01_MechanistDoorControlScript.psc

Header: ScriptName DLC01:DLC01_MechanistDoorControlScript extends ObjectReference Hidden

Compile batchfile -i includes the path Data\Scripts\Source\DLC01

 

Run the compile batchfile and get the error:

 

filename does not match script name: "dlc01:dlc01_mechanistdoorcontrolscript" expected: "DLC01_MechanistDoorControlScript"

 

Since DOS filenames cant have a colon ( : ) TWO DOTS symbol in them, whats missing ?

Link to comment
Share on other sites

usual compiler run argument is something like:

-i="C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User;C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\Base"

You are trying to compile file in \Source\DLC01

 

One option : add path to \Source folder to -i argument. I didn't try it, and possibly you will need to replace path to \Source\User by path to \Source

 

Another option: put compiling content of DLC01 folder to \Source\User\DLC01

Edited by DlinnyLag
Link to comment
Share on other sites

I have alrady tried that:

 

Compile batchfile -i includes the path Data\Scripts\Source\DLC01

 

plus Data\Scripts\Source\User\DLC01

plus Data\Scripts\Source\Base\DLC01

 

no difference.

 

 

 

@echo off
cls
echo ********************************************** 
echo Papyrus debug compile of %1
echo ********************************************** 
echo.

set FLAGS=C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\Base\Institute_Papyrus_Flags.flg

set IMPORT1=C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User
set IMPORT2=C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\Base
set IMPORT3=C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\DLC01

set OUTPUT=C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts
 
"C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Papyrus Compiler\PapyrusCompiler.exe" %1 -f="%FLAGS%" -i="%IMPORT1%;%IMPORT2%;%IMPORT3%" -o="%OUTPUT%"

pause

 

 

Link to comment
Share on other sites

I'm looking to decompiled method

private static string CalculateRelativeObjectName(string asFullPath, List<string> akImportFolders)
	{
		string fileName = Path.GetFileName(asFullPath);
		foreach (string akImportFolder in akImportFolders)
		{
			string text = akImportFolder;
			if (!Path.IsPathRooted(text))
			{
				text = PathCanonicalize(Path.Combine(Directory.GetCurrentDirectory(), text));
			}
			if (asFullPath.Length <= text.Length)
			{
				continue;
			}
			string text2 = asFullPath.Substring(0, text.Length);
			if (text2.Equals(text, StringComparison.InvariantCultureIgnoreCase))
			{
				fileName = asFullPath.Substring(text.Length);
				if (fileName[0] == '\\' || fileName[0] == '/')
				{
					return fileName.Substring(1);
				}
				return fileName;
			}
		}
		return fileName;
	}

And as I understand, to get the correct namespace you have to set one of imports to C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source

so, it will be used as root path to detect subfolder that interpreted as namespace

Edited by DlinnyLag
Link to comment
Share on other sites

Still getting filename does not match script name: "dlc01:dlc01_mechanistdoorcontrolscript" expected: "DLC01_MechanistDoorControlScript"

 

placing the file in each file location with all the import locations -included:

 

set IMPORT0=C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source
set IMPORT1=C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User
set IMPORT2=C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\Base
set IMPORT3=C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\DLC01
set IMPORT4=C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC01
Link to comment
Share on other sites

 

placing the file in each file location with all the import locations -included:

It will not work if you will set \Scripts\Source\User\DLC01 as the import and try to compile file in this folder

 

The option that should work:

- Leave 2 imports only

set IMPORT1=C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User
set IMPORT2=C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\Base

- Copy file(s) to compile to C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\DLC01

and compile

Link to comment
Share on other sites

Without including Data\Scripts\Source\User\DLC01 in the compiler path, the error is as expected:

 

<unknown>(0,0): unable to locate script DLC01_MechanistDoorControlScript

 

Lets stop with the pathing now and see if someone actually KNOWS how to compile namespace scripts :wink:

Link to comment
Share on other sites

Appreciated, unfortuantly the command window is closing down (CTD !) on the evaluation line

 

If !Path_to_convert! == !Reference_path! (

 

although the variables all report fine just before that:

 

echo BasePath %BasePath%
echo Reference_path %Reference_path%
echo Path_to_convert %Path_to_convert%
BasePath C:\Program Files (x86)\Steam\steamapps\common\Fallout 4
Reference_path C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User
Path_to_convert C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User
Anyhoo its not using any different paths to those that I have been working with.
It would still be useful to understand what is necesary to compile in namespaces, but I have simply written my own scripts and stuck 'em on the DLC objects via aliases as per usual to workaround without hacking base game or making master dependencies.
Link to comment
Share on other sites

If I recall correctly all your script needs to do is:

- run from the Data\Scripts\Source\User folder

- pass the relative path to the .psc source file as parameter of the compiler

 

Let's say your source script is located at C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User\MyNameSpace\MyScript.psc

Your "Start path" should be "C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User"

So first enter to drive C

C

then change to the User directory

cd "C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\Scripts\Source\User"

and finally call to the compiler using the relative path to the script (MyNameSpace\MyScript.psc) as the first argument:

"C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Papyrus compiler\PapyrusCompiler.exe" "MyNameSpace\MyScript.psc" -f="Institute_Papyrus_Flags.flg" -i="C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\scripts\Source\Base" -o="C:\Program Files (x86)\Steam\steamapps\common\Fallout 4\Data\scripts"
Edited by DieFeM
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...