Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: picklegreen on Wed 15/06/2011 06:13:50

Title: inventory objects unresponsive
Post by: picklegreen on Wed 15/06/2011 06:13:50
I am a complete begginner.
I have looked in the tutorials but can't seem to find any tutorials using gui.
I have created my game using the template "new game" on AGS with the 9verb gui.
My gui has give,open,close,pick up,look at,talk to,use,push and pull.
I have only changed the btnMainBack image, re- positioned the gui at the top of the screen  and added a @score@ the rest is defaut.
I am able to talk to characters and pick up objects.

MY PROBLEM IS THIS....

When I have an item in my inventory and I hover the mouse over it e.g the key, the item name is not displayed on screen (it still says "go to")

The same happens if I click  give, look ect button first.

So in short I can pick up my objects but not use them once in the inventory.

Any idea's as to what I'm doing wrong here?
Title: Re: inventory objects unresponsive
Post by: picklegreen on Wed 15/06/2011 06:37:12
Also if I click "use" then an item I get this message

****

"AGS had a problem running your gane, The error can be seen below, and is most likley due to as scripting problem. The line in the script where this occured is highlighted for you"

File.        Line
Guiscript.    1558

*****

This is highlighted in yellow on the script page..

***

" If (isAction(eGA_use) && ii.IsInteractionAvailable(eModeInteract))

***

I'll be honest I have no idea what it all means it's from the template/default games script.


Title: Re: inventory objects unresponsive
Post by: Khris on Wed 15/06/2011 08:10:21
The 9 verb GUI is more complicated to use than say a Default game. It does have pretty extensive documentation though, there's a file called 9Verbs.pdf in the game directory.

Regarding your problem I'm not sure what happened, could you zip and upload the game files so we can take a look?
Title: Re: inventory objects unresponsive
Post by: picklegreen on Wed 15/06/2011 11:46:05
I might be able to upload it, where would I upload it to?
Title: Re: inventory objects unresponsive
Post by: Matti on Wed 15/06/2011 12:02:44
Here for example: http://www.zshare.net/
Title: Re: inventory objects unresponsive
Post by: picklegreen on Thu 16/06/2011 09:57:04
Ok I started again and tested after every change I made the problem occoured after switching the visibility of the gMaingui (NormalGUI 1) to "when mouse moves to top if screen"

Does this help ?
Title: Re: inventory objects unresponsive
Post by: Khris on Thu 16/06/2011 10:23:10
Yes. If the GUI uses that visibility mode, the game gets paused whenever the GUI is displayed.

Clicks on GUI elements are usually handled in their own function independent of whether the game is paused, the exception here are clicks on inventory items though, those are handled by the on_mouse_click function in guiscript.asc.

Since that function processes all other clicks, too, it was coded to do nothing if the game is paused.

Find line 1447:
    if (IsGamePaused()) {

change it to this:
    if (IsGamePaused() && button != eMouseLeftInv && button != eMouseRightInv) {

This is sort of a quick and dirty fix; it might break other stuff. Be sure to test it well.
Title: Re: inventory objects unresponsive
Post by: picklegreen on Thu 16/06/2011 10:34:25
Thanks but I'm afriad this did not sort out the problem, according to AGS the error occurs on line 1558 : if (isAction(eGA_use) && ii.IsInteractionAvailable (eModeInteract)) {



(Error running fuction 'on mouse click':
Error: Null pointer referenced )
Title: Re: inventory objects unresponsive
Post by: Khris on Thu 16/06/2011 10:57:14
The error occurs because ii is null; that's because it seems when line 1428:

    InventoryItem*ii = InventoryItem.GetAtScreenXY(x, y);

is run, the GUI is already invisible again, i.e. AGS turns it off, then processes the click.

The solution is to replace this line with:

    InventoryItem*ii = inventory[game.inv_activated];

I have to say though that you're sort of ruining the GUI's main concept. It's entire behavior (including for instance showing different default actions triggered by a right click e.g. "open door") is built for it to be visible throughout the game.
You are of course free to do whatever you want but the way you're using it renders much of it's functionality sort of crippled.
Be prepared for quite a few comments along those lines when you publish your game :)
Title: Re: inventory objects unresponsive
Post by: picklegreen on Thu 16/06/2011 15:37:10
Great, that seems to have done the trick thanks, and thanks for the advice but it seems to work ok for me. After all  mi3 doesn't always have the inventory showing (9coinverb) and I love that game.
Title: Re: inventory objects unresponsive
Post by: picklegreen on Tue 21/06/2011 08:01:44

Quote from: Khris on Thu 16/06/2011 10:57:14

I have to say though that you're sort of ruining the GUI's main concept. It's entire behavior (including for instance showing different default actions triggered by a right click e.g. "open door") is built for it to be visible throughout the game.
You are of course free to do whatever you want but the way you're using it renders much of it's functionality sort of crippled.
Be prepared for quite a few comments along those lines when you publish your game :)


I have been thinking about this, you may have a point for instance:

**When I want to look, talk, or open it works fine I just move the mouse to the top the inventory pops down then I can click open, it dissapears then I click the door.. Easy. BUT if I want to give something to someone I scroll to the top click give then the inventory dissapears so I have to move the mouse pointer down then back up again to click the item **

maybe I could have an icon that I can click to show the iventory and then I stays open until I click it again or something? I just don't want it there while I'm walking around.
Title: Re: inventory objects unresponsive
Post by: Khris on Tue 21/06/2011 08:37:58
Yeah, I was about to mention the "click twice" situation in my previous post but decided against it :)

The thing is, having a button that keeps the GUI open is even more inconvenient. Think about it:

1. click stay open button
2. click give
3. click item
4. click stay open button again (optional)

There's another way though; you can code the GUI's behavior manually. If you do this, the GUI won't automatically disappear after a click.

Set the GUI's visibility to "normal, off".
Then put this in repeatedly_execute:

  if (mouse.y < 10 && !gMaingui.Visible) gMaingui.Visible = true;
  if (GUI.GetAtScreenXY(mouse.x, mouse.y) != gMaingui && gMaingui.Visible) gMaingui.Visible = false;