Object useinventory problem

Started by dbuske, Sun 31/07/2011 22:59:59

Previous topic - Next topic

dbuske

function oTwist_UseInv()
{
cJudge.ActiveInventory = iBook;
Display("You use the Book to smash the twisted head.");
cJudge.LoseInventory(iBook);
FadeObjectOut(oTwist, 100, 2);
Display("There is a paper in the twisted head. You pick up the paper.");
cJudge.AddInventory(iPage);
}

Above is the code for it.  What is happening is I can't get the mouse to pick up the book in Inventory.
This code worked in another game and I don't get any error messages.
I was working in the global script before this putting looks in for all the inventory objects.
Could I have changed something by mistake?
What if your blessings come through raindrops
What if your healing comes through tears...

Khris

The code needs to check for the active item, not set it:

Code: ags
function oTwist_UseInv()
{
  if (cJudge.ActiveInventory == iBook)  // only react if the book was used on oTwist
  {
    Display("You use the Book to smash the twisted head.");
    cJudge.LoseInventory(iBook);
    FadeObjectOut(oTwist, 100, 2);
    Display("There is a paper in the twisted head. You pick up the paper.");
    cJudge.AddInventory(iPage);
  }
  else Display("You can't use that here.");
}


This problem:
Quote from: dbuske on Sun 31/07/2011 22:59:59What is happening is I can't get the mouse to pick up the book in Inventory.
is unrelated to the code;
can you pick up other inv items? Did it work at first, then not or did it not work from the start?
Did you check the dimensions set in the InventoryWindow's property pane (ItemWidth, ItemHeight) versus the sprite size of the inventory item iBook?
Afaik, inventory clicks only register on the area determined by the dimensions, no matter how big the sprite is.

dbuske

Thanks for the great reponse.  I will check all that out
What if your blessings come through raindrops
What if your healing comes through tears...

dbuske

#3
It works if I click on the very top of the inv item.
I made the size of the inventory gui bigger and inv items smaller and still I have to
click near the top of the icon.
I am going to check the Inventory property pane now.
What if your blessings come through raindrops
What if your healing comes through tears...

monkey0506

Could you tell us the following information?

- The Width, Height, and Location (X, Y) of the GUI that has the InvWindow control on it.
- The ItemWidth and ItemHeight, set on the InvWindow control.
- The width and height of your inventory sprites.

This will help us determine what your problem is. You should be able to get all of this from the Properties pane of the GUI, InvWindow, and the sprites.

Khris

The InvWindow's ItemWidth and ItemHeight values determine the dimensions of the grid. Inventory item sprites are drawn with their top left corner at a grid cell's top left corner. The cell dimensions are also used to calculate which item was clicked from the mouse coordinates relative to the InvWindow's top left corner.

If the sprites are bigger than the cells, they will overlap; and the part outside the cell won't be clickable.

dbuske

Thanks for the replies. Yes some of the inventory sprites are larger than others and some wider.
I will check out the things you both mentioned right now.
By the way the game I am working on is a take off on "The Marionette" from Team Effigy.
First person, horror.  I am thinking about calling it "The Judge."
What if your blessings come through raindrops
What if your healing comes through tears...

dbuske

Problem fixed, thanks to the responders.
I just made itemheight and itemwidth larger, now it works perfect.

My main big puzzle is the player has to collect musical notes. Then at  the end they will have to
put the musical notes on a piece of paper in the correct order. If they don't, they die.
If they do they autochangeroom to the conclusion end and survive.
I want to try hard to get it scripted on my own before asking for help. I used a fragment of Mozart music which you
have to solve puzzles to find.
What if your blessings come through raindrops
What if your healing comes through tears...

SMF spam blocked by CleanTalk