It as been quite a while since I scripted in NWScript… I just modified a Bioware script. It functionally works. I should probably be happy with that, but while debugging it, I noticed an odd behavior that I cannot explain. I was wondering if anyone might have the time to look over my script and could inform me of either the bug I am missing or the behavior that I can’t explain.
I have a while loop that tests if a local integer on the uidUSER is set to true. If it is, the loop should abort (it also checks for a valid object). There are several debug statements within the loop that use PostString to display values. As far as I can tell the one that Posts a TRUE value should never fire off, since the while loop condition would exclude it from executing, but it does display, and it does so without any other problem with the script.
Note that there is some cleaning up I have to do as there are variables leftover from ideas that did not work.
It’s hard to see what you’re trying to do, without knowing the module. You send the party through the trap door. On the destination-site you look for a (nearest) placeable with the tag “tgr_DrMirrorRm + ”. Right?
I woudn’t use a number which has necessarily two digits, just natural numbers. But why is there a numbering at all?
First, thanx for the response. Wasn’t sure there were many active scripters around.
There is a secret door 1 in Room A that leads to room B’s corner. In room B, there is another exit to another room (Room C) in the same corner. That exit leads to a similar behaving secret door in Room C. The number system assures that each pair of doors get the PC to the corresponding destination. I want to be able to adjust the difficulty of the doors individually while otherwise having the same scripts drive them. Thus the numbers to make each unique. Within the secret room (Room B) that side’s doors are not secret, so only getting in must be found not getting out.
The behavior is working perfectly. I just don’t understand why that true value should ever print. I either have a bug I can’t find that might hit sometime or I do not understand how the while loop executes. For me nwscript has many “features” I don’t understand. Perhaps this is one of them?!
PostString(oidUser,“The local int was set to TRUE. Tere should be no more PostString()s shown after this”,44,44);
=> since the loop is not aborted at this stage, it will fire another time, but with the current oNHD as it is only changed when the tag is not the expected one.
That shouldn’t be a problem as the local int was set to TRUE and that abort the loop as well (as in invalid oNHD would do).
What I usually do when a script doesn’t work as it should: spawn the script debugger.
Compile script with debug symbols, insert SpawnScriptDebugger() where debugging should start. Start the debugger (…\util\win32\DebugServer.exe) and enable debugging in NWN options.
PostString(oidUser,“The local int was set to TRUE. Tere should be no more PostString()s shown after this”,44,44);
=> since the loop is not aborted at this stage, it will fire another time, but with the current oNHD as it is only changed when the tag is not the expected one.
[/quote]
I’ll give that a go… thanx… heading out of town, though… so probably won’t get back to it until next week… just didn’t want to leave you hanging. Thanx for the response![
Thanx for the suggestion. I didn’t know about the debugger. I haven’t scripted since NWN1 first came out. There was so little info and resources then, compared to now.
So I had some time last night and tried 4760’s suggestion, which led me to the problem. I was incrementing the tag of the object at a very different point in the while loop than the object itself. This led to having the tag pointing to a different object. Frankly, I do not know how it worked at all, but I guess the tag eventually caught up.
I need to clean everything up and I already put the bulk of the code in a separate function with just a couple of function calls in the main routine.
I really did not know what to expect when I posted here. There is a lot more activity than I expected for a game so old.
I need to try out the SpawnScriptDebugger() Kamiryn mentioned.