Aller au contenu

Photo

Advanced Script Compiler for NWN2 release thread


  • Veuillez vous connecter pour répondre
116 réponses à ce sujet

#101
AGhost_7

AGhost_7
  • Members
  • 62 messages

Hello, I'm trying to get a little batch script working to simplify my workflow which will work from anywhere. My scripts are located in the campaign folder, I don't know if that could be causing any issue. I probably made a silly mistake here, not familiar with shell scripting all that much.

 

nwscript.bat:

@echo off

set installDir=C:\Program Files (x86)\Atari\Neverwinter Nights 2
set campaignFolder=C:\Users\Jonathan\Documents\Neverwinter Nights 2\campaigns\Realms of Trinity\
set returnDir=%cd%

cd %campaignFolder%

NWNScriptCompiler.exe -n "%installDir%" -b . *.NSS

cd %returnDir%
This is the message that I get:
NWNScriptCompiler - built Jan 29 2014 19:24:04
Copyright (C) 2008-2014 Skywing.
Portions copyright (C) 2002-2003, Edward T. Smith.
Portions copyright (C) 2003, The Open Knights Consortium.
Compiling: ag7_alpha_utils.NSS
Unable to load nwscript.nss
Failed to initialize compiler; compilation aborted.
Compilation aborted with errors.
Error: Failed to process file "ag7_alpha_utils.NSS".
Stopping processing on first error.
1 error(s); see above for context.
Processing aborted.
Total Execution time = 0ms
Tried even running this as admin and it gives me the same message.


#102
kevL

kevL
  • Members
  • 4 052 messages
does "C:\Program Files (x86)\Atari\Neverwinter Nights 2" need quotation marks, because of the space
... ie, maybe it thinks installDir is "C:\Program"

for reflection, here's what I use.

_asc.bat
for /r . %%1 in (.) do f:\asc -aglo -i .;F: -v1.69 -y "%%1\*.nss"

pause
NWNScriptCompiler.exe has been renamed 'asc.exe' and put in the root of F: along with a copy of 'nwscript.nss' (see -i argument)

i plop the .bat file into any dir I want to compile, and this does that dir + its subdirectories.

ps. took forever to get that recursion working acceptably. it seems to work better for me without -b, i tried with and without -- but your needs are likely different. What i need to do is get all my includes in one directory so that the -l argument could go away.

/hth

#103
AGhost_7

AGhost_7
  • Members
  • 62 messages

does "C:\Program Files (x86)\Atari\Neverwinter Nights 2" need quotation marks, because of the space
... ie, maybe it thinks installDir is "C:\Program"

My understanding is that the way I wrote it it will be fine. When you set variables like this it takes what you write "as is"; I made the mistake before of writing :

set direct= C:\Program Files (x86)\Atari\Neverwinter Nights 2

Which results in the space right after the equal sign to be included in the string. It does need the quotation marks for the call to the compiler, which I've added.

 

 

ps. took forever to get that recursion working acceptably. it seems to work better for me without -b, i tried with and without -- but your needs are likely different. What i need to do is get all my includes in one directory so that the -l argument could go away.


/hth

 

Yea, I've just got one big directory to compile here. Honestly I'd use your code but I'm wondering if there's a better way to do this.

 

edit: What does this -aglo argument do? I can't find it anywhere in the readme.

 

edit 2: Looks like I just got it about figured out thanks to your help kev!

 

nwscript.bat:

@echo off

set returnDir=%cd%

cd %campaignFolder%

if "%1" == "" (
  NWNScriptCompiler.exe -aglo -i . -v1.69 "*.nss"
) else (
  NWNScriptCompiler.exe -aglo -i . -v1.69 "%1.nss"
)

cd %returnDir%
Added it to my path, and now I can just type nwscript for a full directory compile(no subdirectories in my case), or a single specific file using nwscript <filename>(directory that I'm in doesn't matter for this script).


#104
kevL

kevL
  • Members
  • 4 052 messages

edit: What does this -aglo argument do? I can't find it anywhere in the readme.


run NWNScriptCompiler w/out arguments and it prints help.
-a : analyze for consistency
-g : no debug file
-l : load base game resources
-o : optimize



maybe have a look at these two posts:

http://forum.bioware...read/?p=5911693


as you see, i did away with -h and -n and use -l and -i

To the error message:
Unable to load nwscript.nss

I think ASC should find it w/ -n, and -l, but for some reason I keep a copy of nwscript.nss in a directory ref'd by -i (maybe because i have a tendency to run without -l every so often, i forget.) Have you tried parsing your .bat down to a minimum to get it working, then adding stuff till it borks? That is, is the fault definitely within the ASC commandline? ...

edit: looks like you need -l even when -n is spec'd ( unless, at a minimum, nwscript.nss is broken out w/ -i )

#105
kevL

kevL
  • Members
  • 4 052 messages

good stuff :mellow:



#106
AGhost_7

AGhost_7
  • Members
  • 62 messages

I saw that too, I guess I didn't make the connection that you could combine them like that.

 

edit: I think I've found a way to get this running through multiple processes.

 

nwscript.bat:

@echo off

set campaignFolder=C:\Users\Jonathan\Documents\Neverwinter Nights 2\campaigns\Realms of Trinity\
set returnDir=%cd%

if "%1" == "" (
   rem Spread load as evenly possible.
   start nwscriptpar n
   start nwscriptpar c
   start nwscriptpar gi
   start nwscriptpar quwy
   start nwscriptpar xo
   start nwscriptpar el_jtrpsfmbkdvzha
) else (
   cd %campaignFolder%
   NWNScriptCompiler.exe -aglo -i . -v1.69 "%1.nss"
   cd %returnDir%
)
nwscriptpar.bat:
 
@echo off

set campaignFolder=C:\Users\Jonathan\Documents\Neverwinter Nights 2\campaigns\Realms of Trinity\
set iter=%1?

cd %campaignFolder%

:start

set c=%iter:~0,1%
set iter=%iter:~1%
NWNScriptCompiler.exe -aglo -i . -v1.69 "%c%*.nss"

:: Olde school
if not "%iter%" =="?" goto start

exit
Now, this creates a new problem; how am I going to see the error output?


#107
Halgroth

Halgroth
  • Members
  • 10 messages

Hello! I have a few questions regarding the use of NWNScriptCompiler with NWN1 modules. I'm running the compiler on Ubuntu 14.04 x64 using Wine and it works as expected, but I'm trying to optimize the way I keep includes around.

 

I was hoping switches -1 -i would allow me to specify resource archives in order to avoid keeping extracted nss around, but I am having trouble compiling. Take for instance nwscript.nss contained in NWN/data/2da.bif. Is it possible to specify the [path to] .bif only? Example commands;

 

I.  ./NWNScriptCompiler.exe -1 -i ../../src/data/2da/* -v1.69 -q -g -e -o -b ../ncs test.nss

II. ./NWNScriptCompiler.exe -1 -i \"${nwn_installdir}/NWN/data/\" -v1.69 -q -g -e -o -b ../ncs test.nss

I. works since src/data/2da/ contains nwscript.nss, but II., which contains 2da.bif, fails.

 

Questions:

  1. What does -1 influence?
  2. What is the expected contents of pathspec directories?
  3. Can I use -i to reference resource archives or must it be extracted sources?
  4. If yes on 3; can it read .hak?
  5. If no on 3; can it be done using a different switch?

 

NWNScriptCompiler - built Jan 29 2014 19:24:04
Copyright © 2008-2014 Skywing.
Portions copyright © 2002-2003, Edward T. Smith.
Portions copyright © 2003, The Open Knights Consortium.
Usage:
NWNScriptCompiler [-1acdegjkloq] [-b batchoutdir] [-h homedir]
                  [[-i pathspec] ...] [-m resref] [-n installdir]
                  [-r modpath] [-v#] [-x errprefix] [-y]
                  infile [outfile|infiles]
  batchoutdir - Supplies the location at which batch mode places
                output files and enables multiple input filenames.
  homedir - Per-user NWN2 home directory (i.e. Documents\NWN2).
  pathspec - Semicolon separated list of directories to search for
             additional includes.
  resref - Resource name of module to load (without extension).
           Note that loading a module is potentially slow.
  installdir - Per-machine NWN2 install directory.
  modpath - Supplies the full path to the .mod (or directory) that
            contains the module.ifo for the module to load.  This
            option overrides the [-r resref] option.
  errprefix - Prefix string to prepend to compiler errors (replacing
              the default of "Error").
  -1 - Assume NWN1-style module and KEY/BIF resources instead of
       NWN2-style module and ZIP resources.
  -a - Analyze generated code and verify that it is consistent
       (increases compilation time).
  -c - Compile the script (default, overrides -d).
  -d - Disassemble the script (overrides -c).
  -e - Enable non-BioWare extensions.
  -g - Suppress generation of .ndb debug symbols file.
  -j - Show where include file are being sourced from.
  -k - Show preprocessed source text to console output.
  -l - Load base game resources even if -m isn't supplied (slow),
       so that "in-box" standard includes can be resolved.
  -o - Optimize the compiled script.
  -p - Dump internal PCode for compiled script contributions.
  -q - Silence most messages.
  -vx.xx - Set the version of the compiler.
  -y - Continue processing input files even on error.
 

PS: If there exists documentation other than the above executable dump I would be very happy to be pointed in the right direction.

PPS: Awesome compiler! TYVM!



#108
kevL

kevL
  • Members
  • 4 052 messages
i was hoping Skywing would see this sooner, because it deals with aspects I don't know about.

but i can make some comments about #include woes.

First, I suggest keeping a copy of nwscript.nss somewhere (other than inside any sort of packed file)

then, on your command line, use the -i switch to string a series of directories that will include nwscript.nss plus your includes, separated by semicolons ... eg.

-i .;F:\;F:\Games\NWN2\Override\includes\



and, -1 (one) likely helps -l (load) deal with packed files, but I doubt that alone tells the compiler to access nwscript inside such files. Rather, I'd guess it's just a simple flag that tells -l to "unpack using method x, or method y"

To specify multiple files I have success using wildcards as input (*.nss) instead of -b

#109
Halgroth

Halgroth
  • Members
  • 10 messages

Thank you for your response, kevL.

 

I'd use -i if it would eat archives and not only .nss, but from what I can tell this is not supported. Both -l and -m looks for NWN1 registry keys, which is out of the question on my linux system and causes the compiler to fail. So I either have to make do with extracting the resources, or edit the NWNScriptConsole. I recon the first option and -i is the better one at this point.



#110
kevL

kevL
  • Members
  • 4 052 messages
*nod

am sure you'll figure something that does trix.

#111
kevL

kevL
  • Members
  • 4 052 messages
ps. should add that all stock #includes copied to a directory in /Override helps a lot ( could throw nwscript.nss in there as well )

[edit] oh right, NwN1 .. i'll shuddup now.
[edit2] ie. just copy the stock includes to the same dir as you'll place nwscript.nss ... add that dir w/ -i

#112
SkywingvL

SkywingvL
  • Members
  • 351 messages

You can tell the compiler to load a full module up using either (-m modulename and optionally -h homedir, OR just -r path_to_module_directory).  This will load up haks from the "home directory" (typically Documents\Neverwinter Nights 2 unless overridden with -h) under direction of module.ifo, and the "install directory" (i.e. NWN2/NWN1 install path, default can be overridden with -n) as necessary.

 

The compiler only supports writing output to a file system directory and not an ERF, i.e. a .mod file.  If you want to package the build products of the compilation up into a .mod file, use ErfUtil.  Only NWN2 natively supports directory mode modules and if memory serves, only NWN2 has the notion of a "home directory" that is distinct from the game installation directory.

 

While the install and home paths are defaulted from registry, etc., these can be manually overridden with the -n and -h arguments, respectively.


  • GCoyote et Savagefool aiment ceci

#113
Halgroth

Halgroth
  • Members
  • 10 messages

That was all I needed, thank you. Silly me assumed switches that mentioned NWN2 (-n and -h) did not account for the directory structure of NWN1 and ignored them by default. Using the below command all module nss files successfully compile in < 6s. Amazing.

./NWNScriptCompiler.exe -1 -v1.69 -q -g -e -o -n ../../NWN -m modulename -y -b ../ncs *.nss


  • Savagefool aime ceci

#114
GlowingCactus

GlowingCactus
  • Members
  • 7 messages

Hello, I'm trying to see if this Compiler will work with NWN1.  I'm trying to modify the bat files I've seen but my Bat Fu is weak.

@echo off

set installDir="C:\NeverwinterNights\NWN\"

set nssFolder="C:\NeverwinterNights\my_nss\"

set returnDir=%cd%

cd %nssFolder%

C:\NeverwinterNights\NWN_TOOLS\AdvancedScriptCompiler\StandaloneCompiler\NWNScriptCompiler.exe -1c -n "%installDir%" -b . *.NSS

cd %returnDir%


#115
kamal_

kamal_
  • Members
  • 5 235 messages

Not sure. Skywing hasn't been around the new irc channel.



#116
GlowingCactus

GlowingCactus
  • Members
  • 7 messages

Not sure. Skywing hasn't been around the new irc channel.

 

In the Usage it outputs it says: "-1 Assume NWN1-style module and KEY/BIF resources instead of NWN2-style module and ZIP resources." and in the bug fixes it says: "NWN1 game resource directories no longer are required to be present on the Windows build." so my hopes are high.  It should be just telling the right arguments to the exe?



#117
kevL

kevL
  • Members
  • 4 052 messages
have you seen the thread in the NwN forum: Advanced Script Compiler for NWN1 release thread