Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: flicky1991 on Tue 29/07/2008 10:19:36

Title: Nothing comes up when I look at an item
Post by: flicky1991 on Tue 29/07/2008 10:19:36
I followed the tutorial, and wrote a script for when I look at an item in my inventory:

Quotefunction iBottle_Look()
{
  Display ("Yes, you're carrying a massive water bottle. You don't even have a bag. It's best not to ask about it.");
}

However, when I look at the item, nothing happens. What have I done wrong?
Title: Re: Nothing comes up when I look at an item
Post by: Matti on Tue 29/07/2008 10:24:25
Did you perhaps put that code in a room's script? Then it would only appear when looking at the item and being in the room at the same time. You have to put it into the global script.
Title: Re: Nothing comes up when I look at an item
Post by: flicky1991 on Tue 29/07/2008 10:30:43
Yes, it is in the global script. As I said, I followed the tutorial.
Title: Re: Nothing comes up when I look at an item
Post by: Matti on Tue 29/07/2008 10:35:51
Can you click the items (e.g. use them)? If not then perhaps there's something wrong with your GUI. Do you use the given Inventory GUI?
Title: Re: Nothing comes up when I look at an item
Post by: Creator on Tue 29/07/2008 12:24:19
Did you check that iBottle_Look() is actually defined in the inventory window properties by clicking on the lightning bolt?

EDIT: Never mind. Saw you followed the tutorial. Must actually read the posts, not skim. Maybe the 'Look' button on the GUI doesn't change the cursor to 'eModeLook'?
Title: Re: Nothing comes up when I look at an item
Post by: OneDollar on Tue 29/07/2008 14:29:21
Creator's point is the most likely answer; you always have to link your code to an action. Make sure that when you choose the inventory item and click the Events lightning bolt you have iBottle_Look written next to Look at inventory item.

If you've already done that let us know.
Title: Re: Nothing comes up when I look at an item
Post by: flicky1991 on Tue 29/07/2008 18:52:49
Quote from: OneDollar on Tue 29/07/2008 14:29:21
Creator's point is the most likely answer; you always have to link your code to an action. Make sure that when you choose the inventory item and click the Events lightning bolt you have iBottle_Look written next to Look at inventory item.

If you've already done that let us know.

Yes, I have done that.

I also don't understand the "crosshair" thingy - does that mean you can only click on a specific pixel to activate it?

EDIT:
Quote from: matti on Tue 29/07/2008 10:35:51
Can you click the items (e.g. use them)?
No, that doesn't work either.
Title: Re: Nothing comes up when I look at an item
Post by: Khris on Tue 29/07/2008 19:34:33
The crosshair specifies the item's hotspot if it's active and displayed as mouse cursor. (E.g. the hotspot of the windows mouse cursor is the arrow's tip.)
Title: Re: Nothing comes up when I look at an item
Post by: flicky1991 on Tue 29/07/2008 19:54:15
OK, then that doesn't help what I'm trying to do.
Title: Re: Nothing comes up when I look at an item
Post by: .M.M. on Tue 29/07/2008 20:09:11
Maybe, your inventory window isnt active. Look at settings of your inventory window if Clickable is set on True.
Title: Re: Nothing comes up when I look at an item
Post by: flicky1991 on Tue 29/07/2008 20:18:36
Where's that?  ???
Title: Re: Nothing comes up when I look at an item
Post by: Matti on Wed 30/07/2008 13:19:09
Quote from: flicky1991 on Tue 29/07/2008 20:18:36
Where's that?  ???

Obviously where all the other things are: at the panel on the right. There's a GUI section where you can add, delete and change GUIs.

You should probably go through the GUI section in the manual. It's in "other features" I think.
Title: Re: Nothing comes up when I look at an item
Post by: flicky1991 on Fri 01/08/2008 15:50:34
Yes, it is set on True. It still doesn't work! I can't do anything to any items in my inventory!
Title: Re: Nothing comes up when I look at an item
Post by: Matti on Fri 01/08/2008 16:25:27
Perhaps there's something wrong with your on_mouseclick-code in the global script. Would be helpful if you post it here.
Title: Re: Nothing comes up when I look at an item
Post by: flicky1991 on Sun 03/08/2008 09:33:41
This is the code, but I haven't changed it from how it started, so I don't see how it could be wrong:

function on_mouse_click(MouseButton button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) {
    ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
  else if (button == eMouseRight || button == eMouseWheelSouth){
    // right-click our mouse-wheel down, so cycle cursor
    mouse.SelectNextMode();
  }
  else if (button == eMouseMiddle) {
    // Middle-button-click, default make character walk to clicked area (a little shortcut)
    // Could have been just "player.Walk(mouse.x,mouse.y)", but it's best to
    // leave our options open - what if you have a special script triggered
    // on "walking" mode?
    ProcessClick(mouse.x, mouse.y, eModeWalkto);
  }
  else if (button == eMouseWheelNorth) {
    // Mouse-wheel up, cycle cursors
    // If mode isn't WALK, set the previous mode (notice usage of numbers instead
    // of eNums, when it suits us)...
    if (mouse.Mode>0) mouse.Mode=mouse.Mode-1;
    else
    {
      // ...but if it is WALK mode...
      if (player.ActiveInventory!=null)
      {
        //...and the player has a selected inventory item, set mouse mode to UseInv.
        mouse.Mode=eModeUseinv;
      }
      else
      {
        // If they don't, however, just set it to mode TALK (change this line if you add more cursor modes)
        mouse.Mode=eModeTalkto;
      }
    }
  }
}
Title: Re: Nothing comes up when I look at an item
Post by: Makeout Patrol on Sun 03/08/2008 09:59:21
What GUI type is the inventory GUI? If it's pausing the game when it's showing up, that will be why your clicks aren't responding - note the IsGamePaused check at the very beginning. You'll either have to make it so that the GUI doesn't pause the game when it appears, change the logic in your on_mouse_click so that clicking works when the inventory GUI is displayed, or (and I would say that this is the best option) enable the inventory clicks script command setting (I forget its exact name, search for those sorts of names in the manual, I think it's an option in the main game preferences screen) and set up inventory left and right clicks in this script.
Title: Re: Nothing comes up when I look at an item
Post by: flicky1991 on Sun 03/08/2008 10:41:17
Nope, can't get any of that stuff to work.  :(