inventory objects unresponsive

Started by picklegreen, Wed 15/06/2011 06:13:50

Previous topic - Next topic

picklegreen

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?

picklegreen

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.



Khris

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?

picklegreen

I might be able to upload it, where would I upload it to?


picklegreen

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 ?

Khris

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:
Code: ags
    if (IsGamePaused()) {


change it to this:
Code: ags
    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.

picklegreen

#7
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 )

Khris

The error occurs because ii is null; that's because it seems when line 1428:

Code: ags
    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:

Code: ags
    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 :)

picklegreen

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.

picklegreen


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.

Khris

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:

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

SMF spam blocked by CleanTalk