It should be so simple but I can’t figure out what I’ve done wrong!
I am trying to hide text in a conversation until the PC has enough gold in their inventory to proceed but
despite all my efforts nothing has worked. I feel like I have made a grammar error or some obscure little mistake that I’ve overlooked. Any help would be greatly appreciated. Thanks in advance.
int StartingConditional ()
{
object oPC = GetPCSpeaker();
int iGold = GetGold(oPC);
Regulars here who will know my complete lack of scripting ability will have a chuckle but do you want to try the following? Note, this is not my own work. If you want to improve your scripting or if you’d rather just get it sorted quickly the Script Generator program is your friend. You tell it what you want and it spits it out right back at you. Absolutely brilliant .
/*
* Script generated by LS Script Generator, v.TK.0
*
* For download info, please visit:
* http://nwvault.ign.com/View.php?view=Other.Detail&id=1502
*/
// Put this under "Text Appears When" in the conversation editor.
int StartingConditional()
{
// Get the PC who is involved in this conversation
object oPC = GetPCSpeaker();
// The PC must have at least 100 gold.
if ( GetGold(oPC) < 100 )
return FALSE;
// If we make it this far, we have passed all tests.
return TRUE;
}
Now, this is me really going out on a limb but have you not forgotten to close the script with the second curly bracket at the bottom?
Not a clue. I think I see what you mean about the second curly bracket. Still very new to this whole scripting business but thanks a bunch I will give this a try and see if it works.
Is the Script Generator a website or do I download it from somewhere?
Try here. If you find it awkward to operate just give us a shout and I’ll post a short video but it really is VERY easy.
I’m never sure if this is the latest version or not but it’ll work. We could really do with someone taking this on as a project to update but i’m guessing that would be a huge endeavour.
PS. the whole world in terms of resources is here somewhere.
Part of the latter download has - Neverwinter Nights Newbie FAQ #2.pdf (103 Pages, 102 Questions Answered). It contains pre-written scripts that answer common scripting needs.
I hadn’t noticed the if (iGold == 0) part before. If that is what you require we can have a ridiculously simple script by exploiting a quirk of NwScript (taken from C/C++) -
Should work in theory. This depends on the behaviour of NwScript in that zero is treated as false and any other value is treated as true. However a guaranteed to work script that is almost as simple is -
The first one will work in practice as well. zero is false, non-zero is !false (i.e. true). TRUE itself is defined as 1 but all that really matters is it’s not zero.
Well I have no idea why but after testing these out they all achieve the desired effect in my module.Thank you so much guys. I was worried I wouldn’t get a reply due to the age of the game but I am super happy that so many people are still active on this website. I only discovered NWN fairly recently.
There are also tutorials in the lexicon too (link in an earlier post of mine). They will help you get started writing scripts while mine should help you to actually understand what you are writing.
I’m guessing that this is the first module that you will have built. I’m also guessing that you are not aware that for what you wanted to do here, you didn’t actually need to write a script at all in order to do it. There is actually a wizard built into NwN’s toolset that would have created it for you. You can read about it in (see the section on conversations) -
Yeah it is my first ever module attempted. I had no idea I was making it harder for myself
Thanks to everybody who has posted links. I appreciate it. I am gonna start looking through all of these and learning as much as my brain can take. It seems really big and difficult but I imagine it will all start making sense soon.
It’s really not hard to get started on the toolset. I’m a johnny-come- lately to it and I now feel I know my way round it pretty well. As Tarot says you don’t need scripting to make a module, although once you’ve made one you’ll probably want to pick up some.
Don’t know if it will suit you but the way I started was by following the excellent set of 10 YouTube tutorials on using the toolset by a Mr Hanson ( computing teacher I think). They are superb. Here is the first
If you want to get into scripting you could do a lot worse than follow the tutorials suggested. Mr Hanson also did a few of these, although maybe scripting tutorials are better read than watched. Anyway, first of these
If you can’t really get on with video tutorials there is always the old pdf tutorials that Bioware released back in 2002 - Ancient Bioware PDF Tutorials. Note that there are links to a set of accompanying notes (on the wiki) in the Related Projects section of that web page. These notes are aimed primarily at EE users.