So I am working on my PW and t is going greatthough I am not a script master I have the desire to alter this script that I had found but I seem to hit a wall with this so I would appreciate any additional help on this!
Okay so i got this script which I believe works the moment you close the placeable (in my case a bookcase) with books with a certain letter on it.
Which if I read this correctly would teleport the user to the WP that has been specified in the top. HOWEVER I seem to be doing it either wrong or something went wrong.
So I thought of altering it slightly to create a portal at a WP that will last for like 6seconds (so long enough for people to hop in before the portal vanishes and the books being consumed by the placeable)
Would that be doable? with this script? If anyone can lend me a hand with this since I keep walking up that wall and I can tell you I do not like the wall :S
Alright, I have no idea what I’m doing wrong, but I can’t get the script to work. I’ve tried several methods now. I won’t embarass myself posting my attempts here since I know they don’t work. This should be an easy script to make but…
Wait, I have another idea. I’ll try that. I’ll get back to you. I realized I have a very similar script in the module I’m working on. Let met take a look.
Here. This works in NWN2 at least (I renamed the tags when testing, sorry about that):
int ItemsValid()
{
int bHasBook1 = FALSE;
int bHasBook2 = FALSE;
int bHasBook3 = FALSE;
int bHasBook4 = FALSE;
string sTag;
object oItem = GetFirstItemInInventory();
while (GetIsObjectValid(oItem))
{
sTag = GetTag(oItem);
if (sTag == "book_o")
{
bHasBook1 = TRUE;
}
else if (sTag == "book_p")
{
bHasBook2 = TRUE;
}
else if (sTag == "book_e")
{
bHasBook3 = TRUE;
}
else if (sTag == "book_n")
{
bHasBook4 = TRUE;
}
oItem = GetNextItemInInventory();
}
return bHasBook1 && bHasBook2 && bHasBook3 && bHasBook4; // All must be TRUE for the return to be TRUE
}
void DestroyTheObject()
{
object oPortal = GetObjectByTag("portal");
DestroyObject(oPortal,0.1);
}
void main()
{
object oThief = GetLastClosedBy();
location lLoc = GetLocation(GetWaypointByTag("WP_BOOKCASE_PORTAL"));
if(ItemsValid())
{
CreateObject(OBJECT_TYPE_PLACEABLE,"portal",lLoc);
DelayCommand(6.0, DestroyTheObject());
}
}
Sigh, so the function ginc_object is not available in NWN1. Ok, I’ll try and fix it.
Maybe this will work (it works like a charm in NWN2, don’t know about using the teleporter, if that interupts the destroy but…EDIT: Tested that too in NWN2 and it works too):
int ItemsValid()
{
int bHasBook1 = FALSE;
int bHasBook2 = FALSE;
int bHasBook3 = FALSE;
int bHasBook4 = FALSE;
string sTag;
object oItem = GetFirstItemInInventory();
while (GetIsObjectValid(oItem))
{
sTag = GetTag(oItem);
if (sTag == "book_o")
{
bHasBook1 = TRUE;
}
else if (sTag == "book_p")
{
bHasBook2 = TRUE;
}
else if (sTag == "book_e")
{
bHasBook3 = TRUE;
}
else if (sTag == "book_n")
{
bHasBook4 = TRUE;
}
oItem = GetNextItemInInventory();
}
return bHasBook1 && bHasBook2 && bHasBook3 && bHasBook4; // All must be TRUE for the return to be TRUE
}
void DestroyTheObject()
{
object oPortal = GetObjectByTag("portal");
DestroyObject(oPortal,0.1);
}
void main()
{
object oThief = GetLastClosedBy();
location lLoc = GetLocation(GetWaypointByTag("WP_BOOKCASE_PORTAL"));
if(ItemsValid())
{
CreateObject(OBJECT_TYPE_PLACEABLE,"portal",lLoc);
DelayCommand(6.0, DestroyTheObject());
}
}
Have you changed the tags? As I said, I happened to change the tags when trying different things, so you would want to change them back to what you had. OR it might be as @4760 says that you shouldn’t have a space in the tag name.
Since I only have NWN “somewhat” installed on this computer (I’ve actually just copied my previous folders from an old harddrive) and even though I can open the toolset, it says (understandably) that there’s no key for the game, so I probably wouldn’t be able to test this. And it takes to long if I were to install the whole game from my old discs (I own the NWN Deluxe Edition), sorry. Plus, I don’t know my way around the NWN1 Toolset. I know how to write a script there, but that’s it.
EDIT: Have you put my script on the OnClosed of the placeable you use?
I’m trying with the NWN1 toolset myself now. Have no idea if the game will start…It will take a while for me to set this up, being so unfamiliar with this toolset, but I’ll try.
Hmmm, it actually worked. The game runs, and everything except teleporting from the portal works (but that’s because I don’t know how to write a normal jump to object script in NWN1, while I know exactly how this is done in NWN2). Such nostalgia to run old NWN1 again.
So I have no idea why it doesn’t work for you. I have the old NWN1 so maybe it’s got something to do with NWN:EE if you’re using that?