Practicing Scripting?

This might be a kind of odd request. So, I’ve been working my way through Celowin’s tutorial, watching Mr.Hanson’s videos, as well as poring over the Scripting FAQs, the Lexicon, and everything else.

And I feel like I’m making very limited progress. I’ve managed to chisel out some meanings, but for the most part it seems like I just can’t seem to wrap my head around it. I can successfully parrot what they’re doing, and I managed to make the portal 2-way in Celowin’s tutorial, but even that was supposed to be easy and was pretty difficult for me.

So I was wondering if anyone has like practice sheets, but for scripting, that will take me from the basics of integers, variables, and such? Like homework for the dim kid in class?

I’m not sure if I’ve explained myself very well, but I hope y’all can understand what I mean.

Edit: You guys are truly great. I’m going to take everyone’s advice and get back at it. Expect me back later with more questions (this time with 100% more script)!

I too had a hard time grasping scripting when I began with my first module for NWN2 2 years ago. It’s only recently that I feel like I actually understand some of it. For me, my brother was the one who helped me the most, who works as a programmer, to get me to understand what an integer actually is for instance. I’m sorry to say that I know of no practice sheets as such. The only thing I can think of that might help you somewhat is Lilac Soul’s Script Generator: https://neverwintervault.org/project/nwn1/other/tool/lilac-souls-nwn-script-generator-v23 and maybe Kevl_s scripting help (but Kevl_s jumps from understandable to advanced quite quickly): https://neverwintervault.org/forums/neverwinter-nights-2/nwn2-tutorials/basic-scripting-not-so-basic

And, Aqvilinus here on the forums is really a master on scripting and explains extremely well how things work. He has been able to make me understand quite a bit also.

1 Like

I have worked in the IT field as a developer for a few years now and I still need to refer to code examples or ask for help with NWN and NWN2 scripting. I understand the code when I read it, but since it is its own language and I don’t use it often, I forget naming conventions and some of the syntax when writing my own scripts. If only NWN used Java, then I would be fine. :slight_smile:

I recommend trying to find scripts in the official campaigns that do something similar to what you are trying to achieve and then modify them to do what you want.

1 Like

@andgalf You do realise this is in the NwN1 section don’t you?

@Bearserker First a question. Have you read through the 4 primers that I wrote? The first one is TR’s Basics - Variables, Types and Functions (TBC). The other 3 are linked in the Related Projects section of that project page. If you have read them, didn’t they help at all? I did write them for people with no programming experience whatsoever.

I understand where you are coming from with your need for practice but really the only way to learn is by writing your own scripts to make things do what you want them to do. You will need to keep referring to things like the lexicon, but that’s no bad thing. It’s the way most of us currently on here learned. OK, so some of us already knew how to program but NWScript was new to all of us when we started.

Just try and when you don’t understand something… ASK. We don’t bite. We’re mostly a friendly bunch.

There are a few tips I can give you though.

  1. Don’t panic. When you feel your brain start to melt. Stop. Breathe deeply. Nothing you can write in NWScript will result in your PC blowing up.
  2. Take your time. Don’t expect to be instantly proficient.
  3. The majority of scripts that you will need to write for a module will be really small (less than 10 lines of code). So get the basics understood first.
  4. Do not be afraid to ask (I can’t repeat this enough). However, I personally do prefer when people have tried to help themselves first (e.g. Lexicon, FAQs, etc.)

TR

2 Likes

The thing that helped me most when I was learning to script was to look at scripts that other people had written and try to figure out what it was doing and why. Obviously, your mileage there will depend on how complex the script is and how good the person who wrote it is.

The next thing that helped me was just to try making something. Give yourself a small project and then figure out how to do it. Try it on your own at first, and use the lexicon to figure out what kinds of functions you might want to use. if you get stuck, you can try looking at someone else’s script to see how they solved the same problem.

Also, as others have said, don’t be afraid to ask for help on specific things here on the forums.

2 Likes

When writing your scripts, the best suggestions I can give you is put in a lot of debug information at every stage. So that you can test it and get feedback to yourself. You maybe doing something right, but just missed some small scripting error or other minor thing. The other things is to write notes in the script (what the script is doing and what it doing at certain points along the script), so you and future people who may use/look at your script can get a general idea of what and how your script is accomplishing it task.

1 Like

@Tarot_Redhand Of course I do, but scrpiting for both games are so similar that’s why I posted my post (I guess I could have just left out that I made modules for NWN2 instead of NWN1). For example, I mean, the Lilac Soul’s Script Generator is for NWN1 but I still use it.

@Bearserker Like others have said here, try to make a simple script that you have a clear intention to what it wants to do, then post it here on the forums and ask questions about why this and that doesn’t work. I’ve done those things and it has helped quite a lot. Nowadays, I use Discord almost exclusively for this stuff because I find it easier and I get faster feedback/help.

2 Likes

Have a reason.

It’s SO much easier to figure out how to do something when you NEED to.
If you have a dungeon with a brazier and this brazier needs to light up every time a PC walks up to it, you’ll figure out how to code that one specific thing.

You’ll have to look things up. (NWN Lexicon, mostly)
Every script you code will make the next script easier.
Suddenly one day you realize you have a pretty good idea about code.

3 Likes

I think I was trying to do too much, at first. I was flipping through your tutorials, other people’s tutorials, the lexicon, and working through Celowin’s all at the same time. I’ve been re-reading your basics at work whenever I’m on break, and I think it’s starting to make a bit more sense.

There is still a lot that confuses me, but I think I’m going to take everyone’s advice and just try it out as needed, and make sure to ask if I can’t figure out why my script isn’t working. I was concerned to do that, because I didn’t want to post a failed script that was just the utter height of stupidity, but it turns out everyone is super helpful and isn’t likely to judge me for that.Thank you for being so patient.

4 Likes

I’ll do that. I think I made a classic mistake in starting off too ambitiously, and not tempering my expectations for myself. I have plenty of things I’d like to do that are relatively simple, script-wise, (I think) so I’m going to focus on trying to do those, like everyone’s said. I’ll be sure to ask for help when something inevitably goes wrong. :slight_smile:

2 Likes

You’re quite right - asking here is always cool, especially if you post your script - even better if you’ve narrowed it down to the section that’s failing.

We’re all learning here.

2 Likes

Charles’ recommendation is the single best way to learn. Set a particular goal to achieve through scripting, and before you go to the Lexicon, reason through in your head based on whatever you know about NWScript about how you think you’d go about accomplishing it. Check to see if the functions you think you’ll need are already written (often they are!) and assemble your script. You’ll be surprised how much else you pick up on the way, and by the time you’ve figured out how maybe 10% of the included BioWare scripts work, you’ll be able to guess how the other 90% are written based on their names alone.

You’ll screw up a lot, but we all did. In the end, the small goals you set for yourself will serve as your ‘homework assignments’ and they’ll get progressively more complex as you become more ambitious.

For my own part, I was fairly proficient scripter back in the early 2000s when the games were first released, but after finishing university and starting work in a field completely unrelated to computer programming, my skills fell to rust. With the release of the Diamond Edition on GOG, I challenged myself to build a PW for my friends, and to rebuild my skills, I started a small module with a couple of areas (several interior levels of a large home, the grounds outside, a subterranean level, etc) and in each room I set up different challenges for myself; for example, creating a ladder/trapdoor between one level of the house and the roof, creating two possible, morally-opposed henchmen that would react differently based on which was recruited first, randomizing the placement of a secret note in the inventory of various bookshelves, and so on. The little test module itself became so interesting in the end that I’m likely to release it in a few months (well, whenever it’s done) as a standalone adventure.

I’d recommend doing the exact same thing. Start a little module with no purpose in mind other than to be a series of disjointed experiments, and eventually the workspace will inspire you further until you’re doing things you’d never even thought you could.

1 Like

One thing I’ve always recommended for new scripters is that they play around with the default scripts for spells, AIs, triggers, etc… first. Make a few changes to a core asset then save it. Then jump into the module to actually see what your changes did. I recommend editing the default scripts mainly because you really can’t break anything that way. Does it fail now? No sweat. Delete the custom version and save your module and the default will take over again. Does it have an unexpected or unwanted outcome? Now you have an idea of what a change or tweak can do. Try again. Delete the custom version and start over even. Regardless, playing around with default scripts will usually speed up the learning curves and relieves the scripter of the nagging fear of failure. You can’t fail. You might break the script or have other adverse outcomes, but you just delete the custom version and VOILA! all is good again.