Nothing comes up when I look at an item

Started by flicky1991, Tue 29/07/2008 10:19:36

Previous topic - Next topic

flicky1991

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?

Matti

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.

flicky1991

Yes, it is in the global script. As I said, I followed the tutorial.

Matti

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?

Creator

#4
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'?

OneDollar

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.

flicky1991

#6
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.

Khris

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

flicky1991

OK, then that doesn't help what I'm trying to do.

.M.M.

Maybe, your inventory window isnt active. Look at settings of your inventory window if Clickable is set on True.

flicky1991


Matti

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.

flicky1991

Yes, it is set on True. It still doesn't work! I can't do anything to any items in my inventory!

Matti

Perhaps there's something wrong with your on_mouseclick-code in the global script. Would be helpful if you post it here.

flicky1991

This is the code, but I haven't changed it from how it started, so I don't see how it could be wrong:

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

Makeout Patrol

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.

flicky1991

Nope, can't get any of that stuff to work.  :(

SMF spam blocked by CleanTalk