Is there no way to close a chest through a script? I can find no function that does this it seems.
Think I found how to do it. I’ll just test it. I remembered I have used a script copied from somewhere long ago with activating/moving a lever. Inside that script it looked like this:
PlayAnimation( ANIMATION_PLACEABLE_ACTIVATE );
So my guess is I should be able to use this:
PlayAnimation( ANIMATION_PLACEABLE_CLOSE );
EDIT: Ok, it kind of worked, but I realize I need to close the inventory GUI of the chest too.
EDIT2: @Lance_Botelle - I’m lazy now, I know, but I think you made a script at some point where you closed the GUI of the inventory of a placeable. Do you remember the code for that?
I do believe it is CloseGUIScreen that I should use, but what’s the name of the GUI for that?
Maybe it’s “SCREEN_INVENTORY”? I’ll try that…
EDIT3: Ok, that closed the inventory screen of the player. I guess I have to use
object oChest = GetObjectByTag("mchest");
PlayAnimation( ANIMATION_PLACEABLE_CLOSE );
CloseGUIScreen(oChest,"SCREEN_INVENTORY");
EDIT4: No, that wasn’t it…
“SCREEN_CONTAINER_DEFAULT” most likely.
However, maybe this would work too… replace oTOCLOSE with your object.
AssignCommand(oTOCLOSE, ActionCloseDoor(oTOCLOSE));
i.e. I think this function closes a placeable as well as a door. I have it in some scripts that look as though they aim to do that… but it’s been a while since I checked them.
Well, the
worked really well as stated here (maybe my statement wasn’t entirely clear):
It’s just the GUI screen I need closing. I’ll try
You misunderstand me … I meant that the function may replace all that you needed it to do. i.e. That will close the placeable and the inventory at the same time, iirc …
Now with a bit of fiddling back and forth I got it working:
void main()
{
if(GetGlobalInt("mocktalnote")) return;
object oPC = GetFirstPC();
SendMessageToPC(oPC,"I should take a look at the note I found first.");
PlayAnimation( ANIMATION_PLACEABLE_CLOSE );
CloseGUIScreen(oPC,"SCREEN_CONTAINER_DEFAULT");
}
I put this on OnUsed and on OnLeftClick of the placeable in question (in this case the chest).
You could try the NWN1 solution:
if the placeable is just opened by the PC:
AssignCommand (oPC, DoPlaceableObjectAction (oCont, PLACEABLE_ACTION_USE));
if it’s just an opened chest somewhere, which shall be closed by something:
void main()
{
object c = GetObjectByTag ("TestChest");
AssignCommand (c, PlayAnimation (ANIMATION_PLACEABLE_CLOSE));
}
Hmmm, yes, I think the mayor fault in your script above (which happens to be quite similar) is, that you didn’t assign then PlayAnimation-Command to the chest.
I’m afraid you’re wrong. My script above works as a charm now. The AssignCommand wasn’t needed in this case. I’ve tested it. I clicked on the chest about 15 times.
I’m afraid you’re wrong. My script above works as a charm now.
Well, that depends on which objects action queue the script runs.
As stated, the issue is solved.
Works like a charm!