I’m trying to use this thing again in a new module I’m working on at the moment. Just as before I put it on the OnLeftClick. This is how this particular version of the script looks like:
void InventoryFountain (object oPC, object oPlaceable)
{
AssignCommand(oPC, DoPlaceableObjectAction(oPlaceable, PLACEABLE_ACTION_USE));
}
void main()
{
object oFountain = GetObjectByTag("fountainvebi");
object oPC = GetFirstPC();
if(GetIsInCombat(oPC)) return;
if(GetJournalEntry("q_fountain",oPC) < 11)
{
ActionStartConversation(oPC);
}
else
{
DelayCommand(0.1f, InventoryFountain(oPC, oFountain));
}
}
It almost works, but now quite. The inventory of the fountain placeable opens, but very quickly closes again automatically. Any idea of what I’m doing wrong this time?
EDIT: Hmm, odd. If I put this script on OnUsed instead, the game gets stuck in a loop where it opens and closes the inventory. What is this weird stuff?
EDIT2: I tried using @Lance_Botelle 's solution instead. In other words I did it like this, and now, for some reason it works again:
void InventoryFountain (object oPC, object oPlaceable)
{
//AssignCommand(oPC, DoPlaceableObjectAction(oPlaceable, PLACEABLE_ACTION_USE));
AssignCommand(oPC, ClearAllActions(TRUE));
AssignCommand(oPC, ActionInteractObject(oPlaceable));
}
void main()
{
object oFountain = GetObjectByTag("fountainvebi");
object oPC = GetFirstPC();
if(GetIsInCombat(oPC)) return;
if(GetJournalEntry("q_fountain",oPC) < 11)
{
ActionStartConversation(oPC);
}
else
{
DelayCommand(0.1f, InventoryFountain(oPC, oFountain));
}
}
Could it have to to with the ClearAllActions stuff that I didn’t have at first?
EDIT3: There’s another thing I want do do here regarding this situation. In another script that comes later the player opens his inventory. I would like to close that inventory by scripting. I thought the way to do this was to use this:
CloseGUIScreen(oPC,"SCREEN_INVENTORY");
But that didn’t work. Any ideas of how to do that?
EDIT4: Hmmm, I might have defined oPC wrong.