Skip to content

Script Compiler for Enhanced Edition

GlorwingerGlorwinger Member Posts: 41
edited February 2018 in Tools & Plugin Developers
*** UPDATE ***

I just posted an UPDATED script compiler to the vault and Github that works with NWN EE and the packed game files. This one is based on the Skywing compiler engine and is more robust and faster. There are a few things left on the ToDo list - visit the source repository below to see or add bugs and issues.


This has been tested on Windows, Linux, and Mac for both 1.74 (EE) and older 1.69 and things seem i order so far...

https://neverwintervault.org/project/nwn1/other/tool/nwnsc-nwn-enhanced-edition-script-compiler

Source code... https://gitlab.com/glorwinger/nwnsc
Post edited by Glorwinger on
«1

Comments

  • shadguyshadguy Member Posts: 154
    @Glorwinger

    Thank you. It sounds like this may be a separate branch from Skywing's work, based on the same source. Is my understanding correct? [ Reference: https://neverwintervault.org/project/nwn2/other/tool/advanced-script-compiler-nwn2 ]

    -Dave
  • GlorwingerGlorwinger Member Posts: 41
    It is the base for the Skywing Compiler. I am going to pull the parser from that one and update this one. It doesn't have all of the optimizations etc. of the Skywing version. This one was already cross platform and easier to update for NWN EE.
  • shadguyshadguy Member Posts: 154
    Cool, thank you for the follow-up. :):)

    -Dave
  • HimmelweissHimmelweiss Member Posts: 72
    @Glorwinger

    This is really awesome, also using Visual Studio Code now for nwscript and made a build task with your compiler.

    Really awesome!!!
  • BalanorBalanor Member Posts: 176
    edited February 2018
    I'm not able to get this to work. External script compilers are definitely not my thing.

    I put the nwnnss.exe in C:\Users\username\Documents\Neverwinter Nights
    Then I created a .bat in the same directory with the following in it since that was the example on the NWVault page:
    @ECHO OFF
    nwnnss compile -p /Applications/Beamdog/00829 -u "/Users/username/Documents/Neverwinter Nights/" *.nss
    PAUSE

    And it always errors out with:
    "Unable to locate or open Neverwinter Nights"

    What am I doing wrong?
  • FinalStandFinalStand Member Posts: 87
    Balanor said:


    nwnnss compile -p /Applications/Beamdog/00829 -u "/Users/username/Documents/Neverwinter Nights/" *.nss
    PAUSE

    And it always errors out with:
    "Unable to locate or open Neverwinter Nights"

    You probably need to give the full path to the -p parameter. Also use backslashes in windows, not forward slahes.

    Something like `-p C:\Applications\Beamdog\00829`

    Lastly, if you update your client in beam dog client the last directory name (00829) will change, so need to update your script everytime you update.

  • SherincallSherincall Member Posts: 387

    Lastly, if you update your client in beam dog client the last directory name (00829) will change, so need to update your script everytime you update.

    00829 is not a version, it's the code for "NWN:EE Head Start Standard Edition". If you update it, it'll stay in the same spot. If you install Digital Deluxe, you'll get a different number. And when it gets released, it will get a new number (and head start will become beta for patches).

  • FinalStandFinalStand Member Posts: 87

    Lastly, if you update your client in beam dog client the last directory name (00829) will change, so need to update your script everytime you update.

    00829 is not a version, it's the code for "NWN:EE Head Start Standard Edition". If you update it, it'll stay in the same spot. If you install Digital Deluxe, you'll get a different number. And when it gets released, it will get a new number (and head start will become beta for patches).

    Good to know. It did change on me once, but regardless, that should fix his problem.
  • GlorwingerGlorwinger Member Posts: 41
    I updated the first post above with an updated Compiler. This is based on the Skywing engine and is more robust and stable.

    Give this one a try and report any issues here or better in the Issue tracker via the link above.
  • BalanorBalanor Member Posts: 176
    edited February 2018
    just to close the loop, and in case it might help someone else; with Glorwinger' and sherincall's help I did get the new compiler to work. the .bat I setup looked like this:
    @ECHO OFF
    nwnsc -n "\Users\balan\Beamdog Library\00829" -i "\Users\balan\Beamdog Library\00829\ovr" -l *.nss
    pause
    Thanks Glorwinger, for your work on this!
  • GlorwingerGlorwinger Member Posts: 41
    Updated nwnsc script compiler version 0.9.6 - https://neverwintervault.org/project/nwn1/other/tool/nwnsc-nwn-enhanced-edition-script-compiler
    • Fixed several null pointers and segmentation faults
    • Improved speed with compile optimizations
    • Redundant -l command line option not required when passing -n
    • When building for NWN EE the installdir ovr folder (override) will be processed for includes before the .bif files
    • Added -M to create Makefile compatible dependency files
  • fot1fot1 Member Posts: 74
    I could use some help to make this work. I'm on Linux with a steam installation. I'm getting a segfault. I'm not sure what is the right directory to point the compiler. Without a directory, I get the same "Unable to locate script nwscript.nss" error. My best try was this one:

    $ /nwnsc -p /steam/steamapps/common/Neverwinter\ Nights/data/ temp0/*.nss Segmentation fault (core dumped)

    I have tried all partial paths and no luck. strace tells me the following:

    access("/steam/steamapps/common/Neverwinter Nights/data/", F_OK) = 0 open("/steam/steamapps/common/Neverwinter Nights/data/", O_RDONLY) = 3 fstat64(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 fstat64(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 _llseek(3, 0, [2147483647], SEEK_END) = 0 _llseek(3, 0, [0], SEEK_SET) = 0 mmap2(NULL, 2147483647, PROT_READ, MAP_SHARED, 3, 0) = -1 ENODEV (No such device) mmap2(NULL, 2147487744, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x77514000 --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0xffffffff} ---

    I wonder what is the directory I should point to the compiler?

  • GlorwingerGlorwinger Member Posts: 41
    What version of the compiler? I haven't tried it on Steam on Linux...
  • Grizzled_DwarflordGrizzled_Dwarflord Member Posts: 168
    This may seem like a stupid question, but why can't we have a compiler like this, or NWNx's compiler, inside the toolset itself?
  • dTddTd Member Posts: 182
    How hard would it be to get this to be case insensitive? Many old scripts have includes which for some odd reason are capitalized which breaks when using the external compiler.
  • BohuntinBohuntin Member Posts: 4
    I've mostly got this to work, but I cannot figure out how to get the compiler to find includes that are in a hak. Compile command:

    nwnsc -m $(VER) -n $(NWN_INSTALL_DIR) -h $(NWN_HOME_DIR) *.nss
    ...
    NSC1085: Unable to open the include file "zep_inc_main"

    which will be on one of the CEP 2.65 haks. I am using version 1.0.0 - built Jun 2 2018 18:03:29 on linux. The above is from a makefile and the variables point to the right places.


    PS-Hi GDL!
  • TarotRedhandTarotRedhand Member Posts: 1,481
    @Grizzled_Dwarflord
    This may seem like a stupid question, but why can't we have a compiler like this

    The compiler being discussed here is a command line compiler. Though limited, the compiler in the toolset has a gui. While this command line compiler may well be better at its job, I would much rather stick with a gui unless I have a pressing need for compiled code.

    @Bohuntin I don't think this compiler has the ability to look inside haks. I certainly can't see such an option on the project page. The reason that the toolset script compiler can do so is because the toolset itself needs to open hak files so that you can use their contents when building a module. I suppose you could open your project in the toolset and then look in the temporary folder that the toolset creates when it opens a module but I don't know if the include file will be in there.

    TR
  • BohuntinBohuntin Member Posts: 4
    I eventually figured it out and got the compile to work. It turned out that the includes were in a hak, but it was the cep2_custom.hak which is also part of the build (stuff that was moved out of the module)...
  • BohuntinBohuntin Member Posts: 4
    @dTd is the case-sensitive #include issue a thing on windows and/or mac or just linux? I'm also suffering with that.
  • dTddTd Member Posts: 182
    Just linux afik.
  • Daijin_HeartlightDaijin_Heartlight Member Posts: 11
    Can someone post a typical steam nwn ee windows batch file text so i can see what i am doing wrong? Everything i do it says it cannot open the key file.....
  • ReachPWReachPW Member Posts: 27
    edited March 2020
    This compiler has been working lovely for awhile now, but with recent update (1.80 patch) it has these random errors.

    Compiling: can_test_restric.nss
    Exception compiling 'can_test_restric.ncs': 'bad allocation'
    
    Compilation aborted with errors.
    
    Error: Failed to process file can_test_restric.nss.
    
    Stopping processing on first error.
    
    1 error(s); see above for context.
    
    Processing aborted.
    
    Total Execution time = 0.7040 seconds
    


    I've been runnig it the same way for a few versions now, nothing changed on my side, code or command line; other than upgrading to NWN:EE 1.80 though BeamDog client

    command line used
    @echo off
    
    SET MOD_PATH=F:\nwn\ReachPW\modules\reach_dev
    cd /D %MOD_PATH%
    
    del /F  *.ncs
    
    C:\nwn\nwnsc.exe -o -w -h F:\nwn\ReachPW\ -i %MOD_PATH% -i F:\Beamdog\00785\ovr -n F:\Beamdog\00785\ -l *.nss
    
    timeout 3 /nobreak
    


    What is strange is that 1) it doesn't happen every time 2) when it does happen, it's usually a different file.


    Everything compiles cleanly in toolset and with nwnsc.exe using NWN:EE < 1.80 version.
  • WilliamDracoWilliamDraco Member Posts: 175
    Also getting this bad allocation error - First started with version 8193.7, with .6 working.
    8193.7 was when they did the packing of the /ovr into the keyfiles - so I assume it is related.
  • ReachPWReachPW Member Posts: 27
    Also getting this bad allocation error - First started with version 8193.7, with .6 working.
    8193.7 was when they did the packing of the /ovr into the keyfiles - so I assume it is related.

    Interesting, thanks for sharing. Have you found a work around ?

    Does yours happened "randomly" too ? Works sometimes, but not others.
  • WilliamDracoWilliamDraco Member Posts: 175
    Wouldn't quite call it randomly - If a certain script hits the issue it will continue to always hit it on retries.

    Only workaround I got so far is changing base game back to 8193.5 to compile, which is obviously a bit of a drag. I've heard there's changes to nwnsc that are only currently in the docker version which fix the issue, but haven't had time to extract and confirm that.
  • RinehardtRinehardt Member Posts: 7
    For me, it seems to fail on a random script every time, but it generally only does this with the first or last few dozen scripts. It almost never fails half-way through.
    My current workaround is to just repeatedly run the command until it compiles everything without the "bad allocation" error. Usually takes 20-40 tries.
    I am aware of the Docker container compiler, but installing Docker on my development machine is not an option right now.
  • WaffleWaffle Member Posts: 1
    I pulled down the latest code from the repo and recompiled it in Visual Studio and so far it is working for those who have tried it.

    I can't really account for why it worked before and not now. Maybe the binary that was on neverwintervault is an older one that doesn't have the EE escape chars in it - and the new patch released some content/scripts that triggered this?
  • ReachPWReachPW Member Posts: 27
    > I am aware of the Docker container compiler,

    I am not. Anyone have a link?
  • squattingmonksquattingmonk Member Posts: 59
    It's jakkn's fork, located at https://github.com/jakkn/nwnsc.
Sign In or Register to comment.