Can someone help me set up Sublime Text 2 for papyrus?

Post » Mon Nov 19, 2012 4:11 am

I'm fairly new to scripting/programming in general and I really want to use Sublime because it just seems so comfortable to use.

So I was assuming that you could set up a compile thing inside the editor like you can do with Notepad++ and I've looked at http://www.creationkit.com/Sublime_Text_Setupbut that doesn't really show me how to set up the compiler for sublime. Papyrus shows up as a build inside sublime and some of the functions change in font styles and colors like it's supposed to but attempting to build a .psc file does nothing it seems since it doesn't even give me any errors(when I intentionally put some in)

So I saw this: http://www.creationkit.com/Papyrus_Compiler_Reference
But I don't understand that tutorial at all nor do I even know if it's what I'm looking for.

What I'm trying to do basically is:
Being able to press a button/keyboard shortcut inside Sublime Text 2 and have it tell me if there are any errors with the scripts and if not then generate the .pex file in the data/scripts folder.

Help please? :(
User avatar
carley moss
 
Posts: 3331
Joined: Tue Jun 20, 2006 5:05 pm

Post » Mon Nov 19, 2012 10:08 am

It looks like the Papyrus package available via the wiki has been updated last month, but the new version gives me problems too. Try downloading this version: http://www.creationkit.com/images/archive/3/33/20120814182210%21Papyrus.zip

Cipscis
User avatar
GabiiE Liiziiouz
 
Posts: 3360
Joined: Mon Jan 22, 2007 3:20 am

Post » Mon Nov 19, 2012 2:29 am

Hmm that seems to have fixed the initial problem(and thanks for that :D). But now it's trying to find the compiler batch file in the wrong directory.



[Error 2] The system cannot find the file specified[cmd:  [u'C:\\Program Files (x86)\\Steam\\steamapps\\common\\skyrim\\Papyrus compiler\\ScriptCompile.bat', u'D:\\Steam\\steamapps\\common\\skyrim\\Data\\Scripts\\Source\\wzSublimeTest.psc']][dir:  D:\Steam\steamapps\common\skyrim\Data\Scripts\Source][path: %CommonProgramFiles%\Microsoft Shared\Windows Live;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live][Finished]
It's not located in program files. My skyrim directory looks like this:
D:\Steam\steamapps\common\skyrim

Where can I change this?
User avatar
Hearts
 
Posts: 3306
Joined: Sat Oct 20, 2007 1:26 am

Post » Mon Nov 19, 2012 5:41 am

I decided to copy the papyrus compiler folder to the default directory so that it thinks that my skyrim client is there and it seemed to have worked because the .pex file got created in my actual skyrim directory.

That means everything works right?
User avatar
Music Show
 
Posts: 3512
Joined: Sun Sep 09, 2007 10:53 am

Post » Mon Nov 19, 2012 8:48 am

You want to look for this file to set the path for your ScriptCompile.bat file:
C:\Users\Username\AppData\Roaming\Sublime Text 2\Packages\Papyrus\Papyrus.sublime-build

If moving the compiler has worked then, cool, it worked, but it's probably cleaner to keep in with the rest of the Creation Kit and scripts.

Cipscis
User avatar
Kristina Campbell
 
Posts: 3512
Joined: Sun Oct 15, 2006 7:08 am

Post » Sun Nov 18, 2012 8:52 pm

It's worth noting that, if you want to keep a clean script development folder outside of your Skyrim installation directory, you can set up your Sublime Text build system to work with that. Here's how I've done it (with paths that would be different for you in ):
Papyrus.sublime-build
{	"cmd": [		"ScriptCompile.bat",		"$file"	],	"working_dir": "${file_path/Source/./}",	"file_regex": "(^.*\\.psc)\\(([0-9]*),([0-9]*)\\)",	"selector": "source.papyrus"}
ScriptCompile.bat:
"PapyrusCompiler.exe" %1 -f="TESV_Papyrus_Flags.flg" -i="Source;" -o="." -keepasm"PapyrusCompiler.exe" %1 -f="TESV_Papyrus_Flags.flg" -i="Source;" -o="" -keepasm
Multiple output folders can't be specified for the compiler, as far as I know, so I've taken the easy route and just compiled the script twice - first into my development directory and then into my Skyrim directory.

Cipscis
User avatar
Amy Siebenhaar
 
Posts: 3426
Joined: Fri Aug 10, 2007 1:51 am

Post » Mon Nov 19, 2012 2:08 am

Alright thanks so much! I'll definitely note this :D
User avatar
Jarrett Willis
 
Posts: 3409
Joined: Thu Jul 19, 2007 6:01 pm

Post » Mon Nov 19, 2012 4:13 am

Hey there, folks!

So when I set up the new Papyrus build system, I *thought* I was ultimately making things easier on you guys, but it seems like it actually made it harder if you don't have a standardized Steam install. :-(

BUT -- the new system was designed to be flexible above all else. It was made to deal with the lessons learned from working on DLC with its various script directories and so forth. So the good news is, you can still use it without having to go back to the nasty batch file which gets overwritten when we patch the game.

What you'll need to do: Make a file in your My Documents folder called "SublimePapyrus.ini". In that file, you'll need values for the scripts path, the compiler location, the output directory, and the flags file. Here is what it would look like if your Steam installation was in a standard spot on a Windows 7 machine:

[Skyrim]scripts=C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Sourcecompiler=C:\Program Files (x86)\Steam\steamapps\common\skyrim\Papyrus Compiler\PapyrusCompiler.exeoutput=C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scriptsworkspace=flags=TESV_Papyrus_Flags.flg

(Note you can probably leave the "workspace" value out since you're not using Perforce, but for the sake of completeness, there it is.)

So all you'd have to do is make those values point to the appropriate places on your machine, and the new build system will know where it's being compiled and do the right thing when you tell it to build.

The system tries to fill in these values by default so that most modders don't have to use the custom ini file, but I should have figured that all you clever folks would have tweaked setups with stuff in non-standard locations. :-)

Let me know if this makes sense or doesn't make sense or still breaks or whatever.

Happy modding!

- Shane
User avatar
Queen of Spades
 
Posts: 3383
Joined: Fri Dec 08, 2006 12:06 pm

Post » Mon Nov 19, 2012 7:00 am

Thanks for the explanation, I'll try this out now :)

Would I use the same syntax as with the batch file to specify multiple locations (i.e. separate them via a semicolon)? Currently I have different source directories named "Native", "Vanilla", "SKSE", as well as a separate location for each project.

Cipscis
User avatar
Ash
 
Posts: 3392
Joined: Tue Jun 13, 2006 8:59 am

Post » Sun Nov 18, 2012 11:04 pm

Thanks for the explanation, I'll try this out now :smile:

Would I use the same syntax as with the batch file to specify multiple locations (i.e. separate them via a semicolon)? Currently I have different source directories named "Native", "Vanilla", "SKSE", as well as a separate location for each project.

Cipscis

Ah ha! That's where the new system *really* shines.

You can make new sections in that same ini file, and the build system will detect *where* you are compiling and use the appropriate settings. So, you could have:

[Skyrim]scripts=C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Sourcecompiler=C:\Program Files (x86)\Steam\steamapps\common\skyrim\Papyrus Compiler\PapyrusCompiler.exeoutput=C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scriptsworkspace=flags=TESV_Papyrus_Flags.flg [SKSE]scripts=C:\Projects\SKSE\Skyrim\Data\Scripts\Sourcecompiler=C:\Projects\SKSE\Skyrim\Papyrus Compiler\PapyrusCompiler.exeoutput=C:\Projects\SKSE\Skyrim\Data\Scriptsworkspace=flags=TESV_Papyrus_Flags.flg

Then when you tell Sublime to compile a file, it will look through all of these sections to see if it's located in one of the "scripts" directories, then use the settings from that section for the compilation.

In my experience with working on the DLC while also working on the patches (in a separate project branch) this was tremendously handy. Hopefully it is for you folks as well.
User avatar
Alex Blacke
 
Posts: 3460
Joined: Sun Feb 18, 2007 10:46 pm

Post » Mon Nov 19, 2012 2:29 am

Oh, cool! Here's what I had for my batch file build system on this computer (which doesn't have Skyrim or the CK installed):
Spoiler
{	"cmd": [		"C:\\Users\\mark.hanna\\Dropbox\\Cipscis\\Skyrim\\Papyrus Compiler\\ScriptCompileWork.bat",		"$file"	],	"working_dir": "${file_path/Source/./}",	"file_regex": "(^.*\\.psc)\\(([0-9]*),([0-9]*)\\)",	"selector": "source.papyrus"}
And the batch file itself:
Spoiler
"C:\Users\mark.hanna\Dropbox\Cipscis\Skyrim\Papyrus Compiler\PapyrusCompiler.exe" %1 -f="TESV_Papyrus_Flags.flg" -i="Source;D:\Users\mark.hanna\Documents\Papyrus\Dawnguard;D:\Users\mark.hanna\Documents\Papyrus\Vanilla;D:\Users\mark.hanna\Documents\Papyrus\SKSE;D:\Users\mark.hanna\Documents\Papyrus\Native" -o="." -keepasm
This has let me always use the 4 libraries I've got set up as well as the source for my current project, and then output the compiled script either in the same directory as its source or, if that directory is named "Source", in its parent directory.

Is there a way I could set up this new build system so I could have it instantly work with any new project directory and always import scripts from multiple locations like this?

Cipscis
User avatar
Dalia
 
Posts: 3488
Joined: Mon Oct 23, 2006 12:29 pm

Post » Mon Nov 19, 2012 10:05 am

Hmmmm. Not at present -- it's designed around the idea of setting up a project as a relatively rare event. Makes a lot of sense for us; maybe not as much for you. It's pretty easy to add more sections to that INI file as need be, but I'm not sure about making is smart enough to just guess where to put things. (I mean, it definitely *could* -- it's just a Python script; it can do whatever we need it to do), but I'm curious how common your use case is of wanting to do more ad-hoc project things.
User avatar
April D. F
 
Posts: 3346
Joined: Wed Mar 21, 2007 8:41 pm

Post » Mon Nov 19, 2012 9:16 am

I expect I'm probably a special case, since I often make tiny little projects that never get released just to tinker. In all honesty I'd probably be better off just having a persistent "Experiments" project folder or something.

I quite like having my source libraries kept separate, though, especially with SKSE overriding some of the native scripts. Would something like this work, or would the Python script need to be changed in order to support it?
scripts=D:\Users\mark.hanna\Documents\Papyrus\Dawnguard;D:\Users\mark.hanna\Documents\Papyrus\Vanilla;D:\Users\mark.hanna\Documents\Papyrus\SKSE;D:\Users\mark.hanna\Documents\Papyrus\Native
Cipscis

EDIT:

Just confirming I've been able to get this working with my setup, using the following to compile a Test.psc file in D:\Users\mark.hanna\Documents\Papyrus\Test\Source with separate folders for Dawnguard, Native, SKSE, and Vanilla scripts as I mentioned before:
Spoiler
[Test]scripts=D:\Users\mark.hanna\Documents\Papyruscompiler=C:\Users\mark.hanna\Dropbox\Cipscis\Skyrim\Papyrus Compiler\PapyrusCompiler.exeoutput=D:\Users\mark.hanna\Documents\Papyrus\Testworkspace=flags=TESV_Papyrus_Flags.flg
Cipscis
User avatar
Devils Cheek
 
Posts: 3561
Joined: Sun Aug 13, 2006 10:24 pm

Post » Mon Nov 19, 2012 6:26 am

Instead of putting all of them on one line, you'd want to split them out into different sections of the ini file.

Spoiler

[Dawnguard]scripts=D:\Users\mark.hanna\Documents\Papyrus\Dawnguardcompiler=(whatever)output=(wherever)workspace=flags=TESV_Papyrus_Flags.flg[Vanilla]scripts=D:\Users\mark.hanna\Documents\Papyrus\Vanillacompiler=(whatever)output=(wherever)workspace=flags=TESV_Papyrus_Flags.flg[SKSE]scripts=D:\Users\mark.hanna\Documents\Papyrus\SKSEcompiler=(whatever)output=(wherever)workspace=flags=TESV_Papyrus_Flags.flg[Native]scripts=D:\Users\mark.hanna\Documents\Papyrus\Nativecompiler=(whatever)output=(wherever)workspace=flags=TESV_Papyrus_Flags.flg
User avatar
Sunny Under
 
Posts: 3368
Joined: Wed Apr 11, 2007 5:31 pm

Post » Mon Nov 19, 2012 11:24 am

Oh, I think I see now. Sorry, I hadn't understood you before.

Just to make sure I understand now, am I right that it will tell the compiler to look in all of the "script" directories listed, and then pick the compiler and output folders depending on which of the script directories the current script is in?

Cipscis
User avatar
Joanne
 
Posts: 3357
Joined: Fri Oct 27, 2006 1:25 pm

Post » Mon Nov 19, 2012 10:48 am

Just to make sure I understand now, am I right that it will tell the compiler to look in all of the "script" directories listed, and then pick the compiler and output folders depending on which of the script directories the current script is in?
Correct.
User avatar
alicia hillier
 
Posts: 3387
Joined: Tue Feb 06, 2007 2:57 am

Post » Mon Nov 19, 2012 6:38 am

And bear in mind that the names of the sections don't mean anything -- they're just for you to know what each one means. Important that they're there as separators, and important that they're unique, but otherwise, you can put whatever you want in the brackets.
User avatar
Danial Zachery
 
Posts: 3451
Joined: Fri Aug 24, 2007 5:41 am

Post » Sun Nov 18, 2012 8:26 pm

Cool, I'll give it a go with that setup then.

Is there any way to get the compiler output in Sublime like with the batch file? Currently the white output view (not sure what it's called) still pops up when I run the build system, but now it stays empty whereas before it would show output from the compiler, including compilation errors.

Cipscis
User avatar
Killer McCracken
 
Posts: 3456
Joined: Wed Feb 14, 2007 9:57 pm

Post » Sun Nov 18, 2012 8:34 pm

Hmm, I may have messed it up before. I think the compiled script I saw was already there before I'd attempted to try the new build system. Pretty stupid mistake, I know...

Anyway, now I've got the following set up for my SublimePapyrus.ini file:
Spoiler
[Test]scripts=D:\Users\mark.hanna\Documents\Papyrus\Test\Sourcecompiler=C:\Users\mark.hanna\Dropbox\Cipscis\Skyrim\Papyrus Compiler\PapyrusCompiler.exeoutput=D:\Users\mark.hanna\Documents\Papyrus\Testworkspace=flags=TESV_Papyrus_Flags.flg[Dawnguard]scripts=D:\Users\mark.hanna\Documents\Papyrus\Dawnguardcompiler=output=workspace=flags=TESV_Papyrus_Flags.flg[Vanilla]scripts=D:\Users\mark.hanna\Documents\Papyrus\Vanillacompiler=output=workspace=flags=TESV_Papyrus_Flags.flg[SKSE]scripts=D:\Users\mark.hanna\Documents\Papyrus\SKSEcompiler=output=workspace=flags=TESV_Papyrus_Flags.flg[Native]scripts=D:\Users\mark.hanna\Documents\Papyrus\Nativecompiler=output=workspace=flags=TESV_Papyrus_Flags.flg
However, when attempt to compile my Test.psc file Sublime gives the following status message:
No configuration for D:\Users\mark.hanna\Documents\Papyrus\Test\Source
This is definitely the path I've put in the ini file, though, and definitely the folder for the script I'm trying to compile.

Any idea what might be the problem here? I've tried adding values for "compiler" and "output" for the other sections, but as I thought that didn't seem to change anything.


Cipscis
User avatar
c.o.s.m.o
 
Posts: 3419
Joined: Sat Aug 12, 2006 9:21 am

Post » Mon Nov 19, 2012 4:58 am

Sorry, disregard my last 2 posts. Seems I'm full of stupid mistakes at the moment, perhaps it's time for a break :P

Cipscis
User avatar
Russell Davies
 
Posts: 3429
Joined: Wed Nov 07, 2007 5:01 am

Post » Mon Nov 19, 2012 10:10 am

Okay, I've tried again and it looks like it's not working as I'd expected. Here's my SublimePapyrus.ini file:
Spoiler
[Native]scripts=D:\Users\mark.hanna\Documents\Papyrus\Nativecompiler=output=workspace=flags=TESV_Papyrus_Flags.flg[SKSE]scripts=D:\Users\mark.hanna\Documents\Papyrus\SKSEcompiler=output=workspace=flags=TESV_Papyrus_Flags.flg[Vanilla]scripts=D:\Users\mark.hanna\Documents\Papyrus\Vanillacompiler=output=workspace=flags=TESV_Papyrus_Flags.flg[Dawnguard]scripts=D:\Users\mark.hanna\Documents\Papyrus\Dawnguardcompiler=output=workspace=flags=TESV_Papyrus_Flags.flg[Test]scripts=D:\Users\mark.hanna\Documents\Papyrus\Test\Sourcecompiler=C:\Users\mark.hanna\Dropbox\Cipscis\Skyrim\Papyrus Compiler\PapyrusCompiler.exeoutput=D:\Users\mark.hanna\Documents\Papyrus\Testworkspace=flags=TESV_Papyrus_Flags.flg
Now when I try to compile Test.psc, which exists within the scripts directory for [Test], it doesn't find the scripts in all the other locations.

What I've done to fix it is make a slight change to the Python script and the structure of my ini file. Here's the change I made to the Python script (line 80):
Spoiler
if ('import' in config):    args["cmd"].append('-i=%s' % config['scripts'] + ';' + config['import'])else:    args["cmd"].append('-i=%s' % config['scripts'])
Here's the new SublimePapyrus.ini file I'm using:
Spoiler
[Test]scripts=D:\Users\mark.hanna\Documents\Papyrus\Test\Sourceimport=D:\Users\mark.hanna\Documents\Papyrus\Dawnguard;D:\Users\mark.hanna\Documents\Papyrus\Vanilla;D:\Users\mark.hanna\Documents\Papyrus\SKSE;D:\Users\mark.hanna\Documents\Papyrus\Nativecompiler=C:\Users\mark.hanna\Dropbox\Cipscis\Skyrim\Papyrus Compiler\PapyrusCompiler.exeoutput=D:\Users\mark.hanna\Documents\Papyrus\Testflags=TESV_Papyrus_Flags.flg

Is that a decent way to do what I'm trying to do (import from various different script libraries located elsewhere)? As far as I can tell it doesn't break anything, and the "import" section can be left blank or omitted completely if it's not required. Remove the "workspace" section doesn't seem to have broken anything either.

Cipscis
User avatar
Joanne
 
Posts: 3357
Joined: Fri Oct 27, 2006 1:25 pm

Post » Mon Nov 19, 2012 2:41 am

I'm not sure what you're doing with this "import" directive -- is that an SKSE thing?
User avatar
lillian luna
 
Posts: 3432
Joined: Thu Aug 31, 2006 9:43 pm

Post » Mon Nov 19, 2012 5:48 am

No, the Papyrus Compiler is able to use multiple "import" directories, so long as they're separated by semicolons. This is basically telling it to look in all of my different libraries, since I don't have all my Papyrus source in the same place.

The way the Python script was set up (as far as I could tell with my limited Python experience) it would only ever pass a single import directory to the compiler, so unless all my source files were in the same place it wouldn't work. This change lets me tell it where my source is, like before, and then go on to tell it to also import the Papyrus source from those other directories as well. For the list of import directories, earlier directories have higher priority, which is why the current directory is first and I put my SKSE directory before Native.

This behaviour is described when you run PapyrusCompiler.exe with the -? parameter:
Spoiler
Usage:PapyrusCompiler  []  object     Specifies the object to compile. (-all is not specified)  folder     Specifies the folder to compile. (-all is specified)  arguments  One or more of the following:   -debug|d    Turns on compiler debugging, outputting dev information to the screen.   -optimize|op    Turns on optimization of scripts.   -output|o=    Sets the compiler's output directory.   -import|i=    Sets the compiler's import directories, separated by semicolons.   -flags|f=    Sets the file to use for user-defined flags.   -all|a    Invokes the compiler against all psc files in the specified directory    (interprets object as the folder).   -quiet|q    Does not report progress or success (only failures).   -noasm    Does not generate an assembly file and does not run the assembler.   -keepasm    Keeps the assembly file after running the assembler.   -asmonly    Generates an assembly file but does not run the assembler.   -?    Prints usage information.
Cipscis
User avatar
Timara White
 
Posts: 3464
Joined: Mon Aug 27, 2007 7:39 am

Post » Sun Nov 18, 2012 10:56 pm

Oh oh oh oh. Sorry, I didn't realize you were passing that directly to the compiler. My bad.

Yeah, that's one more thing we don't really use much internally. Let me think about how that's structured and the best way to handle it. Your patch might be that way, but it might be something more fundamental. Thanks for pointing that out.
User avatar
Shirley BEltran
 
Posts: 3450
Joined: Wed Jul 26, 2006 4:14 pm


Return to V - Skyrim