Help with RunInteraction(inventory)(SOLVED)

Started by Scarab, Mon 24/08/2009 11:05:00

Previous topic - Next topic

Scarab

OK, I tried searching for this, but to no avail, so if there is already a thread on this, please point me in the right direction.

My intention is to have an Inventory GUI which has Look, Use, and Interact as its buttons, but I can't get the Interact function to work, and just using   function iBook_Interact()  doesn't work because it just ends up being 'Use' and picks up the item.
The code I used to make my button work was
Code: ags
function btnInvInteract_OnClick(GUIControl *control, MouseButton button)
{
Mouse.Mode = eModeInteract;
}



The code I had which before I founf out in the manual that it doesn't work was
Code: ags
function iBook_Interact()
{
  
Display ("Feeling destructive, you tear a page out of the book");
player.AddInventory(iPage);
}


After searching the manual I was told that I had to use RunInteraction, and was given this code
Code: ags
InventoryItem.RunInteraction(CursorMode)

//And this example

if (button == eMouseLeftInv)
  inventory[game.inv_activated].RunInteraction(mouse.Mode);


which I can't figure out how to implement

please help
Peace 8)
Scarab

lsb

oooh, i know this one, i think.

Well as you figured out, "interact" merely picks up the object instead of interacting with it. to get around it, use another function like "talk" and have your interact actions done in that instead. To make it so it still has your interact icon, just change the pointer to temporarily look like the interact, even though you're using the talk function.

for example, if you want to interact with a book in your inventory, have something like this for your inventory gui:

Code: ags
function btnInvUse_OnClick(GUIControl *control, MouseButton button)
{
    mouse.Mode = eModeTalkto; //changes icon to interact
    mouse.UseModeGraphic(eModeInteract);
}


that should be something like that for the button you want your "interact" button in your gui to be. that way, it'll be the talk mode but still look like the interact mode. then for one of your inventory items, use the talk function instead of the interact function, like

Code: ags
 function iBook_Talk()
{
  
Display ("Feeling destructive, you tear a page out of the book");
player.AddInventory(iPage);
}


and then it'll do that. :)

i hope that was clear. This is my first time helping someone in this forum :D

Jared

Yeah, I had the same problem (to a slightly worse degree) and did something similar to solve it. It's left me wondering - why is the Interact() function even there for the inventory when it's so difficult to call? You would think that more people would be coding in ways to interact with an item than to talk to it. Wouldn't mind seeing this addressed in future versions, and it's pretty much my only beef with AGS...

Scarab

#3
Hrrmm, I understand how the solution should work, but I keep getting no response when I click on the book.
Is there, by any chance, some fundamental thing that I'm missing here? When I first ran the script, the cursor changed just fine, but there was no response when I clicked on anything with the Interact cursor, even thought Look and Use were working fine.

I went to General Settings and changed 'Handle Inventory clicks in script' to true, and got the same result, except now nothing worked on the click.

Could I be putting these snippets of script in the wrong place or something? Because I cant seem to see why my new button is acting differently to the regular ones, even though all its settings are the same.

I also tried the above script with Usermode1, and had the same problem.

GRRR! I CAN'T FIND OUT WHAT'S WRONG!!


Ameature mistake, I forgot to activate the events :-[
thanks lsb

Khris

In General settings, set "Handle inventory clicks in script" to true, then add this to on_mouse_click:

Code: ags
  else if (button == eMouseLeftInv) {
    inventory[game.inv_activated].RunInteraction(mouse.Mode);
  }

Jared

Quote from: KhrisMUC on Mon 24/08/2009 20:04:24
In General settings, set "Handle inventory clicks in script" to true, then add this to on_mouse_click:

Code: ags
  else if (button == eMouseLeftInv) {
    inventory[game.inv_activated].RunInteraction(mouse.Mode);
  }


Thought I'd best mention for the record that this was actually the very first thing I tried with mine and it didn't work. So I don't think this is foolproof.

Khris

I tested this and it worked just fine.
Why didn't it work for you?

SMF spam blocked by CleanTalk