Hello guys, I am trying to make torches on the walls of my dungeon light up/snuff out on use. I tried using script generator for this script, but it doesn´t work completely. It gets the frist aprt right I use the placeable and the torch lights up, but when I use it again, it doesn´t do anything. Would anyone be so kind please and would point me in the right direction?
Here is the simple script:
void main()
{
object oPC = GetLastUsedBy();
if (!GetIsPC(oPC)) return;
object oTarget;
oTarget = OBJECT_SELF;
if (GetPlaceableIllumination(oTarget))
{
PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);
Weird. As far as I can see, the script looks correct. Don’t know what could be going on.
Question: when you use the torch a second time to turn off the light, so to speak, does the animation play? If it doesn’t then that should point at that the “if” part isn’t running.
Maybe you could do some SendMessageToPC to try and find where it goes wrong?
(As I only work with NWN2, I hope this kind of script works with NWN:EE)
Maybe something like this:
void main()
{
object oPC = GetLastUsedBy();
if (!GetIsPC(oPC)) return;
object oTarget;
oTarget = OBJECT_SELF;
if (GetPlaceableIllumination(oTarget))
{
SendMessageToPC(oPC,"The torch is lit");
PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE);
SendMessageToPC(oPC,"Animation is running");
SetPlaceableIllumination (oTarget, FALSE);
SendMessageToPC(oPC,"The torch is no longer lit");
}
else
{
SendMessageToPC(oPC,"The torch is not lit");
PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE);
SendMessageToPC(oPC,"Animation is running");
SetPlaceableIllumination (oTarget, TRUE);
SendMessageToPC(oPC,"The torch is now lit");
}
RecomputeStaticLighting(GetArea(oTarget));
}
I tested this in NWN2, and it’s quite strange, but the first if statement doesn’t work. So it’s the same for me as for you.
Yes, try @Mannast way instead. Maybe there’s something wrong/buggy with the GetPlaceableIllumination function.
Edit: Tried Mannast script (with my SendMessageToPC, even though I have no torch that can show light, haven’t found that kind of placeable) and everything seems to check out with that script.
@raymondsebas Thanks, I’ll try and download that. However, keep in mind that Nathaniel works with NWN:EE so this maybe won’t do him any good downloading this, unless he can check the script files…Maybe you can actually do that and import the nss files in NWN1, I don’t know.