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
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);
Or should you use
RunInventoryInteraction(game.inv_activated,MODE_USE);
?
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.
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.
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...
Put a Wait(1); before it?
That's exactly what Spyros said.. I tried putting Wait(1) in every place but still...
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.
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 ;)