Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Paper Carnival on Thu 30/10/2003 18:22:55

Title: Wierd results with RunInventoryInteraction?
Post by: Paper Carnival on Thu 30/10/2003 18:22:55
I noticed something that has been bugging me for a long time. It's nothing serious or anything I can't go around, but it is still a bit strange.

You see, there is only *one* thing left for my whole GUI thingababom to finish and it's this one. RunInventoryInteraction() seems to work fine, but does it?

This is the code for the inventory verb coin (in the on_interface_click event):
Quoteif (interface == INVCOIN) {

GUIOff(INVCOIN);
GUIOff(INVENTORY);
RunInventoryInteraction(game.inv_activated, button + 1);
GUIOn(INVENTORY);

}

The above is quite self explanatory; It hides the inventory verb coin GUI (INVCOIN), the inventory GUI, it runs the inventory interaction and then it brings up the inventory again. You see, I want to simulate the same thing that happens with the default inventory. So, what's the problem? Well, It *doesn't* work! Every block action I try to make (like display speech) works except if it is in the interaction of the item! Putting
QuoteGUIOff(INVENTORY);
DisplaySpeech(EGO, "What a lovely item");
GUIOn(INVENTORY);
in the interaction seems to solve the problem, but it waistes time. Also, I am planning to release the template and I don't want the user having to put GUIOn(INVENTORY); and GUIOff(INVENTORY); in the beginning and end of the interaction script.

All in one, is it possible to make the RunInventoryInteraction blocking the game or something?

I have a feeling I've just asked a stupid question

This thingy also appears in a similar script. Check this out (it's in on_mouse_click() function):
Quoteif (button == LEFTINV) {

if (GetCursorMode() != 4){
lastitem = game.inv_activated;
SetActiveInventory(game.inv_activated );}

else if (game.inv_activated != lastitem)
{

InterfaceOff(INVENTORY);
if (IsInventoryInteractionAvailable(game.inv_activated, 4) == 0)
DisplaySpeech(EGO, "I can't use these things together");
else
RunInventoryInteraction(game.inv_activated, 4);
InterfaceOn(INVENTORY);

}
}
The above script picks up an item if there is not an active one and uses the items together if there is. Again, the same thing with RunInventoryInteraction happens, even though DisplaySpeech(EGO, "I can't use these things together") works just fine
Title: Re:Wierd results with RunInventoryInteraction?
Post by: Spyros on Thu 30/10/2003 19:31:58
Try putting a Wait(1);
in the place where you put the DisplaySpeech that works.

GUIOff(INVENTORY);
Wait(1);
RunInventoryInteraction(game.inv_activated, button + 1);
GUIOn(INVENTORY);


Title: Re:Wierd results with RunInventoryInteraction?
Post by: Ishmael on Thu 30/10/2003 20:00:45
Or should you use

RunInventoryInteraction(game.inv_activated,MODE_USE);

?
Title: Re:Wierd results with RunInventoryInteraction?
Post by: Paper Carnival on Thu 30/10/2003 20:20:07
I have already tried to use wait, Spyros. using MODE_USE is not necessary. The interaction works, it's just that it doesn't block the game.
Title: Re:Wierd results with RunInventoryInteraction?
Post by: Ishmael on Thu 30/10/2003 20:28:10
You need to make it a blocking interaction!
If you have something like MoveCharacter in the inv item interactions, of cource it is not blocked since MoveCharacter is not a blocking function.
Title: Re:Wierd results with RunInventoryInteraction?
Post by: Paper Carnival on Thu 30/10/2003 20:36:48
no, if you have read the whole thing then you should know what I mean. This code:
QuoteGUIOff(INVENTORY);
DisplaySpeech(EGO, "I've just used the item");
GUIOn(INVENTORY);
works fine. But if I put
QuoteGUIOff(INVENTORY);
RunInventoryInteraction(game.inv_activated, MODE_USE);
GUIOn(INVENTORY);
will NOT work fine, even if I put in the interact script
Quote
DisplaySpeech(EGO, "I've just used the item");
You see what I mean? It doesn't block it even if it is a blocking action...
Title: Re:Wierd results with RunInventoryInteraction?
Post by: Ishmael on Fri 31/10/2003 19:39:37
Put a Wait(1); before it?
Title: Re:Wierd results with RunInventoryInteraction?
Post by: Paper Carnival on Fri 31/10/2003 20:03:28
That's exactly what Spyros said.. I tried putting Wait(1) in every place but still...
Title: Re:Wierd results with RunInventoryInteraction?
Post by: Pumaman on Fri 31/10/2003 21:16:30
RunInventoryInteraction is one of those functions that doesn't get run immediately - instead, it gets run when the calling script finishes. Therefore, the following GUIOn is being run before the RunInventoryInteraction is.

Sorry, this should really be documented in the manual.
Title: Re:Wierd results with RunInventoryInteraction?
Post by: Paper Carnival on Sat 01/11/2003 06:59:20
Oh ok. I understand now. Well, your answer made me think a way to fool it...

I created an integer variable called InteractedInv. Then, I put:
Quoteif (interface == INVCOIN) {
InteractedInv = 1;
GUIOff(INVCOIN);
GUIOff(INVENTORY);
RunInventoryInteraction(game.inv_activated, button + 1);
if (IsInventoryInteractionAvailable(game.inv_activated, button + 1)==0) GUIOn(INVENTORY);
}
in the on_interface_click function. After that, I put in repeatedly execute function:
Quoteif (InteractedInv) {
InteractedInv=0;
if (IsGUIOn(INVENTORY)==0) GUIOn(INVENTORY);
}
It works! You see, I thought "if RunInventoryInteraction() function executes when the script is over, then I must bring back the interface on a different script, so it is brought *after* RunInventoryInteraction() executes..." >> pure adventure gamer's way of thinking ;)